Move generating of package configuration into separate section

This commit is contained in:
Florian Albrechtskirchinger 2022-09-23 10:12:42 +02:00
parent d14e22c40b
commit 37453d0903
No known key found for this signature in database
GPG Key ID: 19618CE9B2D4BE6D

View File

@ -69,12 +69,6 @@ if (MSVC)
) )
endif() endif()
# Install a pkg-config file, so other tools can find this.
CONFIGURE_FILE(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/pkg-config.pc.in"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc"
)
############################################################################# #############################################################################
# add tests # add tests
############################################################################# #############################################################################
@ -91,10 +85,22 @@ if(JSON_CI)
endif() endif()
############################################################################# #############################################################################
# install files and targets # generate package configuration files
############################################################################# #############################################################################
include(CMakePackageConfigHelpers) # generate pkg-config file
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/pkg-config.pc.in"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc"
)
# generate CMake module configuration and version files
configure_file(
${JSON_CMAKE_CONFIG_TEMPLATE}
${JSON_CMAKE_PROJECT_CONFIG_FILE}
@ONLY
)
# use a custom package version config file instead of # use a custom package version config file instead of
# write_basic_package_version_file to ensure that it's architecture-independent # write_basic_package_version_file to ensure that it's architecture-independent
# https://github.com/nlohmann/json/issues/1697 # https://github.com/nlohmann/json/issues/1697
@ -103,11 +109,10 @@ configure_file(
${JSON_CMAKE_VERSION_CONFIG_FILE} ${JSON_CMAKE_VERSION_CONFIG_FILE}
@ONLY @ONLY
) )
configure_file(
${JSON_CMAKE_CONFIG_TEMPLATE} #############################################################################
${JSON_CMAKE_PROJECT_CONFIG_FILE} # install files and targets
@ONLY #############################################################################
)
if(JSON_Install) if(JSON_Install)
install( install(