mirror of https://github.com/CGAL/cgal
375 lines
14 KiB
CMake
375 lines
14 KiB
CMake
# Top level CMakeLists.txt for CGAL
|
|
# The name of our project is "CGAL". CMakeLists files in this project can
|
|
# refer to the root source directory of the project as ${CMAKE_SOURCE_DIR} or
|
|
# ${CGAL_SOURCE_DIR} and to the root binary directory of the project as
|
|
# ${CMAKE_BINARY_DIR} or ${CGAL_BINARY_DIR}.
|
|
project(CGAL)
|
|
|
|
#--------------------------------------------------------------------------------------------------
|
|
#
|
|
# -= BASIC SETUP =-
|
|
#
|
|
#--------------------------------------------------------------------------------------------------
|
|
|
|
|
|
# Where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
|
|
set(CGAL_CMAKE_MODULE_PATH ${CGAL_SOURCE_DIR}/cmake/modules)
|
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CGAL_CMAKE_MODULE_PATH} )
|
|
|
|
include(CGALcommon)
|
|
include(GeneratorSpecificSettings)
|
|
include(CheckCXXFileRuns)
|
|
include(OptionalAddSubdirectory)
|
|
|
|
mark_as_advanced(CMAKE_BACKWARDS_COMPATIBILITY)
|
|
|
|
#
|
|
# Read and parse CGAL version number from VERSION file
|
|
#
|
|
|
|
file( READ "VERSION" CGAL_VERSION )
|
|
string( REPLACE "-" "." CGAL_VERSION_TOKENS1 ${CGAL_VERSION} )
|
|
string( REPLACE "." ";" CGAL_VERSION_TOKENS ${CGAL_VERSION_TOKENS1} )
|
|
list( LENGTH CGAL_VERSION_TOKENS CGAL_VERSION_TOKENS_LEN )
|
|
list( GET CGAL_VERSION_TOKENS 0 CGAL_MAJOR_VERSION )
|
|
|
|
set(CGAL_MINOR_VERSION)
|
|
set(CGAL_BUILD_VERSION)
|
|
|
|
if ( CGAL_VERSION_TOKENS_LEN GREATER 1 )
|
|
list( GET CGAL_VERSION_TOKENS 1 CGAL_MINOR_VERSION )
|
|
endif()
|
|
|
|
if ( CGAL_VERSION_TOKENS_LEN GREATER 3 )
|
|
list( GET CGAL_VERSION_TOKENS 3 CGAL_BUILD_VERSION )
|
|
elseif( CGAL_VERSION_TOKENS_LEN GREATER 2 )
|
|
list( GET CGAL_VERSION_TOKENS 2 CGAL_BUILD_VERSION )
|
|
endif()
|
|
|
|
message( STATUS "CGAL_MAJOR_VERSION=${CGAL_MAJOR_VERSION}" )
|
|
message( STATUS "CGAL_MINOR_VERSION=${CGAL_MINOR_VERSION}" )
|
|
message( STATUS "CGAL_BUILD_VERSION=${CGAL_BUILD_VERSION}" )
|
|
|
|
#--------------------------------------------------------------------------------------------------
|
|
#
|
|
# -= DEPENDENCIES =-
|
|
#
|
|
#--------------------------------------------------------------------------------------------------
|
|
|
|
set(CGAL_3RD_PARTY_DEFINITIONS)
|
|
set(CGAL_3RD_PARTY_INCLUDE_DIRS)
|
|
set(CGAL_3RD_PARTY_LIBRARIES)
|
|
set(CGAL_3RD_PARTY_LIBRARIES_DIR)
|
|
|
|
# This module finds dependent libraries: Boost, GMP, CORE, etc..
|
|
# Updates CGAL_3RD_PARTY_* accordingly
|
|
# Sets CGAL_USE_* which is stored in compiler_config.h
|
|
# Each dependency can be selected or unselected via the option WITH_*
|
|
include(FindCGALDependencies)
|
|
|
|
|
|
#--------------------------------------------------------------------------------------------------
|
|
#
|
|
# -= Generation of compiler_config.h =-
|
|
#
|
|
#--------------------------------------------------------------------------------------------------
|
|
|
|
# The variables set are the #defines expected by compiler_config.h
|
|
# Note: CMake will not notice when files are added or removed
|
|
# but this is probably OK for the installation procedure.
|
|
|
|
file(GLOB all_config_tests "${CGAL_SOURCE_DIR}/config/testfiles/*.cpp")
|
|
|
|
file( WRITE ${CGAL_BINARY_DIR}/include/CGAL/compiler_config.h "//\n// compiler_config.h is included by CGAL headers to load the needed compiler settings.\n//\n// DO NOT EDIT compiler_config.h. It is generated by CMake.\n//\n\n")
|
|
|
|
macro( add_config_flag flag )
|
|
|
|
if ( ${flag} )
|
|
file( APPEND ${CGAL_BINARY_DIR}/include/CGAL/compiler_config.h "#define ${flag} 1\n\n")
|
|
else()
|
|
file( APPEND ${CGAL_BINARY_DIR}/include/CGAL/compiler_config.h "//#define ${flag} 1\n\n")
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
foreach(config_test_cpp ${all_config_tests})
|
|
|
|
# Test's name is .cpp's base name
|
|
get_filename_component(config_test_name ${config_test_cpp} NAME_WE)
|
|
|
|
# Compile and run ${config_test_cpp}. Exit code is stored in ${config_test_name}.
|
|
CHECK_CXX_FILE_RUNS(${config_test_cpp} ${config_test_name} ${config_test_name})
|
|
|
|
if ( ${config_test_name} )
|
|
set ( ${config_test_name} 0 )
|
|
else()
|
|
set ( ${config_test_name} 1 )
|
|
endif()
|
|
|
|
add_config_flag( ${config_test_name} ${config_test_name} )
|
|
|
|
endforeach()
|
|
|
|
add_config_flag( CGAL_USE_BOOST )
|
|
add_config_flag( CGAL_USE_BOOST_THREAD )
|
|
add_config_flag( CGAL_USE_GMP )
|
|
add_config_flag( CGAL_USE_MPFR )
|
|
add_config_flag( CGAL_USE_GMPXX )
|
|
add_config_flag( CGAL_USE_CGAL_CORE )
|
|
add_config_flag( CGAL_USE_OPENGL )
|
|
add_config_flag( CGAL_USE_ZLIB )
|
|
add_config_flag( CGAL_USE_TAUCS )
|
|
|
|
find_package(Qt3)
|
|
if(QT_FOUND)
|
|
set( CGAL_USE_QT TRUE )
|
|
add_config_flag( CGAL_USE_QT )
|
|
endif()
|
|
|
|
if ( RUNNING_CGAL_AUTO_TEST AND MSVC )
|
|
file( APPEND "${CGAL_BINARY_DIR}/include/CGAL/compiler_config.h" "#include <CGAL/Testsuite/vc_debug_hook.h>")
|
|
endif()
|
|
|
|
#--------------------------------------------------------------------------------------------------
|
|
#
|
|
# -= Installation Setup =-
|
|
#
|
|
#--------------------------------------------------------------------------------------------------
|
|
|
|
option(WITH_INSTALL "Create installation rules")
|
|
|
|
if ( WITH_INSTALL )
|
|
|
|
set ( CGAL_INSTALL_INC_DIR "include" CACHE STRING "The folder where CGAL header files will be installed, relative to CMAKE_INSTALL_PREFIX" )
|
|
set ( CGAL_INSTALL_LIB_DIR "lib" CACHE STRING "The folder where CGAL libraries will be installed, relative to CMAKE_INSTALL_PREFIX" )
|
|
|
|
if ( NOT DEFINED SOURCE_INSTALL )
|
|
if ( WIN32 AND NOT UNIX AND NOT CYGWIN AND NOT WIN32_CMAKE_ON_CYGWIN )
|
|
set ( SOURCE_INSTALL TRUE )
|
|
else()
|
|
set ( SOURCE_INSTALL FALSE )
|
|
endif()
|
|
endif()
|
|
|
|
if ( WIN32_CMAKE_ON_CYGWIN )
|
|
exec_program(cygpath ARGS -w ${CMAKE_INSTALL_PREFIX} OUTPUT_VARIABLE CMAKE_INSTALL_PREFIX2 )
|
|
file ( TO_CMAKE_PATH ${CMAKE_INSTALL_PREFIX2} CMAKE_INSTALL_PREFIX )
|
|
endif()
|
|
|
|
message( STATUS "CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}" )
|
|
|
|
if ( SOURCE_INSTALL )
|
|
|
|
set ( CGAL_INSTALL_BIN_DIR "script" CACHE STRING "The folder where CGAL user-side scripts will be installed, relative to CMAKE_INSTALL_PREFIX" )
|
|
|
|
set ( CGAL_INSTALL_CMAKE_DIR "cmake/modules"
|
|
CACHE STRING "The folder where CGAL CMake modules will be installed, relative to CMAKE_INSTALL_PREFIX"
|
|
)
|
|
|
|
set ( CGAL_INSTALL_ROOT_DIR "."
|
|
CACHE STRING "The folder where CGAL documentation and license files will be installed, relative to CMAKE_INSTALL_PREFIX"
|
|
)
|
|
|
|
set ( CGAL_INSTALL_DOC_DIR "${CGAL_INSTALL_ROOT_DIR}" )
|
|
|
|
else()
|
|
|
|
set ( CGAL_INSTALL_BIN_DIR "bin"
|
|
CACHE STRING "The folder where CGAL user-side scripts will be installed, relative to CMAKE_INSTALL_PREFIX"
|
|
)
|
|
|
|
set ( CGAL_INSTALL_CMAKE_DIR "lib/CGAL-${CGAL_VERSION}"
|
|
CACHE STRING "The folder where CGAL CMake modules will be installed, relative to CMAKE_INSTALL_PREFIX"
|
|
)
|
|
|
|
set ( CGAL_INSTALL_DOC_DIR "share/doc/CGAL-${CGAL_VERSION}"
|
|
CACHE STRING "The folder where CGAL documentation and license files will be installed, relative to CMAKE_INSTALL_PREFIX"
|
|
)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
#--------------------------------------------------------------------------------------------------
|
|
#
|
|
# -= Build =-
|
|
#
|
|
#--------------------------------------------------------------------------------------------------
|
|
|
|
set(CGAL_LIBRARIES_DIR ${CGAL_BINARY_DIR}/lib)
|
|
|
|
set(CGAL_LIBRARIES CACHE STRING "Selected CGAL Libraries")
|
|
hide_variable(CGAL_LIBRARIES)
|
|
|
|
set(CGAL_INCLUDE_DIRS ${CGAL_BINARY_DIR}/include ${CGAL_SOURCE_DIR}/include)
|
|
|
|
include_directories (${CGAL_INCLUDE_DIRS})
|
|
include_directories (${CGAL_3RD_PARTY_INCLUDE_DIRS})
|
|
|
|
add_definitions(${CGAL_3RD_PARTY_DEFINITIONS})
|
|
|
|
set(LIBRARY_OUTPUT_PATH ${CGAL_LIBRARIES_DIR})
|
|
|
|
if( MSVC )
|
|
|
|
set( CGAL_CXX_FLAGS "${CGAL_CXX_FLAGS} -D_CRT_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS" )
|
|
|
|
# _SECURE_SCL=0 is defined because it has been reported that the Secure SCL has an overhead of near one order of magnitude EVEN IN RELEASE BUILDS
|
|
set( CGAL_CXX_FLAGS_RELEASE "${CGAL_CXX_FLAGS_RELEASE} -D_SECURE_SCL=0" )
|
|
|
|
endif()
|
|
|
|
include(CGAL_SetupFlags)
|
|
|
|
add_subdirectory(src)
|
|
|
|
set( CGAL_LIBRARIES ${CGAL_CORE_LIBRARY} ${CGAL_LIBRARY} ${CGAL_IMAGEIO_LIBRARY} ${CGAL_PDB_LIBRARY} ${CGAL_QT_LIBRARY} )
|
|
|
|
hide_variable(EXECUTABLE_OUTPUT_PATH)
|
|
hide_variable(LIBRARY_OUTPUT_PATH)
|
|
|
|
#--------------------------------------------------------------------------------------------------
|
|
#
|
|
# -= USER SIDE SETTINGS =-
|
|
#
|
|
#--------------------------------------------------------------------------------------------------
|
|
|
|
# FindCGAL and UseCGAL are platform specific so they are generated and stored in the binary folder.
|
|
configure_file(${CGAL_SOURCE_DIR}/CGALConfig_binary.cmake.in ${CGAL_BINARY_DIR}/CGALConfig.cmake @ONLY IMMEDIATE)
|
|
|
|
|
|
|
|
if ( SOURCE_INSTALL )
|
|
configure_file(${CGAL_SOURCE_DIR}/CGALConfig_install.cmake.source.in ${CGAL_BINARY_DIR}/cmake/CGALConfig.cmake @ONLY IMMEDIATE)
|
|
else()
|
|
configure_file(${CGAL_SOURCE_DIR}/CGALConfig_install.cmake.fhs.in ${CGAL_BINARY_DIR}/cmake/CGALConfig.cmake @ONLY IMMEDIATE)
|
|
endif()
|
|
|
|
|
|
#--------------------------------------------------------------------------------------------------
|
|
#
|
|
# -= Installation Commands =-
|
|
#
|
|
#--------------------------------------------------------------------------------------------------
|
|
|
|
if ( WITH_INSTALL )
|
|
|
|
# WARNING: Use only relative paths; full paths break CPack!
|
|
# DESTINATION option is mandatory; skipping it breaks CPack!
|
|
|
|
install(FILES CHANGES "INSTALL" INSTALL.MacOSX INSTALL.win32.txt LICENSE LICENSE.FREE_USE LICENSE.LGPL LICENSE.QPL README "VERSION"
|
|
DESTINATION ${CGAL_INSTALL_DOC_DIR}
|
|
)
|
|
|
|
|
|
install(DIRECTORY include/CGAL DESTINATION ${CGAL_INSTALL_INC_DIR} )
|
|
install(DIRECTORY "${CGAL_BINARY_DIR}/include/CGAL" DESTINATION ${CGAL_INSTALL_INC_DIR} )
|
|
|
|
install(DIRECTORY scripts/ DESTINATION ${CGAL_INSTALL_BIN_DIR} )
|
|
|
|
install(DIRECTORY cmake/modules/ DESTINATION ${CGAL_INSTALL_CMAKE_DIR} )
|
|
install(FILES cmake/modules/UseCGAL.cmake DESTINATION ${CGAL_INSTALL_CMAKE_DIR} )
|
|
|
|
if ( GMP_IN_AUXILIARY )
|
|
install(DIRECTORY auxiliary/gmp/include/ DESTINATION ${CGAL_INSTALL_INC_DIR} )
|
|
install(DIRECTORY auxiliary/gmp/lib/ DESTINATION ${CGAL_INSTALL_LIB_DIR} )
|
|
endif()
|
|
|
|
if ( TAUCS_IN_AUXILIARY )
|
|
install(DIRECTORY auxiliary/taucs/include/ DESTINATION ${CGAL_INSTALL_INC_DIR} )
|
|
install(DIRECTORY auxiliary/tacus/lib/ DESTINATION ${CGAL_INSTALL_LIB_DIR} )
|
|
endif()
|
|
|
|
if ( ZLIB_IN_AUXILIARY )
|
|
install(DIRECTORY auxiliary/zlib/include/ DESTINATION ${CGAL_INSTALL_INC_DIR} )
|
|
install(DIRECTORY auxiliary/zlib/lib/ DESTINATION ${CGAL_INSTALL_LIB_DIR} )
|
|
endif()
|
|
|
|
|
|
if ( SOURCE_INSTALL )
|
|
install(FILES ${CGAL_BINARY_DIR}/cmake/CGALConfig.cmake DESTINATION ${CGAL_INSTALL_ROOT_DIR} )
|
|
install(FILES CMakeLists.txt DESTINATION ${CGAL_INSTALL_ROOT_DIR} )
|
|
install(DIRECTORY auxiliary DESTINATION ${CGAL_INSTALL_ROOT_DIR} )
|
|
install(DIRECTORY src DESTINATION ${CGAL_INSTALL_ROOT_DIR} )
|
|
else()
|
|
install(FILES ${CGAL_BINARY_DIR}/cmake/CGALConfig.cmake DESTINATION ${CGAL_INSTALL_CMAKE_DIR} )
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
#--------------------------------------------------------------------------------------------------
|
|
#
|
|
# -= APPLICATIONS =-
|
|
#
|
|
#--------------------------------------------------------------------------------------------------
|
|
|
|
|
|
# This allows programs to locate CGALConfig.cmake
|
|
set(CGAL_DIR ${CGAL_BINARY_DIR} )
|
|
|
|
# This script does not configure demos and examples by default, but its does if requested.
|
|
optional_add_subdirectory( demo ON EXCLUDE_FROM_ALL )
|
|
optional_add_subdirectory( examples ON EXCLUDE_FROM_ALL )
|
|
|
|
|
|
#--------------------------------------------------------------------------------------------------
|
|
#
|
|
# -= CPack =-
|
|
#
|
|
#--------------------------------------------------------------------------------------------------
|
|
|
|
option( WITH_CPACK "Create package generation rules")
|
|
if( WITH_CPACK AND EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake" )
|
|
|
|
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "CGAL - Computational Geometry Algorithms Library")
|
|
set(CPACK_PACKAGE_VENDOR "CGAL Open Source Project")
|
|
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README")
|
|
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
|
|
set(CPACK_PACKAGE_VERSION_MAJOR "${CGAL_MAJOR_VERSION}")
|
|
set(CPACK_PACKAGE_VERSION_MINOR "${CGAL_MINOR_VERSION}")
|
|
set(CPACK_PACKAGE_VERSION_PATCH "${CGAL_BUILD_VERSION}")
|
|
set(CPACK_PACKAGE_INSTALL_DIRECTORY "CGAL ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
|
|
set(CPACK_SOURCE_PACKAGE_FILE_NAME "CGAL-${CGAL_VERSION}")
|
|
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
|
|
|
|
if(NOT DEFINED CPACK_SYSTEM_NAME)
|
|
set(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR})
|
|
endif()
|
|
|
|
if(${CPACK_SYSTEM_NAME} MATCHES Windows)
|
|
if(CMAKE_CL_64)
|
|
set(CPACK_SYSTEM_NAME win64-${CMAKE_SYSTEM_PROCESSOR})
|
|
else()
|
|
set(CPACK_SYSTEM_NAME win32-${CMAKE_SYSTEM_PROCESSOR})
|
|
endif()
|
|
endif()
|
|
|
|
if(NOT DEFINED CPACK_PACKAGE_FILE_NAME)
|
|
set(CPACK_PACKAGE_FILE_NAME "${CPACK_SOURCE_PACKAGE_FILE_NAME}-${CPACK_SYSTEM_NAME}")
|
|
endif()
|
|
|
|
set(CPACK_PACKAGE_EXECUTABLES "CGAL" "CGAL")
|
|
|
|
if(WIN32 AND NOT UNIX)
|
|
set(CPACK_GENERATOR "NSIS")
|
|
# There is a bug in NSI that does not handle full unix paths properly. Make
|
|
# sure there is at least one set of four (4) backlasshes.
|
|
#set(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}\\\\cgal_install.gif")
|
|
#set(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\CGAL.exe")
|
|
set(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} Computational Geometry Algorithms Library")
|
|
set(CPACK_NSIS_HELP_LINK "http:\\\\\\\\www.cgal.org")
|
|
set(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.cgal.com")
|
|
set(CPACK_NSIS_CONTACT "info@cgal.org")
|
|
set(CPACK_NSIS_MODifY_PATH ON)
|
|
else()
|
|
set(CPACK_STRIP_FILES "")
|
|
set(CPACK_SOURCE_STRIP_FILES "")
|
|
endif()
|
|
|
|
INCLUDE(CPack)
|
|
|
|
endif()
|
|
|