Config-mode install
This commit is contained in:
parent
7d151fd687
commit
4eecec17ea
@ -105,13 +105,6 @@ target_link_libraries(bzip2_bin bz2)
|
||||
set_target_properties(bzip2_bin PROPERTIES OUTPUT_NAME bzip2)
|
||||
|
||||
|
||||
install(TARGETS bz2 bzip2recover bzip2_bin
|
||||
RUNTIME DESTINATION bin
|
||||
ARCHIVE DESTINATION lib
|
||||
LIBRARY DESTINATION lib
|
||||
PUBLIC_HEADER DESTINATION include
|
||||
)
|
||||
|
||||
file(GLOB man1 ${bzip2_SOURCE_DIR}/*.1)
|
||||
|
||||
|
||||
@ -195,3 +188,47 @@ add_test(NAME decompress_block_size_3
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
####
|
||||
# Installation (https://github.com/forexample/package-example)
|
||||
|
||||
set(config_install_dir "lib/cmake/${PROJECT_NAME}")
|
||||
set(include_install_dir "include")
|
||||
|
||||
set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
|
||||
|
||||
set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake")
|
||||
set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake")
|
||||
set(targets_export_name "${PROJECT_NAME}Targets")
|
||||
set(namespace "${PROJECT_NAME}::")
|
||||
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
# Note: PROJECT_VERSION is used as a VERSION
|
||||
write_basic_package_version_file(
|
||||
"${version_config}" COMPATIBILITY SameMajorVersion
|
||||
)
|
||||
|
||||
# Note: variable 'targets_export_name' used
|
||||
configure_file("cmake/Config.cmake.in" "${project_config}" @ONLY)
|
||||
|
||||
install(
|
||||
TARGETS bz2 bzip2recover bzip2_bin
|
||||
EXPORT "${targets_export_name}"
|
||||
LIBRARY DESTINATION "lib"
|
||||
ARCHIVE DESTINATION "lib"
|
||||
RUNTIME DESTINATION "bin"
|
||||
INCLUDES DESTINATION "${include_install_dir}"
|
||||
PUBLIC_HEADER DESTINATION "${include_install_dir}"
|
||||
)
|
||||
|
||||
install(
|
||||
FILES "${project_config}" "${version_config}"
|
||||
DESTINATION "${config_install_dir}"
|
||||
)
|
||||
|
||||
install(
|
||||
EXPORT "${targets_export_name}"
|
||||
NAMESPACE "${namespace}"
|
||||
DESTINATION "${config_install_dir}"
|
||||
)
|
||||
|
1
cmake/Config.cmake.in
Normal file
1
cmake/Config.cmake.in
Normal file
@ -0,0 +1 @@
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake")
|
Loading…
Reference in New Issue
Block a user