Merge pull request #1054 from kiroma/master
Create an install and package targets in cmake tree #1054
This commit is contained in:
commit
9203edd741
@ -74,10 +74,11 @@ before_build:
|
|||||||
$env:generator="$env:generator Win64"
|
$env:generator="$env:generator Win64"
|
||||||
}
|
}
|
||||||
echo generator="$env:generator"
|
echo generator="$env:generator"
|
||||||
cmake .. -G "$env:generator" -DGLM_QUIET=ON -DGLM_TEST_ENABLE=ON "$env:GLM_ARGUMENTS"
|
cmake .. -G "$env:generator" -DCMAKE_INSTALL_PREFIX="$env:APPVEYOR_BUILD_FOLDER/install" -DGLM_QUIET=ON -DGLM_TEST_ENABLE=ON "$env:GLM_ARGUMENTS"
|
||||||
|
|
||||||
build_script:
|
build_script:
|
||||||
- cmake --build . --parallel --config %CONFIGURATION% -- /m /v:minimal
|
- cmake --build . --parallel --config %CONFIGURATION% -- /m /v:minimal
|
||||||
|
- cmake --build . --target install --parallel --config %CONFIGURATION% -- /m /v:minimal
|
||||||
|
|
||||||
test_script:
|
test_script:
|
||||||
- ctest --parallel 4 --verbose -C %CONFIGURATION%
|
- ctest --parallel 4 --verbose -C %CONFIGURATION%
|
||||||
@ -85,7 +86,7 @@ test_script:
|
|||||||
- ps: |
|
- ps: |
|
||||||
mkdir build_test_cmake
|
mkdir build_test_cmake
|
||||||
cd build_test_cmake
|
cd build_test_cmake
|
||||||
cmake ..\test\cmake\ -G "$env:generator" -Dglm_DIR="$env:APPVEYOR_BUILD_FOLDER/cmake/glm/"
|
cmake ..\test\cmake\ -G "$env:generator" -DCMAKE_PREFIX_PATH="$env:APPVEYOR_BUILD_FOLDER/install"
|
||||||
- cmake --build . --parallel --config %CONFIGURATION% -- /m /v:minimal
|
- cmake --build . --parallel --config %CONFIGURATION% -- /m /v:minimal
|
||||||
|
|
||||||
deploy: off
|
deploy: off
|
||||||
|
@ -415,13 +415,14 @@ before_script:
|
|||||||
script:
|
script:
|
||||||
- mkdir ./build
|
- mkdir ./build
|
||||||
- cd ./build
|
- cd ./build
|
||||||
- cmake -DCMAKE_CXX_COMPILER=$COMPILER ${CMAKE_BUILD_ENV} ..
|
- cmake -DCMAKE_INSTALL_PREFIX=$TRAVIS_BUILD_DIR/install -DCMAKE_CXX_COMPILER=$COMPILER ${CMAKE_BUILD_ENV} ..
|
||||||
- cmake --build . ${CMAKE_ENV}
|
- cmake --build . ${CMAKE_ENV}
|
||||||
- ctest ${CTEST_ENV}
|
- ctest ${CTEST_ENV}
|
||||||
|
- cmake --build . --target install ${CMAKE_ENV}
|
||||||
- cd $TRAVIS_BUILD_DIR
|
- cd $TRAVIS_BUILD_DIR
|
||||||
- mkdir ./build_test_cmake
|
- mkdir ./build_test_cmake
|
||||||
- cd ./build_test_cmake
|
- cd ./build_test_cmake
|
||||||
- cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR/cmake/glm/
|
- cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -DCMAKE_PREFIX_PATH=$TRAVIS_BUILD_DIR/install
|
||||||
- cmake --build .
|
- cmake --build .
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,13 +16,30 @@ set(GLM_VERSION ${GLM_VERSION_MAJOR}.${GLM_VERSION_MINOR}.${GLM_VERSION_PATCH}.$
|
|||||||
project(glm VERSION ${GLM_VERSION} LANGUAGES CXX)
|
project(glm VERSION ${GLM_VERSION} LANGUAGES CXX)
|
||||||
message(STATUS "GLM: Version " ${GLM_VERSION})
|
message(STATUS "GLM: Version " ${GLM_VERSION})
|
||||||
|
|
||||||
enable_testing()
|
|
||||||
|
|
||||||
add_subdirectory(glm)
|
add_subdirectory(glm)
|
||||||
add_library(glm::glm ALIAS glm)
|
add_library(glm::glm ALIAS glm)
|
||||||
|
|
||||||
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
|
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
|
||||||
|
include(CPack)
|
||||||
|
install(DIRECTORY glm DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} PATTERN "CMakeLists.txt" EXCLUDE)
|
||||||
|
install(EXPORT glm FILE glmConfig.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/glm NAMESPACE glm::)
|
||||||
|
include(CMakePackageConfigHelpers)
|
||||||
|
write_basic_package_version_file("glmConfigVersion.cmake" COMPATIBILITY AnyNewerVersion)
|
||||||
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/glmConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/glm)
|
||||||
|
|
||||||
|
include(CTest)
|
||||||
|
if(BUILD_TESTING)
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
|
endif()
|
||||||
|
|
||||||
endif(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
|
endif(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
|
||||||
|
if (NOT TARGET uninstall)
|
||||||
|
configure_file(cmake/cmake_uninstall.cmake.in
|
||||||
|
cmake_uninstall.cmake IMMEDIATE @ONLY)
|
||||||
|
|
||||||
|
add_custom_target(uninstall
|
||||||
|
"${CMAKE_COMMAND}" -P
|
||||||
|
"${CMAKE_BINARY_DIR}/cmake_uninstall.cmake")
|
||||||
|
endif()
|
||||||
|
21
cmake/cmake_uninstall.cmake.in
Normal file
21
cmake/cmake_uninstall.cmake.in
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
|
||||||
|
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
file(READ "@CMAKE_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()
|
||||||
|
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
|
||||||
|
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
@ -1,11 +0,0 @@
|
|||||||
if(${PACKAGE_FIND_VERSION_MAJOR} EQUAL 0)
|
|
||||||
if (${PACKAGE_FIND_VERSION} VERSION_LESS ${GLM_VERSION})
|
|
||||||
set(PACKAGE_VERSION_COMPATIBLE 1)
|
|
||||||
endif()
|
|
||||||
if(${PACKAGE_FIND_VERSION} VERSION_EQUAL ${GLM_VERSION})
|
|
||||||
set(PACKAGE_VERSION_EXACT 1)
|
|
||||||
endif()
|
|
||||||
else()
|
|
||||||
set(PACKAGE_VERSION_UNSUITABLE 1)
|
|
||||||
endif()
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
|
|
||||||
cmake_policy(VERSION 3.2)
|
|
||||||
|
|
||||||
set(GLM_VERSION 0.9.9)
|
|
||||||
|
|
||||||
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
|
||||||
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
|
|
||||||
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
|
|
||||||
if (_IMPORT_PREFIX STREQUAL "/")
|
|
||||||
set(_IMPORT_PREFIX "")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Set the old GLM_INCLUDE_DIRS variable for backwards compatibility
|
|
||||||
set(GLM_INCLUDE_DIRS ${_IMPORT_PREFIX})
|
|
||||||
|
|
||||||
add_library(glm::glm INTERFACE IMPORTED)
|
|
||||||
set_target_properties(glm::glm PROPERTIES
|
|
||||||
INTERFACE_INCLUDE_DIRECTORIES ${GLM_INCLUDE_DIRS})
|
|
||||||
|
|
||||||
mark_as_advanced(glm_DIR)
|
|
||||||
set(_IMPORT_PREFIX)
|
|
||||||
|
|
@ -43,7 +43,15 @@ source_group("SIMD Files" FILES ${SIMD_INLINE})
|
|||||||
source_group("SIMD Files" FILES ${SIMD_HEADER})
|
source_group("SIMD Files" FILES ${SIMD_HEADER})
|
||||||
|
|
||||||
add_library(glm INTERFACE)
|
add_library(glm INTERFACE)
|
||||||
target_include_directories(glm INTERFACE ../)
|
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
|
target_include_directories(glm INTERFACE
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>
|
||||||
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||||
|
)
|
||||||
|
|
||||||
|
install(TARGETS glm EXPORT glm)
|
||||||
|
|
||||||
if(BUILD_STATIC_LIBS)
|
if(BUILD_STATIC_LIBS)
|
||||||
add_library(glm_static STATIC ${ROOT_TEXT} ${ROOT_MD} ${ROOT_NAT}
|
add_library(glm_static STATIC ${ROOT_TEXT} ${ROOT_MD} ${ROOT_NAT}
|
||||||
|
15
manual.md
15
manual.md
@ -277,18 +277,27 @@ GLM does not depend on external libraries or headers such as `<GL/gl.h>`, [`<GL/
|
|||||||
|
|
||||||
### <a name="section1_5"></a> 1.5. Finding GLM with CMake
|
### <a name="section1_5"></a> 1.5. Finding GLM with CMake
|
||||||
|
|
||||||
GLM provides the CMake package configuration files `glmConfig.cmake` and `glmConfig-version.cmake`.
|
When installed, GLM provides the CMake package configuration files `glmConfig.cmake` and `glmConfigVersion.cmake`.
|
||||||
|
|
||||||
To use these configurations files, you may need to set the `glm_DIR` variable to the directory containing the configuration files `<path to glm root>/cmake/glm/`.
|
To use these configurations files, you may need to set the `glm_DIR` variable to the directory containing the configuration files `<installation prefix>/lib/cmake/glm/`.
|
||||||
|
|
||||||
Use the `find_package` CMake command to load the configurations into your project. Lastly, either link your executable against the `glm::glm` target or add `${GLM_INCLUDE_DIRS}` to your target's include directories:
|
Use the `find_package` CMake command to load the configurations into your project. Lastly, either link your executable against the `glm::glm` target or add `${GLM_INCLUDE_DIRS}` to your target's include directories:
|
||||||
|
|
||||||
```cmake
|
```cmake
|
||||||
set(glm_DIR <path to glm root>/cmake/glm) # if necessary
|
set(glm_DIR <installation prefix>/lib/cmake/glm) # if necessary
|
||||||
find_package(glm REQUIRED)
|
find_package(glm REQUIRED)
|
||||||
target_link_libraries(<your executable> glm::glm)
|
target_link_libraries(<your executable> glm::glm)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
To use GLM as a submodule in a project instead, use `add_subdirectory` to expose the same target, or add the directory to your target's
|
||||||
|
|
||||||
|
```cmake
|
||||||
|
add_subdirectory(glm)
|
||||||
|
target_link_libraries(<your executable> glm::glm)
|
||||||
|
# or
|
||||||
|
target_include_directories(<your executable> glm)
|
||||||
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
<div style="page-break-after: always;"> </div>
|
<div style="page-break-after: always;"> </div>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user