Permalink
Browse files

cJSON: Option to disable exporting targets

This can be disabled when the exporting of the targets causes problems.
  • Loading branch information...
1 parent 5838e27 commit c213f2eb58c1c6227a46900f20c46cc70ad012c5 @FSMaxB FSMaxB committed Nov 6, 2016
Showing with 17 additions and 8 deletions.
  1. +9 −4 CMakeLists.txt
  2. +8 −4 cJSONConfig.cmake.in
View
@@ -22,6 +22,7 @@ set(version "${PROJECT_VERSION}")
set(includedir "${CMAKE_INSTALL_INCLUDEDIR}")
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
+option(ENABLE_TARGET_EXPORT "Enable exporting of CMake targets. Disable when it causes problems!" ON)
#cJSON
set(CJSON_LIB cjson)
@@ -40,8 +41,10 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/libcjson.pc.in"
install(FILES cJSON.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/cjson")
install (FILES "${CMAKE_CURRENT_BINARY_DIR}/libcjson.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
install(TARGETS "${CJSON_LIB}" DESTINATION "${CMAKE_INSTALL_LIBDIR}" EXPORT "${CJSON_LIB}")
-# export library information for CMake projects
-install(EXPORT "${CJSON_LIB}" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/cJSON")
+if(ENABLE_TARGET_EXPORT)
+ # export library information for CMake projects
+ install(EXPORT "${CJSON_LIB}" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/cJSON")
+endif()
set_target_properties("${CJSON_LIB}"
PROPERTIES
@@ -65,8 +68,10 @@ if(ENABLE_CJSON_UTILS)
install(TARGETS "${CJSON_UTILS_LIB}" DESTINATION "${CMAKE_INSTALL_LIBDIR}" EXPORT "${CJSON_UTILS_LIB}")
install(FILES cJSON_Utils.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/cjson")
install (FILES "${CMAKE_CURRENT_BINARY_DIR}/libcjson_utils.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
- # export library information for CMake projects
- install(EXPORT "${CJSON_UTILS_LIB}" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/cJSON")
+ if(ENABLE_TARGET_EXPORT)
+ # export library information for CMake projects
+ install(EXPORT "${CJSON_UTILS_LIB}" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/cJSON")
+ endif()
set_target_properties("${CJSON_UTILS_LIB}"
PROPERTIES
View
@@ -9,16 +9,20 @@ get_filename_component(_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
# The cJSON library
set(CJSON_LIBRARY "@CJSON_LIB@")
-# Include the target
-include("${_dir}/cjson.cmake")
+if(@ENABLE_TARGET_EXPORT@)
+ # Include the target
+ include("${_dir}/cjson.cmake")
+endif()
if(CJSON_UTILS_FOUND)
# The cJSON utils library
set(CJSON_UTILS_LIBRARY @CJSON_UTILS_LIB@)
# All cJSON libraries
set(CJSON_LIBRARIES "@CJSON_UTILS_LIB@" "@CJSON_LIB@")
- # Include the target
- include("${_dir}/cjson_utils.cmake")
+ if(@ENABLE_TARGET_EXPORT@)
+ # Include the target
+ include("${_dir}/cjson_utils.cmake")
+ endif()
else()
# All cJSON libraries
set(CJSON_LIBRARIES "@CJSON_LIB@")

0 comments on commit c213f2e

Please sign in to comment.