mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2024-12-26 18:51:04 +08:00
- exported targets go to separate generated file and package config file generated from template to use automatic package resolving and resolution logic
CMake provides helpers to generate config file. Generated config file has usefull macro check_required_components() to set necessary variables like PackageName_FOUND if requirements has been satisfied. An absence of dedicated config file confuses user project as necessary variables are not set.
This commit is contained in:
parent
94cda30dbd
commit
b640795571
@ -177,11 +177,13 @@ if(JSONCPP_WITH_CMAKE_PACKAGE)
|
|||||||
include(CMakePackageConfigHelpers)
|
include(CMakePackageConfigHelpers)
|
||||||
install(EXPORT jsoncpp
|
install(EXPORT jsoncpp
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/jsoncpp
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/jsoncpp
|
||||||
FILE jsoncppConfig.cmake)
|
FILE jsoncpp-targets.cmake)
|
||||||
|
configure_package_config_file(jsoncppConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/jsoncppConfig.cmake INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/jsoncpp)
|
||||||
|
|
||||||
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/jsoncppConfigVersion.cmake"
|
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/jsoncppConfigVersion.cmake"
|
||||||
VERSION ${PROJECT_VERSION}
|
VERSION ${PROJECT_VERSION}
|
||||||
COMPATIBILITY SameMajorVersion)
|
COMPATIBILITY SameMajorVersion)
|
||||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/jsoncppConfigVersion.cmake
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/jsoncppConfigVersion.cmake ${CMAKE_CURRENT_BINARY_DIR}/jsoncppConfig.cmake
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/jsoncpp)
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/jsoncpp)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
10
jsoncppConfig.cmake.in
Normal file
10
jsoncppConfig.cmake.in
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
cmake_policy(PUSH)
|
||||||
|
cmake_policy(VERSION 3.0)
|
||||||
|
|
||||||
|
@PACKAGE_INIT@
|
||||||
|
|
||||||
|
include ( "${CMAKE_CURRENT_LIST_DIR}/jsoncpp-targets.cmake" )
|
||||||
|
|
||||||
|
check_required_components(JsonCpp)
|
||||||
|
|
||||||
|
cmake_policy(POP)
|
Loading…
x
Reference in New Issue
Block a user