Export build tree package

This commit is contained in:
Zbigniew Mandziejewicz 2015-04-09 11:20:58 +08:00
parent 62a7daddcf
commit 29940ee443
2 changed files with 29 additions and 10 deletions

View File

@ -144,9 +144,8 @@ include_directories("${PROJECT_SOURCE_DIR}/test/external")
add_subdirectory(glm)
add_subdirectory(test)
set(GLM_INSTALL_CONFIG_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/glm")
set(GLM_INCLUDE_DIRS ${CMAKE_INSTALL_FULL_INCLUDEDIR})
install(DIRECTORY glm DESTINATION ${GLM_INCLUDE_DIRS})
set(GLM_INSTALL_CONFIGDIR "${CMAKE_INSTALL_LIBDIR}/cmake/glm")
install(DIRECTORY glm DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
@ -155,23 +154,36 @@ write_basic_package_version_file(
COMPATIBILITY AnyNewerVersion
)
configure_file(cmake/glmConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/glmConfig.cmake"
@ONLY
# build tree package config
configure_package_config_file(
cmake/glmConfig.cmake.in
glmConfig.cmake
INSTALL_DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
PATH_VARS CMAKE_INSTALL_INCLUDEDIR
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
# 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}/glmConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/glmVersion.cmake"
DESTINATION ${GLM_INSTALL_CONFIG_DIR}
DESTINATION ${GLM_INSTALL_CONFIGDIR}
)
if (NOT CMAKE_VERSION VERSION_LESS "2.8.12")
add_library(glm INTERFACE)
target_include_directories(glm INTERFACE
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
)
install(TARGETS glm EXPORT glmTargets)
@ -179,8 +191,11 @@ if (NOT CMAKE_VERSION VERSION_LESS "2.8.12")
EXPORT glmTargets
FILE "${CMAKE_CURRENT_BINARY_DIR}/glmTargets.cmake"
)
install(
EXPORT glmTargets FILE glmTargets.cmake
DESTINATION ${GLM_INSTALL_CONFIG_DIR}
DESTINATION ${GLM_INSTALL_CONFIGDIR}
)
endif()
export(PACKAGE glm)

View File

@ -1,4 +1,8 @@
set_and_check(GLM_INCLUDE_DIRS "@GLM_INCLUDE_DIRS@")
set(GLM_VERSION "@GLM_VERSION@")
@PACKAGE_INIT@
set_and_check(GLM_INCLUDE_DIRS "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@")
if (NOT CMAKE_VERSION VERSION_LESS "2.8.12")
include("${CMAKE_CURRENT_LIST_DIR}/glmTargets.cmake")