From f16e5d0698f841bc76b92168033c5d76a28df2ff Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Mon, 14 Jun 2010 16:47:06 +0000 Subject: [PATCH] Reintegrate the work of /branches/unsorted-branches/Test-no_autolink-for-gmp_mpfr-branch/Installation: If(MSVC), create CMake variables CGAL_AUTO_LINK_GMP and CGAL_AUTO_LINK_GMP that can be set to OFF to disable the autolinking for GMP and MPFR. Those variables are stored in the cache, and in CGALConfig.cmake --- .../cmake/modules/CGALConfig_binary.cmake.in | 2 ++ .../modules/CGAL_GeneratorSpecificSettings.cmake | 8 ++++++++ Installation/cmake/modules/CGAL_SetupGMP.cmake | 12 ++++++++++-- Installation/cmake/modules/FindGMP.cmake | 9 +++++---- Installation/cmake/modules/FindMPFR.cmake | 16 ++++++++-------- 5 files changed, 33 insertions(+), 14 deletions(-) diff --git a/Installation/cmake/modules/CGALConfig_binary.cmake.in b/Installation/cmake/modules/CGALConfig_binary.cmake.in index 4a0a081593b..83a09402582 100644 --- a/Installation/cmake/modules/CGALConfig_binary.cmake.in +++ b/Installation/cmake/modules/CGALConfig_binary.cmake.in @@ -73,6 +73,8 @@ set(CGAL_Qt4_3RD_PARTY_LIBRARIES "@CGAL_Qt4_3RD_PARTY_LIBRARIES@" ) set(CGAL_VERSION "${CGAL_MAJOR_VERSION}.${CGAL_MINOR_VERSION}.${CGAL_BUILD_VERSION}") set(CGAL_GMP_VERSION "@GMP_VERSION@") set(CGAL_MPFR_VERSION "@MPFR_VERSION@") +set(CGAL_AUTO_LINK_GMP "@CGAL_AUTO_LINK_GMP@") +set(CGAL_AUTO_LINK_MPFR "@CGAL_AUTO_LINK_MPFR@") set(CGAL_USE_FILE "${CGAL_CMAKE_MODULE_PATH}/UseCGAL.cmake" ) diff --git a/Installation/cmake/modules/CGAL_GeneratorSpecificSettings.cmake b/Installation/cmake/modules/CGAL_GeneratorSpecificSettings.cmake index 1c859fc9f1e..4274c5b7ba3 100644 --- a/Installation/cmake/modules/CGAL_GeneratorSpecificSettings.cmake +++ b/Installation/cmake/modules/CGAL_GeneratorSpecificSettings.cmake @@ -6,6 +6,14 @@ if ( NOT CGAL_GENERATOR_SPECIFIC_SETTINGS_FILE_INCLUDED ) if ( MSVC ) message( STATUS "Target build enviroment supports auto-linking" ) set(CGAL_AUTO_LINK_ENABLED TRUE) + + if(NOT CGAL_CONFIG_LOADED) + set(CGAL_AUTO_LINK_GMP TRUE + CACHE BOOL "Enable/Disable auto-linking for the external library GMP") + + set(CGAL_AUTO_LINK_MPFR TRUE + CACHE BOOL "Enable/Disable auto-linking for the external library MPFR") + endif() endif() if ( MSVC10 ) diff --git a/Installation/cmake/modules/CGAL_SetupGMP.cmake b/Installation/cmake/modules/CGAL_SetupGMP.cmake index f8f1f93c8a1..d95afb9163f 100644 --- a/Installation/cmake/modules/CGAL_SetupGMP.cmake +++ b/Installation/cmake/modules/CGAL_SetupGMP.cmake @@ -16,6 +16,7 @@ if ( NOT CGAL_GMP_SETUP ) message( STATUS "MPFR include: ${MPFR_INCLUDE_DIR}" ) message( STATUS "MPFR libraries: ${MPFR_LIBRARIES}" ) message( STATUS "MPFR definitions: ${MPFR_DEFINITIONS}" ) + set( MPFR_DEPENDENCY_LIBRARIES ${GMP_LIBRARIES} ) set( MPFR_DEPENDENCY_INCLUDE_DIR ${GMP_INCLUDE_DIR} ) get_dependency_version(MPFR) @@ -30,11 +31,18 @@ if ( NOT CGAL_GMP_SETUP ) add_to_cached_list(CGAL_3RD_PARTY_LIBRARIES_DIRS ${GMP_LIBRARIES_DIR} ) add_to_cached_list(CGAL_3RD_PARTY_DEFINITIONS ${GMP_DEFINITIONS} ) - if ( NOT MSVC ) + if ( NOT CGAL_AUTOLINK_MPFR ) add_to_cached_list(CGAL_3RD_PARTY_LIBRARIES ${MPFR_LIBRARIES} ) + endif() + if ( NOT CGAL_AUTOLINK_GMP ) add_to_cached_list(CGAL_3RD_PARTY_LIBRARIES ${GMP_LIBRARIES} ) endif() - + if ( MSVC AND NOT CGAL_AUTOLINK_MPFR ) + add_to_cached_list(CGAL_3RD_PARTY_DEFINITIONS -DCGAL_NO_AUTOLINK_MPFR ) + endif() + if ( MSVC AND NOT CGAL_NO_AUTOLINK_GMP ) + add_to_cached_list(CGAL_3RD_PARTY_DEFINITIONS -DCGAL_NO_AUTOLINK_GMP ) + endif() else( MPFR_FOUND ) message("CGAL GMP support needs MPFR. GMP will not be supported.") diff --git a/Installation/cmake/modules/FindGMP.cmake b/Installation/cmake/modules/FindGMP.cmake index c88a3d898e0..742ca0a9f99 100644 --- a/Installation/cmake/modules/FindGMP.cmake +++ b/Installation/cmake/modules/FindGMP.cmake @@ -15,7 +15,7 @@ if(GMP_INCLUDE_DIR) else() set(GMP_in_cache FALSE) endif() -if( CGAL_AUTO_LINK_ENABLED ) +if( CGAL_AUTO_LINK_GMP ) if(NOT GMP_LIBRARIES_DIR) set(GMP_in_cache FALSE) endif() @@ -43,7 +43,7 @@ else() cache_set( GMP_IN_CGAL_AUXILIARY TRUE ) endif() - if ( CGAL_AUTO_LINK_ENABLED ) + if ( CGAL_AUTO_LINK_GMP ) find_path(GMP_LIBRARIES_DIR NAMES "gmp-${CGAL_TOOLSET}-mt.lib" "gmp-${CGAL_TOOLSET}-mt-gd.lib" @@ -54,8 +54,9 @@ else() else() - find_library(GMP_LIBRARIES NAMES gmp + find_library(GMP_LIBRARIES NAMES gmp gmp-1 gmp-2 gmp-3 gmp-4 gmp-5 PATHS ENV GMP_LIB_DIR + ${CMAKE_SOURCE_DIR}/auxiliary/gmp/lib DOC "Path to the GMP library" ) @@ -70,7 +71,7 @@ else() include( GMPConfig OPTIONAL ) endif() - if(CGAL_AUTO_LINK_ENABLED) + if(CGAL_AUTO_LINK_GMP) find_package_handle_standard_args(GMP "DEFAULT_MSG" GMP_LIBRARIES_DIR GMP_INCLUDE_DIR) else() find_package_handle_standard_args(GMP "DEFAULT_MSG" GMP_LIBRARIES GMP_INCLUDE_DIR) diff --git a/Installation/cmake/modules/FindMPFR.cmake b/Installation/cmake/modules/FindMPFR.cmake index e556534d8aa..88d6c81f78e 100644 --- a/Installation/cmake/modules/FindMPFR.cmake +++ b/Installation/cmake/modules/FindMPFR.cmake @@ -15,7 +15,7 @@ if(MPFR_INCLUDE_DIR) else() set(MPFR_in_cache FALSE) endif() -if( CGAL_AUTO_LINK_ENABLED ) +if( CGAL_AUTO_LINK_MPFR ) if(NOT MPFR_LIBRARIES_DIR) set(MPFR_in_cache FALSE) endif() @@ -34,21 +34,21 @@ else() find_path(MPFR_INCLUDE_DIR NAMES mpfr.h - PATHS ${CMAKE_SOURCE_DIR}/auxiliary/gmp/include - ENV MPFR_INC_DIR - DOC "The directory containing the MPFR header files" + PATHS ENV MPFR_INC_DIR + ${CMAKE_SOURCE_DIR}/auxiliary/gmp/include + DOC "The directory containing the MPFR header files" ) if ( MPFR_INCLUDE_DIR STREQUAL "${CMAKE_SOURCE_DIR}/auxiliary/gmp/include" ) cache_set( MPFR_IN_CGAL_AUXILIARY TRUE ) endif() - if ( CGAL_AUTO_LINK_ENABLED ) + if ( CGAL_AUTO_LINK_MPFR ) find_path(MPFR_LIBRARIES_DIR NAMES "mpfr-${CGAL_TOOLSET}-mt.lib" "mpfr-${CGAL_TOOLSET}-mt-gd.lib" - PATHS ${CMAKE_SOURCE_DIR}/auxiliary/gmp/lib - ENV MPFR_LIB_DIR + PATHS ENV MPFR_LIB_DIR + ${CMAKE_SOURCE_DIR}/auxiliary/gmp/lib DOC "Directory containing the MPFR library" ) @@ -70,7 +70,7 @@ else() include( MPFRConfig OPTIONAL ) endif() - if(CGAL_AUTO_LINK_ENABLED) + if(CGAL_AUTO_LINK_MPFR) find_package_handle_standard_args(MPFR "DEFAULT_MSG" MPFR_LIBRARIES_DIR MPFR_INCLUDE_DIR) else() find_package_handle_standard_args(MPFR "DEFAULT_MSG" MPFR_LIBRARIES MPFR_INCLUDE_DIR)