From c22a518766884d9f4d36dce9c2c6dde18acb87e3 Mon Sep 17 00:00:00 2001 From: seleznevae Date: Sun, 9 Feb 2020 13:02:25 +0300 Subject: [PATCH] [A] Add target export in cmake. --- ChangeLog.md | 1 + lib/CMakeLists.txt | 24 ++++++++++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 992046d..21595de 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -15,6 +15,7 @@ ### Internal - Refactoring of code that uses vectors. +- Add target export in cmake. ### Docs diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index e065284..837ed5f 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -6,7 +6,8 @@ add_library(fort target_include_directories(fort PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR} + $ + $ ) set_target_properties(fort @@ -30,14 +31,25 @@ endif() include(GNUInstallDirs) install( - TARGETS - fort + TARGETS fort + EXPORT LibFort LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) - -install(FILES fort.h fort.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +install( + FILES fort.h fort.hpp + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) configure_file(libfort.pc.in libfort.pc @ONLY) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libfort.pc DESTINATION lib/pkgconfig) +install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/libfort.pc + DESTINATION lib/pkgconfig +) + +install( + EXPORT LibFort + NAMESPACE LibFort:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} +)