diff --git a/Installation/cmake/modules/CGAL_SetupCGAL_CoreDependencies.cmake b/Installation/cmake/modules/CGAL_SetupCGAL_CoreDependencies.cmake index 6dfc58a8bc7..e22308e0025 100644 --- a/Installation/cmake/modules/CGAL_SetupCGAL_CoreDependencies.cmake +++ b/Installation/cmake/modules/CGAL_SetupCGAL_CoreDependencies.cmake @@ -53,6 +53,12 @@ endif() # keyword, or ``PUBLIC`` otherwise. # +# See the release notes of CGAL-4.10: CGAL_Core now requires +# Boost.Thread, with all compilers but MSVC. +if (NOT MSVC) + find_package( Boost 1.48 REQUIRED thread system ) +endif() + function(CGAL_setup_CGAL_Core_dependencies target) if(ARGV1 STREQUAL INTERFACE) set(keyword INTERFACE) @@ -60,13 +66,24 @@ function(CGAL_setup_CGAL_Core_dependencies target) set(keyword PUBLIC) endif() + use_CGAL_GMP_support(CGAL_Core ${keyword}) + target_compile_definitions(${target} ${keyword} CGAL_USE_CORE=1) + target_link_libraries( CGAL_Core ${keyword} CGAL::CGAL ) + # See the release notes of CGAL-4.10: CGAL_Core now requires # Boost.Thread, with all compilers but MSVC. if (NOT MSVC) - find_package( Boost 1.48 REQUIRED thread system ) + if(TARGET Boost::thread) + target_link_libraries( CGAL_Core ${keyword} Boost::thread) + else() + # Note that `find_package( Boost...)` must be called in the + # function `CGAL_setup_CGAL_Core_dependencies()` because the + # calling `CMakeLists.txt` may also call `find_package(Boost)` + # between the inclusion of this module, and the call to this + # function. That resets `Boost_LIBRARIES`. + find_package( Boost 1.48 REQUIRED thread system ) + target_link_libraries( CGAL_Core ${keyword} ${Boost_LIBRARIES}) + endif() endif() - use_CGAL_GMP_support(CGAL_Core ${keyword}) - target_compile_definitions(${target} ${keyword} CGAL_USE_CORE=1) - target_link_libraries( CGAL_Core ${keyword} CGAL::CGAL ${Boost_LIBRARIES}) endfunction()