diff --git a/.gitattributes b/.gitattributes index 0bb56aff483..3940ce8ea51 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1727,6 +1727,7 @@ Installation/cmake/modules/CGAL_SetupLEDA.cmake -text Installation/cmake/modules/CGAL_SetupMPFI.cmake -text Installation/cmake/modules/CGAL_SetupNTL.cmake -text Installation/cmake/modules/CGAL_SetupRS.cmake -text +Installation/cmake/modules/CGAL_TweakFindBoost.cmake -text Installation/cmake/modules/CGAL_UseBLAS.cmake -text Installation/cmake/modules/CGAL_UseLAPACK.cmake -text Installation/cmake/modules/CGAL_UseMKL.cmake -text diff --git a/Installation/cmake/modules/CGALConfig_binary.cmake.in b/Installation/cmake/modules/CGALConfig_binary.cmake.in index 7039b0d1ffa..da924971ab4 100644 --- a/Installation/cmake/modules/CGALConfig_binary.cmake.in +++ b/Installation/cmake/modules/CGALConfig_binary.cmake.in @@ -15,7 +15,8 @@ set(CGAL_MAJOR_VERSION "@CGAL_MAJOR_VERSION@" ) set(CGAL_MINOR_VERSION "@CGAL_MINOR_VERSION@" ) set(CGAL_BUILD_VERSION "@CGAL_BUILD_VERSION@" ) -set(CGAL_BUILD_SHARED_LIBS "@CGAL_BUILD_SHARED_LIBS@" ) +set(CGAL_BUILD_SHARED_LIBS "@CGAL_BUILD_SHARED_LIBS@" ) +set(CGAL_Boost_USE_STATIC_LIBS "@CGAL_Boost_USE_STATIC_LIBS@" ) set(CGAL_CXX_FLAGS_INIT "@CMAKE_CXX_FLAGS@" ) set(CGAL_CXX_FLAGS_RELEASE_INIT "@CMAKE_CXX_FLAGS_RELEASE@" ) diff --git a/Installation/cmake/modules/CGALConfig_install.cmake.in b/Installation/cmake/modules/CGALConfig_install.cmake.in index 4a77f200642..0ae8ef6f5bb 100644 --- a/Installation/cmake/modules/CGALConfig_install.cmake.in +++ b/Installation/cmake/modules/CGALConfig_install.cmake.in @@ -11,11 +11,12 @@ set(CGAL_CONFIG_LOADED TRUE) # CGAL_DIR is the directory where this CGALConfig.cmake is installed set(CGAL_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@") -set(CGAL_MAJOR_VERSION "@CGAL_MAJOR_VERSION@" ) -set(CGAL_MINOR_VERSION "@CGAL_MINOR_VERSION@" ) -set(CGAL_BUILD_VERSION "@CGAL_BUILD_VERSION@" ) +set(CGAL_MAJOR_VERSION "@CGAL_MAJOR_VERSION@" ) +set(CGAL_MINOR_VERSION "@CGAL_MINOR_VERSION@" ) +set(CGAL_BUILD_VERSION "@CGAL_BUILD_VERSION@" ) -set(CGAL_BUILD_SHARED_LIBS "@CGAL_BUILD_SHARED_LIBS@" ) +set(CGAL_BUILD_SHARED_LIBS "@CGAL_BUILD_SHARED_LIBS@" ) +set(CGAL_Boost_USE_STATIC_LIBS "@CGAL_Boost_USE_STATIC_LIBS@" ) set(CGAL_CXX_FLAGS_INIT "@CMAKE_CXX_FLAGS@" ) set(CGAL_CXX_FLAGS_RELEASE_INIT "@CMAKE_CXX_FLAGS_RELEASE@" ) diff --git a/Installation/cmake/modules/CGAL_SetupBoost.cmake b/Installation/cmake/modules/CGAL_SetupBoost.cmake index 4369fcfc104..fc3dc11f4c3 100644 --- a/Installation/cmake/modules/CGAL_SetupBoost.cmake +++ b/Installation/cmake/modules/CGAL_SetupBoost.cmake @@ -1,25 +1,9 @@ if ( NOT CGAL_Boost_Setup ) - - if(WIN32) - option(CGAL_BOOST_USE_STATIC_LIBS "Link with static Boost libraries" OFF) - if(CGAL_BOOST_USE_STATIC_LIBS) - set(Boost_USE_STATIC_LIBS ON) - else() - set(Boost_USE_STATIC_LIBS OFF) - add_to_cached_list(CGAL_3RD_PARTY_DEFINITIONS -DBOOST_ALL_DYN_LINK) - endif() - else(WIN32) - if ( NOT BUILD_SHARED_LIBS ) - set(Boost_USE_STATIC_LIBS ON) - endif() - endif(WIN32) - - set(Boost_FIND_VERSION 1.33.1 ) - set(Boost_FIND_VERSION_MAJOR 1 ) - set(Boost_FIND_VERSION_MINOR 33 ) - set(Boost_FIND_VERSION_PATCH 1 ) - - find_package( Boost REQUIRED thread ) + + include(CGAL_TweakFindBoost) + # In the documentation, we say we require Boost-1.39, but technically we + # require 1.33.1. Some packages may require more recent versions, though. + find_package( Boost 1.33.1 REQUIRED thread ) message( STATUS "Boost include: ${Boost_INCLUDE_DIRS}" ) message( STATUS "Boost libraries: ${Boost_LIBRARIES}" ) diff --git a/Installation/cmake/modules/CGAL_TweakFindBoost.cmake b/Installation/cmake/modules/CGAL_TweakFindBoost.cmake new file mode 100644 index 00000000000..f50b7d406fe --- /dev/null +++ b/Installation/cmake/modules/CGAL_TweakFindBoost.cmake @@ -0,0 +1,75 @@ +# - Defines Boost_USE_STATIC_LIBS and Boost_ADDITIONAL_VERSIONS +# +# This module sets the CMake variables: +# +# == Boost_USE_STATIC_LIBS == +# +# The option CGAL_Boost_USE_STATIC_LIBS is created in the cache, as +# advanced option. If CGALConfig.cmake has been loaded, the default value +# of that option is the value loaded from CGALConfig.cmake (this file was +# created during the configuration of CGAL libraries). Otherwise, the +# default value of that option is OFF. +# +# The variable Boost_USE_STATIC_LIBS is set to the value of the option +# CGAL_Boost_USE_STATIC_LIBS. +# +# Additionally, if Boost_USE_STATIC_LIBS is OFF, the definition +# BOOST_ALL_DYN_LINK is added to CGAL_3RD_PARTY_DEFINITIONS, so that the +# auto-linking feature on Windows knows that it must search for dynamic +# libraries. +# +# == Boost_ADDITIONAL_VERSIONS == +# +# This option is filled with a long list of Boost versions. That allows the +# module FindBoost to find more recent Boost versions, even if the file +# FindBoost.cmake is old. + +if( NOT CGAL_TweakFindBoost ) + if(CGAL_Boost_USE_STATIC_LIBS) + # If the option is loaded from CGALConfig.h, use its value as default + # value. But the user will still have the choice to change the + # value. That means that we can build the CGAL libraries using static + # or shared Boost libraries, and after build programs using CGAL with a + # different setting for Boost libraries. + set(CGAL_Boost_USE_STATIC_LIBS_DEFAULT ${CGAL_Boost_USE_STATIC_LIBS}) + else() + # Else the option is OFF by default. That means the use of shared Boost + # libraries is the default. + set(CGAL_Boost_USE_STATIC_LIBS_DEFAULT OFF) + endif() + + option(CGAL_Boost_USE_STATIC_LIBS "Link with static Boost libraries" ${CGAL_Boost_USE_STATIC_LIBS_DEFAULT}) + mark_as_advanced(CGAL_Boost_USE_STATIC_LIBS) + + if(CGAL_Boost_USE_STATIC_LIBS) + set(Boost_USE_STATIC_LIBS ON) + else() + set(Boost_USE_STATIC_LIBS OFF) + add_to_cached_list(CGAL_3RD_PARTY_DEFINITIONS -DBOOST_ALL_DYN_LINK) + endif() + + set(Boost_ADDITIONAL_VERSIONS + "1.56.1" "1.56.0" "1.56" + "1.55.1" "1.55.0" "1.55" + "1.54.1" "1.54.0" "1.54" + "1.53.1" "1.53.0" "1.53" + "1.52.1" "1.52.0" "1.52" + "1.51.1" "1.51.0" "1.51" + "1.50.1" "1.50.0" "1.50" + "1.49.1" "1.49.0" "1.49" + "1.48.1" "1.48.0" "1.48" + "1.47.1" "1.47.0" "1.47" + "1.46.1" "1.46.0" "1.46" + "1.45.1" "1.45.0" "1.45" + "1.44.1" "1.44.0" "1.44" + "1.43.1" "1.43.0" "1.43" + "1.42.1" "1.42.0" "1.42" + "1.41.1" "1.41.0" "1.41" + "1.40.1" "1.40.0" "1.40" + "1.39.1" "1.39.0" "1.39" + "1.38.1" "1.38.0" "1.38" + "1.37.1" "1.37.0" "1.37") + + + set(CGAL_TweakFindBoost) +endif() diff --git a/Installation/cmake/modules/UseCGAL.cmake b/Installation/cmake/modules/UseCGAL.cmake index 3d904583a89..443a5b4b2d6 100644 --- a/Installation/cmake/modules/UseCGAL.cmake +++ b/Installation/cmake/modules/UseCGAL.cmake @@ -17,6 +17,7 @@ if(NOT USE_CGAL_FILE_INCLUDED) include(CGAL_Common) include(CGAL_SetupFlags) include(CGAL_GeneratorSpecificSettings) + include(CGAL_TweakFindBoost) set( CGAL_LIBRARIES )