diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index c2900259..903203a4 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -36,13 +36,10 @@ jobs:
- name: Make header
run: cmake --build build --target CLI11-generate-single-file
- - name: Copy file to main folder
- run: cp build/include/CLI11.hpp CLI11.hpp
-
- uses: actions/upload-artifact@v4
with:
name: CLI11.hpp
- path: CLI11.hpp
+ path: build/single-include/CLI11.hpp
- uses: actions/upload-artifact@v4
with:
@@ -54,6 +51,4 @@ jobs:
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
- CLI11.hpp
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ build/single-include/CLI11.hpp
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 01c3815f..10d88230 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -132,10 +132,45 @@ endif()
include(CLI11Warnings)
+# Sources
+
+set(CLI11_headerLoc "${PROJECT_SOURCE_DIR}/include/CLI")
+
+set(CLI11_headers
+ ${CLI11_headerLoc}/App.hpp
+ ${CLI11_headerLoc}/Config.hpp
+ ${CLI11_headerLoc}/ConfigFwd.hpp
+ ${CLI11_headerLoc}/Error.hpp
+ ${CLI11_headerLoc}/Formatter.hpp
+ ${CLI11_headerLoc}/FormatterFwd.hpp
+ ${CLI11_headerLoc}/Macros.hpp
+ ${CLI11_headerLoc}/Option.hpp
+ ${CLI11_headerLoc}/Split.hpp
+ ${CLI11_headerLoc}/StringTools.hpp
+ ${CLI11_headerLoc}/TypeTools.hpp
+ ${CLI11_headerLoc}/Validators.hpp
+ ${CLI11_headerLoc}/Version.hpp
+ ${CLI11_headerLoc}/Encoding.hpp
+ ${CLI11_headerLoc}/Argv.hpp)
+
+set(CLI11_impl_headers
+ ${CLI11_headerLoc}/impl/App_inl.hpp
+ ${CLI11_headerLoc}/impl/Config_inl.hpp
+ ${CLI11_headerLoc}/impl/Formatter_inl.hpp
+ ${CLI11_headerLoc}/impl/Option_inl.hpp
+ ${CLI11_headerLoc}/impl/Split_inl.hpp
+ ${CLI11_headerLoc}/impl/StringTools_inl.hpp
+ ${CLI11_headerLoc}/impl/Validators_inl.hpp
+ ${CLI11_headerLoc}/impl/Encoding_inl.hpp
+ ${CLI11_headerLoc}/impl/Argv_inl.hpp)
+
+set(CLI11_library_headers ${CLI11_headerLoc}/CLI.hpp ${CLI11_headerLoc}/Timer.hpp)
+
# build the fuzzing example or fuzz entry point
add_subdirectory(fuzz)
add_subdirectory(src)
+add_subdirectory(single-include)
# Allow tests to be run on CUDA
if(CLI11_CUDA_TESTS)
diff --git a/cmake/CLIsingle.hpp.in b/cmake/CLIsingle.hpp.in
deleted file mode 100644
index a2d783c3..00000000
--- a/cmake/CLIsingle.hpp.in
+++ /dev/null
@@ -1,10 +0,0 @@
-// Copyright (c) 2017-2024, University of Cincinnati, developed by Henry Schreiner
-// under NSF AWARD 1414736 and by the respective contributors.
-// All rights reserved.
-//
-// SPDX-License-Identifier: BSD-3-Clause
-
-#pragma once
-
-//single file header
-#include "../CLI11.hpp"
diff --git a/single-include/CMakeLists.txt b/single-include/CMakeLists.txt
new file mode 100644
index 00000000..b21003e7
--- /dev/null
+++ b/single-include/CMakeLists.txt
@@ -0,0 +1,37 @@
+if(CLI11_SINGLE_FILE)
+ # Single file test
+ if(CMAKE_VERSION VERSION_LESS 3.12)
+ find_package(PythonInterp REQUIRED)
+ add_executable(Python::Interpreter IMPORTED)
+ set_target_properties(Python::Interpreter PROPERTIES IMPORTED_LOCATION "${PYTHON_EXECUTABLE}"
+ VERSION "${PYTHON_VERSION_STRING}")
+ else()
+ find_package(
+ Python
+ COMPONENTS Interpreter
+ REQUIRED)
+ endif()
+
+ file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/single-include")
+ add_custom_command(
+ OUTPUT "${PROJECT_BINARY_DIR}/single-include/CLI11.hpp"
+ COMMAND
+ Python::Interpreter "${PROJECT_SOURCE_DIR}/scripts/MakeSingleHeader.py" ${CLI11_headers}
+ ${CLI11_impl_headers} --main "${PROJECT_SOURCE_DIR}/CLI11.hpp.in" --output
+ "${PROJECT_BINARY_DIR}/single-include/CLI11.hpp" --version "${CLI11_VERSION}"
+ DEPENDS "${PROJECT_SOURCE_DIR}/include/CLI/CLI.hpp" ${CLI11_headers} ${CLI11_impl_headers})
+ 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)
+ install(FILES "${PROJECT_BINARY_DIR}/single-include/CLI11.hpp"
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+ endif()
+ add_library(CLI11_SINGLE INTERFACE)
+ target_link_libraries(CLI11_SINGLE INTERFACE CLI11)
+ add_dependencies(CLI11_SINGLE CLI11-generate-single-file)
+ target_compile_definitions(CLI11_SINGLE INTERFACE -DCLI11_SINGLE_FILE)
+ target_include_directories(
+ CLI11_SINGLE INTERFACE $
+ $)
+endif()
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index f62c895c..e0b2f64d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,37 +1,3 @@
-set(CLI11_headerLoc "${PROJECT_SOURCE_DIR}/include/CLI")
-
-set(CLI11_headers
- ${CLI11_headerLoc}/App.hpp
- ${CLI11_headerLoc}/Config.hpp
- ${CLI11_headerLoc}/ConfigFwd.hpp
- ${CLI11_headerLoc}/Error.hpp
- ${CLI11_headerLoc}/Formatter.hpp
- ${CLI11_headerLoc}/FormatterFwd.hpp
- ${CLI11_headerLoc}/Macros.hpp
- ${CLI11_headerLoc}/Option.hpp
- ${CLI11_headerLoc}/Split.hpp
- ${CLI11_headerLoc}/StringTools.hpp
- ${CLI11_headerLoc}/TypeTools.hpp
- ${CLI11_headerLoc}/Validators.hpp
- ${CLI11_headerLoc}/Version.hpp
- ${CLI11_headerLoc}/Encoding.hpp
- ${CLI11_headerLoc}/Argv.hpp)
-
-set(CLI11_implLoc "${PROJECT_SOURCE_DIR}/include/CLI/impl")
-
-set(CLI11_impl_headers
- ${CLI11_implLoc}/App_inl.hpp
- ${CLI11_implLoc}/Config_inl.hpp
- ${CLI11_implLoc}/Formatter_inl.hpp
- ${CLI11_implLoc}/Option_inl.hpp
- ${CLI11_implLoc}/Split_inl.hpp
- ${CLI11_implLoc}/StringTools_inl.hpp
- ${CLI11_implLoc}/Validators_inl.hpp
- ${CLI11_implLoc}/Encoding_inl.hpp
- ${CLI11_implLoc}/Argv_inl.hpp)
-
-set(CLI11_library_headers ${CLI11_headerLoc}/CLI.hpp ${CLI11_headerLoc}/Timer.hpp)
-
if(CLI11_PRECOMPILED)
# Create static lib
file(GLOB CLI11_precompile_sources "${PROJECT_SOURCE_DIR}/src/*.cpp")
@@ -84,48 +50,6 @@ if(CMAKE_CXX_STANDARD LESS 14)
endif()
endif()
-if(CLI11_SINGLE_FILE)
- # Single file test
- if(CMAKE_VERSION VERSION_LESS 3.12)
- find_package(PythonInterp REQUIRED)
- add_executable(Python::Interpreter IMPORTED)
- set_target_properties(Python::Interpreter PROPERTIES IMPORTED_LOCATION "${PYTHON_EXECUTABLE}"
- VERSION "${PYTHON_VERSION_STRING}")
- else()
- find_package(
- Python
- COMPONENTS Interpreter
- REQUIRED)
- endif()
-
- file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/include")
- add_custom_command(
- OUTPUT "${PROJECT_BINARY_DIR}/include/CLI11.hpp"
- COMMAND
- Python::Interpreter "${PROJECT_SOURCE_DIR}/scripts/MakeSingleHeader.py" ${CLI11_headers}
- ${CLI11_impl_headers} --main "${PROJECT_SOURCE_DIR}/CLI11.hpp.in" --output
- "${PROJECT_BINARY_DIR}/include/CLI11.hpp" --version "${CLI11_VERSION}"
- DEPENDS "${PROJECT_SOURCE_DIR}/include/CLI/CLI.hpp" ${CLI11_headers} ${CLI11_impl_headers})
- add_custom_target(CLI11-generate-single-file ALL
- DEPENDS "${PROJECT_BINARY_DIR}/include/CLI11.hpp")
- set_property(TARGET CLI11-generate-single-file PROPERTY FOLDER "Scripts")
- if(CLI11_INSTALL)
- install(FILES "${PROJECT_BINARY_DIR}/include/CLI11.hpp"
- DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
- configure_file("${CLI11_SOURCE_DIR}/cmake/CLIsingle.hpp.in"
- "${PROJECT_BINARY_DIR}/include/CLI/CLI.hpp" @ONLY)
- install(FILES "${PROJECT_BINARY_DIR}/include/CLI/CLI.hpp"
- DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/CLI)
- endif()
- add_library(CLI11_SINGLE INTERFACE)
- target_link_libraries(CLI11_SINGLE INTERFACE CLI11)
- add_dependencies(CLI11_SINGLE CLI11-generate-single-file)
- target_compile_definitions(CLI11_SINGLE INTERFACE -DCLI11_SINGLE_FILE)
- target_include_directories(
- CLI11_SINGLE INTERFACE $
- $)
-endif()
-
if(CLI11_INSTALL)
# Make an export target
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index c7ce52fa..77f4ef57 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -118,6 +118,12 @@ foreach(DATA_FILE IN LISTS DATA_FILES)
endforeach()
add_custom_target(cli11_test_data DEPENDS ${DATA_FILES})
+# Make a shim if we are building single file tests
+if(CLI11_SINGLE_FILE AND CLI11_INSTALL_PACKAGE_TESTS)
+ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_single/CLI/CLI.hpp" "#include ")
+ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/test_single/CLI/CLI.hpp" DESTINATION include/CLI)
+endif()
+
# Build dependent applications which are launched from test code
set(CLI11_DEPENDENT_APPLICATIONS ensure_utf8 ensure_utf8_twice)