mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
Make library importable by CMake using find_package
This commit is contained in:
parent
5778149583
commit
d452c3b061
@ -5,6 +5,9 @@ project(GSL CXX)
|
|||||||
include(ExternalProject)
|
include(ExternalProject)
|
||||||
find_package(Git)
|
find_package(Git)
|
||||||
|
|
||||||
|
# Use GNUInstallDirs to provide the right locations on all platforms
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
# creates a library GSL which is an interface (header files only)
|
# creates a library GSL which is an interface (header files only)
|
||||||
add_library(GSL INTERFACE)
|
add_library(GSL INTERFACE)
|
||||||
|
|
||||||
@ -55,6 +58,7 @@ target_include_directories(GSL INTERFACE
|
|||||||
$<BUILD_INTERFACE:
|
$<BUILD_INTERFACE:
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||||
>
|
>
|
||||||
|
$<INSTALL_INTERFACE:include>
|
||||||
)
|
)
|
||||||
|
|
||||||
if ((CMAKE_VERSION GREATER 3.7.9) OR (CMAKE_VERSION EQUAL 3.7.9))
|
if ((CMAKE_VERSION GREATER 3.7.9) OR (CMAKE_VERSION EQUAL 3.7.9))
|
||||||
@ -72,10 +76,18 @@ if ((CMAKE_VERSION GREATER 3.7.9) OR (CMAKE_VERSION EQUAL 3.7.9))
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
install(TARGETS GSL EXPORT GSLConfig
|
||||||
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||||
|
)
|
||||||
install(
|
install(
|
||||||
DIRECTORY include/gsl
|
DIRECTORY include/gsl
|
||||||
DESTINATION include
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
)
|
)
|
||||||
|
# Make library importable by other projects
|
||||||
|
install(EXPORT GSLConfig DESTINATION share/GSL/cmake)
|
||||||
|
export(TARGETS GSL FILE GSLConfig.cmake)
|
||||||
|
|
||||||
option(GSL_TEST "Generate tests." ${GSL_STANDALONE_PROJECT})
|
option(GSL_TEST "Generate tests." ${GSL_STANDALONE_PROJECT})
|
||||||
if (GSL_TEST)
|
if (GSL_TEST)
|
||||||
|
Loading…
Reference in New Issue
Block a user