Fix the CMake module CGAL_SetupBoost shipped with CGAL

CGAL_Boost_USE_STATIC_LIBS is now an (advanced) CMake option on all
platforms, and is stored in the generated CGALConfig.cmake. That way, its
value is proposed as the default value for the same option when programs
using CGAL are configured using CMake.

The script UseCGAL includes the module CGAL_TweakFindBoost, to define
Boost_USE_STATIC_LIBS and Boost_ADDITIONAL_VERSIONS.
This commit is contained in:
Laurent Rineau 2011-10-12 13:47:18 +00:00
parent f15a4f9957
commit 6985effcc8
6 changed files with 89 additions and 26 deletions

1
.gitattributes vendored
View File

@ -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

View File

@ -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@" )

View File

@ -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@" )

View File

@ -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}" )

View File

@ -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()

View File

@ -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 )