diff --git a/CMakeLists.txt b/CMakeLists.txt index b0de85d..8259516 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,9 @@ project(GSL CXX) include(ExternalProject) 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) add_library(GSL INTERFACE) @@ -55,6 +58,7 @@ target_include_directories(GSL INTERFACE $ + $ ) 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() +install(TARGETS GSL EXPORT GSLConfig + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +) install( 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}) if (GSL_TEST)