[A] Add target export in cmake.

This commit is contained in:
seleznevae 2020-02-09 13:02:25 +03:00
parent bff48549de
commit c22a518766
2 changed files with 19 additions and 6 deletions

View File

@ -15,6 +15,7 @@
### Internal ### Internal
- Refactoring of code that uses vectors. - Refactoring of code that uses vectors.
- Add target export in cmake.
### Docs ### Docs

View File

@ -6,7 +6,8 @@ add_library(fort
target_include_directories(fort target_include_directories(fort
PUBLIC PUBLIC
${CMAKE_CURRENT_SOURCE_DIR} $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
) )
set_target_properties(fort set_target_properties(fort
@ -30,14 +31,25 @@ endif()
include(GNUInstallDirs) include(GNUInstallDirs)
install( install(
TARGETS TARGETS fort
fort EXPORT LibFort
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
) )
install(
install(FILES fort.h fort.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) FILES fort.h fort.hpp
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
configure_file(libfort.pc.in libfort.pc @ONLY) 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}
)