From 993e4e2828993b017e6e3f5fff99697eead4d134 Mon Sep 17 00:00:00 2001 From: Sergey Rachev Date: Wed, 14 Apr 2021 20:50:43 +0200 Subject: [PATCH] - isolated namespace targets into separate file --- CMakeLists.txt | 1 + jsoncpp-namespaced-targets.cmake | 7 +++++++ jsoncppConfig.cmake.in | 9 +-------- 3 files changed, 9 insertions(+), 8 deletions(-) create mode 100644 jsoncpp-namespaced-targets.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 6093905..48b0350 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -186,6 +186,7 @@ if(JSONCPP_WITH_CMAKE_PACKAGE) COMPATIBILITY SameMajorVersion) 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() diff --git a/jsoncpp-namespaced-targets.cmake b/jsoncpp-namespaced-targets.cmake new file mode 100644 index 0000000..ac1504e --- /dev/null +++ b/jsoncpp-namespaced-targets.cmake @@ -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 () \ No newline at end of file diff --git a/jsoncppConfig.cmake.in b/jsoncppConfig.cmake.in index c1cc6ca..76570bc 100644 --- a/jsoncppConfig.cmake.in +++ b/jsoncppConfig.cmake.in @@ -4,14 +4,7 @@ cmake_policy(VERSION 3.0) @PACKAGE_INIT@ include ( "${CMAKE_CURRENT_LIST_DIR}/jsoncpp-targets.cmake" ) - -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() +include ( "${CMAKE_CURRENT_LIST_DIR}/jsoncpp-namespaced-targets.cmake" ) check_required_components(JsonCpp)