Merge pull request #586 from ranjak/master

CMake: add the option GLM_INSTALL_ENABLE to control installation. #586
This commit is contained in:
Christophe 2016-12-14 17:49:36 +01:00 committed by GitHub
commit b09fc9cce0

View File

@ -21,11 +21,13 @@ if(GLM_STATIC_LIBRARY_ENABLE)
message(STATUS "GLM is a header only library, no need to build it. Set the option GLM_STATIC_LIBRARY_ENABLE with ON to build an optional static library") message(STATUS "GLM is a header only library, no need to build it. Set the option GLM_STATIC_LIBRARY_ENABLE with ON to build an optional static library")
endif() endif()
option(GLM_DYNAMIC_LIBRARY_ENABLE "GLM static library" OFF) option(GLM_DYNAMIC_LIBRARY_ENABLE "GLM dynamic library" OFF)
if(GLM_DYNAMIC_LIBRARY_ENABLE) if(GLM_DYNAMIC_LIBRARY_ENABLE)
message(STATUS "GLM is a header only library, no need to build it. Set the option GLM_DYNAMIC_LIBRARY_ENABLE with ON to build an optional dynamic library") message(STATUS "GLM is a header only library, no need to build it. Set the option GLM_DYNAMIC_LIBRARY_ENABLE with ON to build an optional dynamic library")
endif() endif()
option(GLM_INSTALL_ENABLE "GLM install" ON)
option(GLM_TEST_ENABLE "GLM test" OFF) option(GLM_TEST_ENABLE "GLM test" OFF)
if(NOT GLM_TEST_ENABLE) if(NOT GLM_TEST_ENABLE)
message(STATUS "GLM is a header only library, no need to build it. Set the option GLM_TEST_ENABLE with ON to build and run the test bench") message(STATUS "GLM is a header only library, no need to build it. Set the option GLM_TEST_ENABLE with ON to build and run the test bench")
@ -166,7 +168,9 @@ add_subdirectory(glm)
add_subdirectory(test) add_subdirectory(test)
set(GLM_INSTALL_CONFIGDIR "${CMAKE_INSTALL_LIBDIR}/cmake/glm") set(GLM_INSTALL_CONFIGDIR "${CMAKE_INSTALL_LIBDIR}/cmake/glm")
install(DIRECTORY glm DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) if (GLM_INSTALL_ENABLE)
install(DIRECTORY glm DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
endif()
write_basic_package_version_file( write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/glmConfigVersion.cmake" "${CMAKE_CURRENT_BINARY_DIR}/glmConfigVersion.cmake"
@ -190,12 +194,14 @@ configure_package_config_file(
NO_CHECK_REQUIRED_COMPONENTS_MACRO NO_CHECK_REQUIRED_COMPONENTS_MACRO
) )
install( if (GLM_INSTALL_ENABLE)
install(
FILES FILES
"${CMAKE_CURRENT_BINARY_DIR}/${GLM_INSTALL_CONFIGDIR}/glmConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/${GLM_INSTALL_CONFIGDIR}/glmConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/glmConfigVersion.cmake" "${CMAKE_CURRENT_BINARY_DIR}/glmConfigVersion.cmake"
DESTINATION ${GLM_INSTALL_CONFIGDIR} DESTINATION ${GLM_INSTALL_CONFIGDIR}
) )
endif()
if (NOT CMAKE_VERSION VERSION_LESS "3.0") if (NOT CMAKE_VERSION VERSION_LESS "3.0")
add_library(glm INTERFACE) add_library(glm INTERFACE)
@ -210,10 +216,12 @@ if (NOT CMAKE_VERSION VERSION_LESS "3.0")
FILE "${CMAKE_CURRENT_BINARY_DIR}/glmTargets.cmake" FILE "${CMAKE_CURRENT_BINARY_DIR}/glmTargets.cmake"
) )
if (GLM_INSTALL_ENABLE)
install( install(
EXPORT glmTargets FILE glmTargets.cmake EXPORT glmTargets FILE glmTargets.cmake
DESTINATION ${GLM_INSTALL_CONFIGDIR} DESTINATION ${GLM_INSTALL_CONFIGDIR}
) )
endif()
endif() endif()
# build pkg-config file # build pkg-config file
@ -224,9 +232,11 @@ configure_file(
) )
# install pkg-config file # install pkg-config file
install( if (GLM_INSTALL_ENABLE)
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/glm.pc" FILES "${CMAKE_CURRENT_BINARY_DIR}/glm.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
) )
endif()
export(PACKAGE glm) export(PACKAGE glm)