From a24dd7dd1cfa839adf4d73b2e1515bd375c94753 Mon Sep 17 00:00:00 2001 From: "Thiago M. de C. Marques" Date: Thu, 8 Sep 2016 21:14:20 -0300 Subject: [PATCH 1/3] Adds CMake package version file generation This allows clients to specify a minimum CGAL version in their CMake list files. Eg.: find_package(CGAL 4.9) More info: https://cmake.org/cmake/help/v3.6/manual/cmake-packages.7.html#package-version-file --- Installation/CMakeLists.txt | 5 ++++- Installation/cmake/modules/CGAL_Macros.cmake | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Installation/CMakeLists.txt b/Installation/CMakeLists.txt index 0058828a7e5..2856cd258c9 100644 --- a/Installation/CMakeLists.txt +++ b/Installation/CMakeLists.txt @@ -891,7 +891,10 @@ if ( ZLIB_IN_AUXILIARY ) endif() -install(FILES ${CMAKE_BINARY_DIR}/config/CGALConfig.cmake DESTINATION ${CGAL_INSTALL_CMAKE_DIR} ) +install(FILES + ${CMAKE_BINARY_DIR}/config/CGALConfig.cmake + ${CMAKE_BINARY_DIR}/config/CGALConfigVersion.cmake + DESTINATION ${CGAL_INSTALL_CMAKE_DIR} ) if(CGAL_INSTALL_MAN_DIR) install(FILES auxiliary/cgal_create_cmake_script.1 DESTINATION ${CGAL_INSTALL_MAN_DIR} ) diff --git a/Installation/cmake/modules/CGAL_Macros.cmake b/Installation/cmake/modules/CGAL_Macros.cmake index 43c7e5be05f..ba946fbb6f3 100644 --- a/Installation/cmake/modules/CGAL_Macros.cmake +++ b/Installation/cmake/modules/CGAL_Macros.cmake @@ -411,11 +411,20 @@ if( NOT CGAL_MACROS_FILE_INCLUDED ) macro( create_CGALconfig_files ) + include(CMakePackageConfigHelpers) + # CGALConfig.cmake is platform specific so it is generated and stored in the binary folder. configure_file("${CGAL_MODULES_DIR}/CGALConfig_binary.cmake.in" "${CMAKE_BINARY_DIR}/CGALConfig.cmake" @ONLY) + write_basic_package_version_file("${CMAKE_BINARY_DIR}/CGALConfigVersion.cmake" + VERSION "${CGAL_MAJOR_VERSION}.${CGAL_MINOR_VERSION}.${CGAL_BUILD_VERSION}" + COMPATIBILITY AnyNewerVersion) # There is also a version of CGALConfig.cmake that is prepared in case CGAL in installed in CMAKE_INSTALL_PREFIX. configure_file("${CGAL_MODULES_DIR}/CGALConfig_install.cmake.in" "${CMAKE_BINARY_DIR}/config/CGALConfig.cmake" @ONLY) + configure_file( + "${CMAKE_BINARY_DIR}/CGALConfigVersion.cmake" + "${CMAKE_BINARY_DIR}/config/CGALConfigVersion.cmake" + COPYONLY) #write prefix exceptions file( APPEND ${CMAKE_BINARY_DIR}/CGALConfig.cmake "${SPECIAL_PREFIXES}\n") From 9c338ad61aff394d4169bdd2759e45c069704b84 Mon Sep 17 00:00:00 2001 From: "Thiago M. de C. Marques" Date: Fri, 9 Sep 2016 08:32:21 -0300 Subject: [PATCH 2/3] Removes the copy of the package version file to the build config folder See: https://github.com/CGAL/cgal/pull/1443#discussion-diff-78147435 --- Installation/CMakeLists.txt | 2 +- Installation/cmake/modules/CGAL_Macros.cmake | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/Installation/CMakeLists.txt b/Installation/CMakeLists.txt index 2856cd258c9..13c622bc697 100644 --- a/Installation/CMakeLists.txt +++ b/Installation/CMakeLists.txt @@ -892,8 +892,8 @@ endif() install(FILES + ${CMAKE_BINARY_DIR}/CGALConfigVersion.cmake ${CMAKE_BINARY_DIR}/config/CGALConfig.cmake - ${CMAKE_BINARY_DIR}/config/CGALConfigVersion.cmake DESTINATION ${CGAL_INSTALL_CMAKE_DIR} ) if(CGAL_INSTALL_MAN_DIR) diff --git a/Installation/cmake/modules/CGAL_Macros.cmake b/Installation/cmake/modules/CGAL_Macros.cmake index ba946fbb6f3..60dea84a5cd 100644 --- a/Installation/cmake/modules/CGAL_Macros.cmake +++ b/Installation/cmake/modules/CGAL_Macros.cmake @@ -421,10 +421,6 @@ if( NOT CGAL_MACROS_FILE_INCLUDED ) # There is also a version of CGALConfig.cmake that is prepared in case CGAL in installed in CMAKE_INSTALL_PREFIX. configure_file("${CGAL_MODULES_DIR}/CGALConfig_install.cmake.in" "${CMAKE_BINARY_DIR}/config/CGALConfig.cmake" @ONLY) - configure_file( - "${CMAKE_BINARY_DIR}/CGALConfigVersion.cmake" - "${CMAKE_BINARY_DIR}/config/CGALConfigVersion.cmake" - COPYONLY) #write prefix exceptions file( APPEND ${CMAKE_BINARY_DIR}/CGALConfig.cmake "${SPECIAL_PREFIXES}\n") From 6cfa204b297d3a32a8dcb5a139e3a50c10a6372d Mon Sep 17 00:00:00 2001 From: "Thiago M. de C. Marques" Date: Fri, 9 Sep 2016 08:32:30 -0300 Subject: [PATCH 3/3] Fixes the version compatibility to `SameMajorVersion` See: https://github.com/CGAL/cgal/pull/1443#discussion-diff-78162752 --- Installation/cmake/modules/CGAL_Macros.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Installation/cmake/modules/CGAL_Macros.cmake b/Installation/cmake/modules/CGAL_Macros.cmake index 60dea84a5cd..333ea39a94b 100644 --- a/Installation/cmake/modules/CGAL_Macros.cmake +++ b/Installation/cmake/modules/CGAL_Macros.cmake @@ -417,7 +417,7 @@ if( NOT CGAL_MACROS_FILE_INCLUDED ) configure_file("${CGAL_MODULES_DIR}/CGALConfig_binary.cmake.in" "${CMAKE_BINARY_DIR}/CGALConfig.cmake" @ONLY) write_basic_package_version_file("${CMAKE_BINARY_DIR}/CGALConfigVersion.cmake" VERSION "${CGAL_MAJOR_VERSION}.${CGAL_MINOR_VERSION}.${CGAL_BUILD_VERSION}" - COMPATIBILITY AnyNewerVersion) + COMPATIBILITY SameMajorVersion) # There is also a version of CGALConfig.cmake that is prepared in case CGAL in installed in CMAKE_INSTALL_PREFIX. configure_file("${CGAL_MODULES_DIR}/CGALConfig_install.cmake.in" "${CMAKE_BINARY_DIR}/config/CGALConfig.cmake" @ONLY)