From 1486821b8e2fd0a681cab3312b3eea2ae700bc13 Mon Sep 17 00:00:00 2001 From: Philip Top Date: Sun, 9 Nov 2025 11:42:31 -0800 Subject: [PATCH 1/4] add an option for full install, include imp headers with precompiled option --- .github/workflows/tests.yml | 17 +++++++++++++++++ CMakeLists.txt | 7 +++++-- book/chapters/installation.md | 1 + single-include/CMakeLists.txt | 2 +- src/CMakeLists.txt | 6 +++--- 5 files changed, 27 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 028881b2e..da6878a89 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -244,6 +244,23 @@ jobs: - name: Run tests run: ctest --output-on-failure -L Packaging working-directory: build + + install-precompiled-all: + name: install tests precompiled full install + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - name: Configure + run: cmake -S . -B build -DCLI11_INSTALL_PACKAGE_TESTS=ON -DCLI11_ENABLE_EXTRA_VALIDATORS=ON -DCMAKE_INSTALL_PREFIX=/home/runner/work/install -DCLI11_PRECOMPILED=ON -DCLI11_FULL_INSTALL=ON + - name: Build + run: cmake --build build -j2 + - name: install + run: cmake --install build + - name: Run tests + run: ctest --output-on-failure -L Packaging + working-directory: build install-precompiled-macos: name: install tests precompiled macos diff --git a/CMakeLists.txt b/CMakeLists.txt index e8f6b5422..b3e3be4b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,6 +79,9 @@ cmake_dependent_option(CLI11_BUILD_EXAMPLES "Build CLI11 examples" ON cmake_dependent_option(CLI11_BUILD_EXAMPLES_JSON "Build CLI11 json example" OFF "CLI11_BUILD_EXAMPLES;NOT CMAKE_VERSION VERSION_LESS 3.15" OFF) +cmake_dependent_option(CLI11_FULL_INSTALL "Install all headers regardless of SINGLE_FILE OR PRECOMPILED OPTIONS" OFF + "CLI11_SINGLE_FILE OR CLI11_PRECOMPILED" OFF) + cmake_dependent_option(CLI11_SINGLE_FILE_TESTS "Duplicate all the tests for a single file build" OFF "BUILD_TESTING;CLI11_SINGLE_FILE" OFF) @@ -93,7 +96,7 @@ cmake_dependent_option( CLI11_CUDA_TESTS "Build the tests with NVCC to check for warnings there - requires CMake 3.9+" OFF "CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME" OFF) -if(CLI11_PRECOMPILED AND CLI11_SINGLE_FILE) +if(NOT CLI11_FULL_INSTALL AND CLI11_PRECOMPILED AND CLI11_SINGLE_FILE) # Sanity check message(FATAL_ERROR "CLI11_PRECOMPILE and CLI11_SINGLE_FILE are mutually exclusive") endif() @@ -171,7 +174,7 @@ if(CLI11_CUDA_TESTS) endif() # This folder should be installed -if(CLI11_INSTALL) +if(CLI11_INSTALL OR CLI11_FULL_INSTALL) # Use find_package on the installed package # Since we have no custom code, we can directly write this diff --git a/book/chapters/installation.md b/book/chapters/installation.md index f44fe8d6d..0cc3fe87b 100644 --- a/book/chapters/installation.md +++ b/book/chapters/installation.md @@ -185,6 +185,7 @@ default to off if CLI11 is used as a subdirectory in another project. | `CLI11_BUILD_EXAMPLES=ON` | Build the example programs. | | `CLI11_BUILD_EXAMPLES_JSON=ON` | Build some additional example using json libraries | | `CLI11_INSTALL=ON` | install CLI11 to the install folder during the install process | +| `CLI11_FULL_INSTALL=ON` | install all CLI11 headers regardless of other settings | | `CLI11_FORCE_LIBCXX=OFF` | use libc++ instead of libstdc++ if building with clang on linux | | `CLI11_CUDA_TESTS=OFF` | build the tests with NVCC | | `CLI11_BUILD_TESTS=ON` | Build the tests. | diff --git a/single-include/CMakeLists.txt b/single-include/CMakeLists.txt index 01bc78e9a..baf66cf30 100644 --- a/single-include/CMakeLists.txt +++ b/single-include/CMakeLists.txt @@ -17,7 +17,7 @@ if(CLI11_SINGLE_FILE) add_custom_target(CLI11-generate-single-file ALL DEPENDS "${PROJECT_BINARY_DIR}/single-include/CLI11.hpp") set_property(TARGET CLI11-generate-single-file PROPERTY FOLDER "Scripts") - if(CLI11_INSTALL) + if(CLI11_INSTALL OR CLI11_FULL_INSTALL) install(FILES "${PROJECT_BINARY_DIR}/single-include/CLI11.hpp" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6989f6d0c..7ec6218a1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -44,14 +44,14 @@ if(CMAKE_CXX_STANDARD LESS 14) target_compile_features(CLI11 INTERFACE cxx_std_11) endif() -if(CLI11_INSTALL) +if(CLI11_INSTALL OR CLI11_FULL_INSTALL) # Make an export target install(TARGETS CLI11 EXPORT CLI11Targets) - if(NOT CLI11_SINGLE_FILE) + if((NOT CLI11_SINGLE_FILE) OR CLI11_FULL_INSTALL) install(FILES ${CLI11_headers} ${CLI11_library_headers} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/CLI") - if(NOT CLI11_PRECOMPILED) + if((NOT CLI11_PRECOMPILED) OR CLI11_FULL_INSTALL) install(FILES ${CLI11_impl_headers} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/CLI/impl") endif() endif() From 2ea7a63ff6362bc5857efe89e1fc4384f2af8c6c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 9 Nov 2025 19:44:51 +0000 Subject: [PATCH 2/4] style: pre-commit.ci fixes --- CMakeLists.txt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b3e3be4b6..ad9e201c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,9 +79,10 @@ cmake_dependent_option(CLI11_BUILD_EXAMPLES "Build CLI11 examples" ON cmake_dependent_option(CLI11_BUILD_EXAMPLES_JSON "Build CLI11 json example" OFF "CLI11_BUILD_EXAMPLES;NOT CMAKE_VERSION VERSION_LESS 3.15" OFF) -cmake_dependent_option(CLI11_FULL_INSTALL "Install all headers regardless of SINGLE_FILE OR PRECOMPILED OPTIONS" OFF - "CLI11_SINGLE_FILE OR CLI11_PRECOMPILED" OFF) - +cmake_dependent_option( + CLI11_FULL_INSTALL "Install all headers regardless of SINGLE_FILE OR PRECOMPILED OPTIONS" OFF + "CLI11_SINGLE_FILE OR CLI11_PRECOMPILED" OFF) + cmake_dependent_option(CLI11_SINGLE_FILE_TESTS "Duplicate all the tests for a single file build" OFF "BUILD_TESTING;CLI11_SINGLE_FILE" OFF) @@ -96,7 +97,9 @@ cmake_dependent_option( CLI11_CUDA_TESTS "Build the tests with NVCC to check for warnings there - requires CMake 3.9+" OFF "CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME" OFF) -if(NOT CLI11_FULL_INSTALL AND CLI11_PRECOMPILED AND CLI11_SINGLE_FILE) +if(NOT CLI11_FULL_INSTALL + AND CLI11_PRECOMPILED + AND CLI11_SINGLE_FILE) # Sanity check message(FATAL_ERROR "CLI11_PRECOMPILE and CLI11_SINGLE_FILE are mutually exclusive") endif() From 305c7e71c2b05da1dab941ac00158b393430c1cc Mon Sep 17 00:00:00 2001 From: Philip Top Date: Sun, 9 Nov 2025 12:04:27 -0800 Subject: [PATCH 3/4] try switching the tests for packaging with full install --- .github/workflows/tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index da6878a89..f0a56cb7a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -258,6 +258,8 @@ jobs: run: cmake --build build -j2 - name: install run: cmake --install build + - name: Configure2 + run: cmake -S . -B build -DCLI11_INSTALL_PACKAGE_TESTS=ON -DCMAKE_INSTALL_PREFIX=/home/runner/work/install - name: Run tests run: ctest --output-on-failure -L Packaging working-directory: build From 21710ea6420e2f92afb6f6da52ef5b1c53fa29e6 Mon Sep 17 00:00:00 2001 From: Philip Top Date: Mon, 10 Nov 2025 14:59:32 -0800 Subject: [PATCH 4/4] update install chapter --- book/chapters/installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/book/chapters/installation.md b/book/chapters/installation.md index 0cc3fe87b..322daf712 100644 --- a/book/chapters/installation.md +++ b/book/chapters/installation.md @@ -185,7 +185,7 @@ default to off if CLI11 is used as a subdirectory in another project. | `CLI11_BUILD_EXAMPLES=ON` | Build the example programs. | | `CLI11_BUILD_EXAMPLES_JSON=ON` | Build some additional example using json libraries | | `CLI11_INSTALL=ON` | install CLI11 to the install folder during the install process | -| `CLI11_FULL_INSTALL=ON` | install all CLI11 headers regardless of other settings | +| `CLI11_FULL_INSTALL=ON` | install all CLI11 headers/libraries regardless of other settings | | `CLI11_FORCE_LIBCXX=OFF` | use libc++ instead of libstdc++ if building with clang on linux | | `CLI11_CUDA_TESTS=OFF` | build the tests with NVCC | | `CLI11_BUILD_TESTS=ON` | Build the tests. |