From 265661ab5c32aee49988400bf7533cb35352c598 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Sat, 2 Nov 2019 17:57:32 +0100 Subject: [PATCH] Move dedicated install/uninstaller script inside cmake directory --- CMakeLists.txt | 71 +++----------------------------------------- cmake/CMakeLists.txt | 66 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 67 deletions(-) create mode 100644 cmake/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index ac3a6c15..37790c2c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,73 +9,6 @@ enable_testing() include_directories("${PROJECT_SOURCE_DIR}") add_subdirectory(glm) -################################## -# CMake install / uninstall script -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") - -include(GNUInstallDirs) -include(CMakePackageConfigHelpers) - -set(GLM_INSTALL_CONFIGDIR "${CMAKE_INSTALL_LIBDIR}/cmake/glm") -install(DIRECTORY glm DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) - -# CMake automatically adds an architecture compatibility check to make sure -# 32 and 64 bit code is not accidentally mixed. For a header-only library this -# is not required. The check can be disabled by temporarily unsetting -# CMAKE_SIZEOF_VOID_P. In CMake 3.14 and later this can be achieved more cleanly -# with write_basic_package_version_file(ARCH_INDEPENDENT). -# TODO: Use this once a newer CMake can be required. -set(GLM_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P}) -unset(CMAKE_SIZEOF_VOID_P) -write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/glmConfigVersion.cmake" VERSION ${GLM_VERSION} COMPATIBILITY AnyNewerVersion) -set(CMAKE_SIZEOF_VOID_P ${GLM_SIZEOF_VOID_P}) - -# build tree package config -configure_file(cmake/glmBuildConfig.cmake.in glmConfig.cmake @ONLY) - -# install tree package config -configure_package_config_file( - cmake/glmConfig.cmake.in - ${GLM_INSTALL_CONFIGDIR}/glmConfig.cmake - INSTALL_DESTINATION ${GLM_INSTALL_CONFIGDIR} - PATH_VARS CMAKE_INSTALL_INCLUDEDIR - NO_CHECK_REQUIRED_COMPONENTS_MACRO) - -install(FILES - "${CMAKE_CURRENT_BINARY_DIR}/${GLM_INSTALL_CONFIGDIR}/glmConfig.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/glmConfigVersion.cmake" - DESTINATION ${GLM_INSTALL_CONFIGDIR}) - -add_library(glm INTERFACE) -target_include_directories(glm INTERFACE - $ - $) -install(TARGETS glm EXPORT glmTargets) - -export(EXPORT glmTargets FILE "${CMAKE_CURRENT_BINARY_DIR}/glmTargets.cmake") - -install(EXPORT glmTargets FILE glmTargets.cmake DESTINATION ${GLM_INSTALL_CONFIGDIR}) - -# build pkg-config file -configure_file("./cmake/glm.pc.in" "glm.pc" @ONLY) - -# install pkg-config file -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/glm.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") - -export(PACKAGE glm) - -if(NOT TARGET uninstall) - configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake - IMMEDIATE @ONLY) - - add_custom_target(uninstall - COMMAND ${CMAKE_COMMAND} -P - ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) -endif() - - ################################## # CMake test @@ -84,3 +17,7 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) add_subdirectory(test) endif(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) + +################################## +# CMake install / uninstall script +add_subdirectory(cmake) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt new file mode 100644 index 00000000..ec007bed --- /dev/null +++ b/cmake/CMakeLists.txt @@ -0,0 +1,66 @@ +################################## +# CMake install / uninstall script +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") + +include(GNUInstallDirs) +include(CMakePackageConfigHelpers) + +set(GLM_INSTALL_CONFIGDIR "${CMAKE_INSTALL_LIBDIR}/cmake/glm") +install(DIRECTORY glm DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + +# CMake automatically adds an architecture compatibility check to make sure +# 32 and 64 bit code is not accidentally mixed. For a header-only library this +# is not required. The check can be disabled by temporarily unsetting +# CMAKE_SIZEOF_VOID_P. In CMake 3.14 and later this can be achieved more cleanly +# with write_basic_package_version_file(ARCH_INDEPENDENT). +# TODO: Use this once a newer CMake can be required. +set(GLM_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P}) +unset(CMAKE_SIZEOF_VOID_P) +write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/glmConfigVersion.cmake" VERSION ${GLM_VERSION} COMPATIBILITY AnyNewerVersion) +set(CMAKE_SIZEOF_VOID_P ${GLM_SIZEOF_VOID_P}) + +# build tree package config +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/glmBuildConfig.cmake.in glmConfig.cmake @ONLY) + +# install tree package config +configure_package_config_file( + ${CMAKE_CURRENT_SOURCE_DIR}/glmConfig.cmake.in + ${GLM_INSTALL_CONFIGDIR}/glmConfig.cmake + INSTALL_DESTINATION ${GLM_INSTALL_CONFIGDIR} + PATH_VARS CMAKE_INSTALL_INCLUDEDIR + NO_CHECK_REQUIRED_COMPONENTS_MACRO) + +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/${GLM_INSTALL_CONFIGDIR}/glmConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/glmConfigVersion.cmake" + DESTINATION ${GLM_INSTALL_CONFIGDIR}) + +add_library(glm INTERFACE) +target_include_directories(glm INTERFACE + $ + $) +install(TARGETS glm EXPORT glmTargets) + +export(EXPORT glmTargets FILE "${CMAKE_CURRENT_BINARY_DIR}/glmTargets.cmake") + +install(EXPORT glmTargets FILE glmTargets.cmake DESTINATION ${GLM_INSTALL_CONFIGDIR}) + +# build pkg-config file +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/glm.pc.in" "glm.pc" @ONLY) + +# install pkg-config file +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/glm.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") + +export(PACKAGE glm) + +if(NOT TARGET uninstall) + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake + IMMEDIATE @ONLY) + + add_custom_target(uninstall + COMMAND ${CMAKE_COMMAND} -P + ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) +endif() +