From 7a3a0e92022f2f49aed83e3e57d6c2c07bee92aa Mon Sep 17 00:00:00 2001 From: fhgffy <102001626+fhgffy@users.noreply.github.com> Date: Tue, 6 Oct 2026 01:57:12 +0800 Subject: [PATCH 1/2] Honor JSONCPP_WITH_INSTALL for package metadata --- .github/workflows/cmake.yml | 11 +++++++++++ CMakeLists.txt | 6 +++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index cccf8ed6c..2382e6bfd 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -23,3 +23,14 @@ jobs: with: options: CMAKE_CXX_STANDARD=${{ matrix.cxx_standard }} + + cmake-no-install: + runs-on: ubuntu-latest + steps: + - name: checkout project + uses: actions/checkout@v5 + + - name: build without installation + uses: threeal/cmake-action@v2.0.0 + with: + options: CMAKE_CXX_STANDARD=11 JSONCPP_WITH_INSTALL=OFF diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d977b71c..4ed9003c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,7 +73,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 "Include JsonCpp header and binaries in the install target" ON) +option(JSONCPP_WITH_INSTALL "Include JsonCpp files 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) @@ -161,7 +161,7 @@ if(JSONCPP_WITH_WARNING_AS_ERROR) use_compilation_warning_as_error() endif() -if(JSONCPP_WITH_PKGCONFIG_SUPPORT) +if(JSONCPP_WITH_INSTALL AND JSONCPP_WITH_PKGCONFIG_SUPPORT) include(JoinPaths) join_paths(libdir_for_pc_file "\${exec_prefix}" "${CMAKE_INSTALL_LIBDIR}") @@ -175,7 +175,7 @@ if(JSONCPP_WITH_PKGCONFIG_SUPPORT) DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") endif() -if(JSONCPP_WITH_CMAKE_PACKAGE) +if(JSONCPP_WITH_INSTALL AND JSONCPP_WITH_CMAKE_PACKAGE) include(CMakePackageConfigHelpers) install(EXPORT jsoncpp DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/jsoncpp From 26c2ee169e69011b74bf93ec2b33d1c19c76bc1e Mon Sep 17 00:00:00 2001 From: fhgffy <102001626+fhgffy@users.noreply.github.com> Date: Tue, 6 Oct 2026 02:18:37 +0800 Subject: [PATCH 2/2] Verify no-install builds leave an empty install stage --- .github/workflows/cmake.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 2382e6bfd..f723aadcf 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -34,3 +34,10 @@ jobs: uses: threeal/cmake-action@v2.0.0 with: options: CMAKE_CXX_STANDARD=11 JSONCPP_WITH_INSTALL=OFF + + - name: verify nothing is installed + run: | + install_dir="$(mktemp -d)" + DESTDIR="$install_dir" cmake --install build + installed_files="$(find "$install_dir" -mindepth 1 -print -quit)" + test -z "$installed_files"