blob: a58d27d2c400abbd93123edc3b5c6b8410dffa06 [file] [log] [blame] [edit]
From 849c82ca87b7d7cfe4ffef05bb60a304f9b77249 Mon Sep 17 00:00:00 2001
From: Christophe Riccio <christophe.riccio@unity3d.com>
Date: Sat, 2 Nov 2019 17:50:26 +0100
Subject: [PATCH 1/2] Bring back CMake installer scripts
---
CMakeLists.txt | 73 ++++++++-
cmake/cmake_uninstall.cmake.in | 26 +++
cmake/glm.pc.in | 7 +
cmake/glmBuildConfig.cmake.in | 6 +
cmake/glmConfig.cmake.in | 9 +
glm/CMakeLists.txt | 7 +-
6 files changed, 125 insertions(+), 8 deletions(-)
create mode 100644 cmake/cmake_uninstall.cmake.in
create mode 100644 cmake/glm.pc.in
create mode 100644 cmake/glmBuildConfig.cmake.in
create mode 100644 cmake/glmConfig.cmake.in
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 843e75465..ac3a6c157 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,10 +3,81 @@ cmake_policy(VERSION 3.2)
set(GLM_VERSION "0.9.9")
project(glm VERSION ${GLM_VERSION} LANGUAGES CXX)
+
enable_testing()
+include_directories("${PROJECT_SOURCE_DIR}")
add_subdirectory(glm)
-add_library(glm::glm ALIAS 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_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
+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
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
diff --git a/cmake/cmake_uninstall.cmake.in b/cmake/cmake_uninstall.cmake.in
new file mode 100644
index 000000000..d00a51665
--- /dev/null
+++ b/cmake/cmake_uninstall.cmake.in
@@ -0,0 +1,26 @@
+if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+ message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+
+if (NOT DEFINED CMAKE_INSTALL_PREFIX)
+ set (CMAKE_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@")
+endif ()
+ message(${CMAKE_INSTALL_PREFIX})
+
+file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
+string(REGEX REPLACE "\n" ";" files "${files}")
+foreach(file ${files})
+ message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
+ if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+ exec_program(
+ "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
+ OUTPUT_VARIABLE rm_out
+ RETURN_VALUE rm_retval
+ )
+ if(NOT "${rm_retval}" STREQUAL 0)
+ message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
+ endif(NOT "${rm_retval}" STREQUAL 0)
+ else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+ message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
+ endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+endforeach(file)
diff --git a/cmake/glm.pc.in b/cmake/glm.pc.in
new file mode 100644
index 000000000..fc5c7bb7f
--- /dev/null
+++ b/cmake/glm.pc.in
@@ -0,0 +1,7 @@
+prefix=@CMAKE_INSTALL_PREFIX@
+includedir=${prefix}/include
+
+Name: GLM
+Description: OpenGL Mathematics
+Version: @GLM_VERSION@
+Cflags: -I${includedir}
diff --git a/cmake/glmBuildConfig.cmake.in b/cmake/glmBuildConfig.cmake.in
new file mode 100644
index 000000000..1258dea14
--- /dev/null
+++ b/cmake/glmBuildConfig.cmake.in
@@ -0,0 +1,6 @@
+set(GLM_VERSION "@GLM_VERSION@")
+set(GLM_INCLUDE_DIRS "@CMAKE_CURRENT_SOURCE_DIR@")
+
+if (NOT CMAKE_VERSION VERSION_LESS "3.0")
+ include("${CMAKE_CURRENT_LIST_DIR}/glmTargets.cmake")
+endif()
diff --git a/cmake/glmConfig.cmake.in b/cmake/glmConfig.cmake.in
new file mode 100644
index 000000000..37d5ad811
--- /dev/null
+++ b/cmake/glmConfig.cmake.in
@@ -0,0 +1,9 @@
+set(GLM_VERSION "@GLM_VERSION@")
+
+@PACKAGE_INIT@
+
+set_and_check(GLM_INCLUDE_DIRS "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@")
+
+if (NOT CMAKE_VERSION VERSION_LESS "3.0")
+ include("${CMAKE_CURRENT_LIST_DIR}/glmTargets.cmake")
+endif()
diff --git a/glm/CMakeLists.txt b/glm/CMakeLists.txt
index 4ff51c818..98759e794 100644
--- a/glm/CMakeLists.txt
+++ b/glm/CMakeLists.txt
@@ -42,8 +42,7 @@ source_group("SIMD Files" FILES ${SIMD_SOURCE})
source_group("SIMD Files" FILES ${SIMD_INLINE})
source_group("SIMD Files" FILES ${SIMD_HEADER})
-add_library(glm INTERFACE)
-target_include_directories(glm INTERFACE ../)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
if(BUILD_STATIC_LIBS)
add_library(glm_static STATIC ${ROOT_TEXT} ${ROOT_MD} ${ROOT_NAT}
@@ -53,8 +52,6 @@ add_library(glm_static STATIC ${ROOT_TEXT} ${ROOT_MD} ${ROOT_NAT}
${GTC_SOURCE} ${GTC_INLINE} ${GTC_HEADER}
${GTX_SOURCE} ${GTX_INLINE} ${GTX_HEADER}
${SIMD_SOURCE} ${SIMD_INLINE} ${SIMD_HEADER})
- target_link_libraries(glm_static PUBLIC glm)
- add_library(glm::glm_static ALIAS glm_static)
endif()
if(BUILD_SHARED_LIBS)
@@ -65,6 +62,4 @@ add_library(glm_shared SHARED ${ROOT_TEXT} ${ROOT_MD} ${ROOT_NAT}
${GTC_SOURCE} ${GTC_INLINE} ${GTC_HEADER}
${GTX_SOURCE} ${GTX_INLINE} ${GTX_HEADER}
${SIMD_SOURCE} ${SIMD_INLINE} ${SIMD_HEADER})
- target_link_libraries(glm_shared PUBLIC glm)
- add_library(glm::glm_shared ALIAS glm_shared)
endif()
From 265661ab5c32aee49988400bf7533cb35352c598 Mon Sep 17 00:00:00 2001
From: Christophe Riccio <christophe.riccio@unity3d.com>
Date: Sat, 2 Nov 2019 17:57:32 +0100
Subject: [PATCH 2/2] 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 ac3a6c157..37790c2cd 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_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
- $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
-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 000000000..ec007bed3
--- /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 ${PROJECT_SOURCE_DIR}/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_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
+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()
+