mirror of
https://github.com/ETLCPP/etl.git
synced 2026-07-30 16:26:17 +08:00
Extended CMake installation handling (#523)
* updated the version handling - Introduces a new version.txt file - This file is parsed by CMake to determine the current version * assign version in project call * use version variable * Meson update 1. Minor fix for GCC build 2. Use external version file which can be used by CMake as well * get version from git tag now * ci/cd broke.. * maybe this solves the error * updated workflow files * one last test * remove git describe call * extended CMake installation handling * only write version file if possible * read version.txt as fallback * missing version.txt arg
This commit is contained in:
parent
fbffca3b4c
commit
39156c918b
@ -16,16 +16,44 @@ add_library(${PROJECT_NAME} INTERFACE)
|
|||||||
|
|
||||||
target_include_directories(${PROJECT_NAME} SYSTEM INTERFACE
|
target_include_directories(${PROJECT_NAME} SYSTEM INTERFACE
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
$<INSTALL_INTERFACE:include>
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME} INTERFACE)
|
target_link_libraries(${PROJECT_NAME} INTERFACE)
|
||||||
|
|
||||||
# only install if top level project
|
# only install if top level project
|
||||||
if(${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME})
|
if(${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME})
|
||||||
install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Config)
|
# Steps here based on excellent guide: https://dominikberner.ch/cmake-interface-lib/
|
||||||
install(EXPORT ${PROJECT_NAME}Config DESTINATION lib/cmake/${PROJECT_NAME})
|
# Which also details all steps
|
||||||
install(DIRECTORY include/${PROJECT_NAME} DESTINATION include)
|
include(CMakePackageConfigHelpers)
|
||||||
|
install(TARGETS ${PROJECT_NAME}
|
||||||
|
EXPORT ${PROJECT_NAME}Targets
|
||||||
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||||
|
)
|
||||||
|
if(ETL_VERSION)
|
||||||
|
# Generate the package configuration files using CMake provided macros
|
||||||
|
write_basic_package_version_file(
|
||||||
|
"${PROJECT_NAME}ConfigVersion.cmake"
|
||||||
|
COMPATIBILITY SameMajorVersion
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
configure_package_config_file(
|
||||||
|
"${PROJECT_SOURCE_DIR}/cmake/${PROJECT_NAME}Config.cmake.in"
|
||||||
|
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
|
||||||
|
INSTALL_DESTINATION
|
||||||
|
${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake)
|
||||||
|
|
||||||
|
# Install target file, then package configuration files, and finally the headers
|
||||||
|
install(EXPORT ${PROJECT_NAME}Targets
|
||||||
|
FILE ${PROJECT_NAME}Targets.cmake
|
||||||
|
NAMESPACE ${PROJECT_NAME}::
|
||||||
|
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake)
|
||||||
|
install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
|
||||||
|
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
|
||||||
|
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake)
|
||||||
|
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/etl DESTINATION include)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (BUILD_TESTS)
|
if (BUILD_TESTS)
|
||||||
|
|||||||
4
cmake/etlConfig.cmake.in
Normal file
4
cmake/etlConfig.cmake.in
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
@PACKAGE_INIT@
|
||||||
|
|
||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
|
||||||
|
check_required_components("@PROJECT_NAME@")
|
||||||
Loading…
x
Reference in New Issue
Block a user