Skip to content

Commit bb34617

Browse files
committed
Merge branch 'cmake-config-improvements' #1271
(creating merge-commit late, after accidental "rebase-and-merge")
2 parents 94cda30 + 993e4e2 commit bb34617

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

CMakeLists.txt

+7-2
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,16 @@ if(JSONCPP_WITH_CMAKE_PACKAGE)
177177
include(CMakePackageConfigHelpers)
178178
install(EXPORT jsoncpp
179179
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/jsoncpp
180-
FILE jsoncppConfig.cmake)
180+
FILE jsoncpp-targets.cmake)
181+
configure_package_config_file(jsoncppConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/jsoncppConfig.cmake
182+
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/jsoncpp)
183+
181184
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/jsoncppConfigVersion.cmake"
182185
VERSION ${PROJECT_VERSION}
183186
COMPATIBILITY SameMajorVersion)
184-
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/jsoncppConfigVersion.cmake
187+
install(FILES
188+
${CMAKE_CURRENT_BINARY_DIR}/jsoncppConfigVersion.cmake ${CMAKE_CURRENT_BINARY_DIR}/jsoncppConfig.cmake
189+
${CMAKE_CURRENT_SOURCE_DIR}/jsoncpp-namespaced-targets.cmake
185190
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/jsoncpp)
186191
endif()
187192

jsoncpp-namespaced-targets.cmake

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
if (TARGET jsoncpp_static)
2+
add_library(JsonCpp::JsonCpp INTERFACE IMPORTED)
3+
set_target_properties(JsonCpp::JsonCpp PROPERTIES INTERFACE_LINK_LIBRARIES "jsoncpp_static")
4+
elseif (TARGET jsoncpp_lib)
5+
add_library(JsonCpp::JsonCpp INTERFACE IMPORTED)
6+
set_target_properties(JsonCpp::JsonCpp PROPERTIES INTERFACE_LINK_LIBRARIES "jsoncpp_lib")
7+
endif ()

jsoncppConfig.cmake.in

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
cmake_policy(PUSH)
2+
cmake_policy(VERSION 3.0)
3+
4+
@PACKAGE_INIT@
5+
6+
include ( "${CMAKE_CURRENT_LIST_DIR}/jsoncpp-targets.cmake" )
7+
include ( "${CMAKE_CURRENT_LIST_DIR}/jsoncpp-namespaced-targets.cmake" )
8+
9+
check_required_components(JsonCpp)
10+
11+
cmake_policy(POP)

0 commit comments

Comments
 (0)