diff --git a/CMakeLists.txt b/CMakeLists.txt index 07a6c2e5..7dbeb471 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,11 @@ cmake_minimum_required( VERSION 3.6 ) -project( SFCGAL ) + +set( SFCGAL_VERSION_MAJOR 2 ) +set( SFCGAL_VERSION_MINOR 0 ) +set( SFCGAL_VERSION_PATCH 0 ) + +set( SFCGAL_VERSION "${SFCGAL_VERSION_MAJOR}.${SFCGAL_VERSION_MINOR}.${SFCGAL_VERSION_PATCH}" ) +project( SFCGAL VERSION ${SFCGAL_VERSION} ) set( CMAKE_DEBUG_POSTFIX "d" ) set(CMAKE_CXX_STANDARD 17) @@ -57,12 +63,6 @@ endif(NOT MSVC) #-- include finders and co set( CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules;${CMAKE_MODULE_PATH}" ) -set( SFCGAL_VERSION_MAJOR 2 ) -set( SFCGAL_VERSION_MINOR 0 ) -set( SFCGAL_VERSION_PATCH 0 ) - -set( SFCGAL_VERSION "${SFCGAL_VERSION_MAJOR}.${SFCGAL_VERSION_MINOR}.${SFCGAL_VERSION_PATCH}" ) - if (CMAKE_CXX_COMPILER MATCHES ".*clang") set(CMAKE_COMPILER_IS_CLANGXX 1) endif () @@ -266,3 +266,41 @@ install( PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/sfcgal-config DESTINATION bin ) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/sfcgal.pc.in ${CMAKE_CURRENT_BINARY_DIR}/sfcgal.pc @ONLY) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/sfcgal.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") + +include(GNUInstallDirs) +include(CMakePackageConfigHelpers) + +# Définir les chemins d'installation +set(SFCGAL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}") +set(SFCGAL_LIBRARY_DIR "${CMAKE_INSTALL_LIBDIR}") + +configure_package_config_file( + "${CMAKE_CURRENT_SOURCE_DIR}/SFCGALConfig.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/SFCGALConfig.cmake" + INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/SFCGAL" + PATH_VARS SFCGAL_INCLUDE_DIR SFCGAL_LIBRARY_DIR +) + +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/SFCGALConfigVersion.cmake" + VERSION ${PROJECT_VERSION} + COMPATIBILITY SameMajorVersion +) + +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/SFCGALConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/SFCGALConfigVersion.cmake" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/SFCGAL" +) + +install(TARGETS SFCGAL + EXPORT SFCGALTargets + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") + +install(EXPORT SFCGALTargets + FILE SFCGALTargets.cmake + NAMESPACE SFCGAL:: + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/SFCGAL") diff --git a/SFCGALConfig.cmake.in b/SFCGALConfig.cmake.in new file mode 100644 index 00000000..956ca801 --- /dev/null +++ b/SFCGALConfig.cmake.in @@ -0,0 +1,32 @@ +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) + +set_and_check(SFCGAL_INCLUDE_DIR "@PACKAGE_SFCGAL_INCLUDE_DIR@") +set_and_check(SFCGAL_LIBRARY_DIR "@PACKAGE_SFCGAL_LIBRARY_DIR@") + +if(NOT TARGET SFCGAL::SFCGAL) + add_library(SFCGAL::SFCGAL SHARED IMPORTED) + + if(WIN32) + set(SFCGAL_LIBRARY_NAME "SFCGAL.dll") + elseif(APPLE) + set(SFCGAL_LIBRARY_NAME "libSFCGAL.dylib") + else() + set(SFCGAL_LIBRARY_NAME "libSFCGAL.so") + endif() + + set_target_properties(SFCGAL::SFCGAL PROPERTIES + IMPORTED_LOCATION "${SFCGAL_LIBRARY_DIR}/${SFCGAL_LIBRARY_NAME}" + INTERFACE_INCLUDE_DIRECTORIES "${SFCGAL_INCLUDE_DIR}" + ) + + if(WIN32) + set_property(TARGET SFCGAL::SFCGAL APPEND PROPERTY + IMPORTED_IMPLIB "${SFCGAL_LIBRARY_DIR}/SFCGAL.lib" + ) + endif() + +endif() + +check_required_components(SFCGAL) diff --git a/SFCGALConfigVersion.cmake.in b/SFCGALConfigVersion.cmake.in new file mode 100644 index 00000000..5c95623b --- /dev/null +++ b/SFCGALConfigVersion.cmake.in @@ -0,0 +1,10 @@ +set(PACKAGE_VERSION "@SFCGAL_VERSION@") + +if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif()