Skip to content

Commit

Permalink
cJSON: Option to disable exporting targets
Browse files Browse the repository at this point in the history
This can be disabled when the exporting of the targets causes problems.
  • Loading branch information
FSMaxB committed Nov 14, 2016
1 parent 5838e27 commit c213f2e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
13 changes: 9 additions & 4 deletions CMakeLists.txt
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand Down
12 changes: 8 additions & 4 deletions cJSONConfig.cmake.in
Expand Up @@ -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@")
Expand Down

0 comments on commit c213f2e

Please sign in to comment.