Skip to content

Commit

Permalink
Merge branch 'cmake-config-improvements' #1271
Browse files Browse the repository at this point in the history
(creating merge-commit late, after accidental "rebase-and-merge")
  • Loading branch information
cdunn2001 committed May 5, 2021
2 parents 94cda30 + 993e4e2 commit bb34617
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,16 @@ if(JSONCPP_WITH_CMAKE_PACKAGE)
include(CMakePackageConfigHelpers)
install(EXPORT 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"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/jsoncppConfigVersion.cmake
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/jsoncppConfigVersion.cmake ${CMAKE_CURRENT_BINARY_DIR}/jsoncppConfig.cmake
${CMAKE_CURRENT_SOURCE_DIR}/jsoncpp-namespaced-targets.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/jsoncpp)
endif()

Expand Down
7 changes: 7 additions & 0 deletions jsoncpp-namespaced-targets.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
if (TARGET jsoncpp_static)
add_library(JsonCpp::JsonCpp INTERFACE IMPORTED)
set_target_properties(JsonCpp::JsonCpp PROPERTIES INTERFACE_LINK_LIBRARIES "jsoncpp_static")
elseif (TARGET jsoncpp_lib)
add_library(JsonCpp::JsonCpp INTERFACE IMPORTED)
set_target_properties(JsonCpp::JsonCpp PROPERTIES INTERFACE_LINK_LIBRARIES "jsoncpp_lib")
endif ()
11 changes: 11 additions & 0 deletions jsoncppConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_policy(PUSH)
cmake_policy(VERSION 3.0)

@PACKAGE_INIT@

include ( "${CMAKE_CURRENT_LIST_DIR}/jsoncpp-targets.cmake" )
include ( "${CMAKE_CURRENT_LIST_DIR}/jsoncpp-namespaced-targets.cmake" )

check_required_components(JsonCpp)

cmake_policy(POP)

0 comments on commit bb34617

Please sign in to comment.