From c250e13b1eddad801b7921863a3709701b8e5d9a Mon Sep 17 00:00:00 2001 From: Johannes Deligiannis Date: Wed, 15 Jan 2025 13:32:15 +0100 Subject: [PATCH 1/2] Adding a cmake option to exclude the jsoncpp files from install. Useful when used used as a submodule --- CMakeLists.txt | 1 + include/CMakeLists.txt | 3 +++ src/lib_json/CMakeLists.txt | 3 +++ 3 files changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6104c5ce5..c7f7b1901 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,6 +78,7 @@ option(JSONCPP_WITH_STRICT_ISO "Issue all the warnings demanded by strict ISO C option(JSONCPP_WITH_PKGCONFIG_SUPPORT "Generate and install .pc files" ON) option(JSONCPP_WITH_CMAKE_PACKAGE "Generate and install cmake package files" ON) option(JSONCPP_WITH_EXAMPLE "Compile JsonCpp example" OFF) +option(JSONCPP_WITH_INSTALL "make JsonCpp header and libraries part of the install target" ON) option(JSONCPP_STATIC_WINDOWS_RUNTIME "Use static (MT/MTd) Windows runtime" OFF) option(BUILD_SHARED_LIBS "Build jsoncpp_lib as a shared library." ON) option(BUILD_STATIC_LIBS "Build jsoncpp_lib as a static library." ON) diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index dc40d95e8..bbd640559 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -1,5 +1,8 @@ +if (JSONCPP_WITH_INSTALL) + file(GLOB INCLUDE_FILES "json/*.h") install(FILES ${INCLUDE_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/json) +endif() \ No newline at end of file diff --git a/src/lib_json/CMakeLists.txt b/src/lib_json/CMakeLists.txt index 3037eb020..86722ac8d 100644 --- a/src/lib_json/CMakeLists.txt +++ b/src/lib_json/CMakeLists.txt @@ -196,6 +196,8 @@ if(BUILD_OBJECT_LIBS) list(APPEND CMAKE_TARGETS ${OBJECT_LIB}) endif() +if (JSONCPP_WITH_INSTALL) + install(TARGETS ${CMAKE_TARGETS} ${INSTALL_EXPORT} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} @@ -203,3 +205,4 @@ install(TARGETS ${CMAKE_TARGETS} ${INSTALL_EXPORT} OBJECTS DESTINATION ${CMAKE_INSTALL_LIBDIR} ) +endif() From fc6886f6c9f53ab6e5a221e79190090139aa2822 Mon Sep 17 00:00:00 2001 From: Johannes Deligiannis Date: Wed, 15 Jan 2025 13:40:00 +0100 Subject: [PATCH 2/2] Updaing help text --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c7f7b1901..f3afc4f21 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,7 +78,7 @@ option(JSONCPP_WITH_STRICT_ISO "Issue all the warnings demanded by strict ISO C option(JSONCPP_WITH_PKGCONFIG_SUPPORT "Generate and install .pc files" ON) option(JSONCPP_WITH_CMAKE_PACKAGE "Generate and install cmake package files" ON) option(JSONCPP_WITH_EXAMPLE "Compile JsonCpp example" OFF) -option(JSONCPP_WITH_INSTALL "make JsonCpp header and libraries part of the install target" ON) +option(JSONCPP_WITH_INSTALL "Include JsonCpp header and binaries in the install target" ON) option(JSONCPP_STATIC_WINDOWS_RUNTIME "Use static (MT/MTd) Windows runtime" OFF) option(BUILD_SHARED_LIBS "Build jsoncpp_lib as a shared library." ON) option(BUILD_STATIC_LIBS "Build jsoncpp_lib as a static library." ON)