fix: 'cjson_utils-static' target not exist(#625)
* Update CMakeLists.txt
fix the bug:when build with cmake using option '-DBUILD_SHARED_AND_STATIC_LIBS=ON -DENABLE_CJSON_UTILS=ON', build sucess,
but use cmake comand 'find_package(cjson CONFIG)', 'cjson_utils' target is available,but  'cjson_utils-static' target not exist.
@@ -156,7 +156,11 @@ install(TARGETS "${CJSON_LIB}"
INCLUDES DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}"
)
if (BUILD_SHARED_AND_STATIC_LIBS)
- install(TARGETS "${CJSON_LIB}-static" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}")
+ install(TARGETS "${CJSON_LIB}-static"
+ EXPORT "${CJSON_LIB}"
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}"
+ INCLUDES DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}"
+)
endif()
if(ENABLE_TARGET_EXPORT)
# export library information for CMake projects
@@ -201,7 +205,11 @@ if(ENABLE_CJSON_UTILS)
INCLUDES DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}"
)
if (BUILD_SHARED_AND_STATIC_LIBS)
- install(TARGETS "${CJSON_UTILS_LIB}-static" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}")
+ install(TARGETS "${CJSON_UTILS_LIB}-static"
+ EXPORT "${CJSON_UTILS_LIB}"
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}"
+ INCLUDES DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}"
+ )
endif()
install(FILES cJSON_Utils.h DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}/cjson")
install (FILES "${CMAKE_CURRENT_BINARY_DIR}/libcjson_utils.pc" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig")
