Skip to content

Commit

Permalink
Export build tree package
Browse files Browse the repository at this point in the history
  • Loading branch information
shaxbee committed Apr 9, 2015
1 parent 62a7dad commit 29940ee
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
33 changes: 24 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -155,32 +154,48 @@ 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)

export(
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)
6 changes: 5 additions & 1 deletion cmake/glmConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -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")
Expand Down

0 comments on commit 29940ee

Please sign in to comment.