Skip to content

Commit bd6462f

Browse files
chore: move single file to own folder (#1030)
See #1025. --------- Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 9ee42de commit bd6462f

File tree

6 files changed

+80
-93
lines changed

6 files changed

+80
-93
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,10 @@ jobs:
3636
- name: Make header
3737
run: cmake --build build --target CLI11-generate-single-file
3838

39-
- name: Copy file to main folder
40-
run: cp build/include/CLI11.hpp CLI11.hpp
41-
4239
- uses: actions/upload-artifact@v4
4340
with:
4441
name: CLI11.hpp
45-
path: CLI11.hpp
42+
path: build/single-include/CLI11.hpp
4643

4744
- uses: actions/upload-artifact@v4
4845
with:
@@ -54,6 +51,4 @@ jobs:
5451
if: startsWith(github.ref, 'refs/tags/')
5552
with:
5653
files: |
57-
CLI11.hpp
58-
env:
59-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
build/single-include/CLI11.hpp

CMakeLists.txt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,45 @@ endif()
132132

133133
include(CLI11Warnings)
134134

135+
# Sources
136+
137+
set(CLI11_headerLoc "${PROJECT_SOURCE_DIR}/include/CLI")
138+
139+
set(CLI11_headers
140+
${CLI11_headerLoc}/App.hpp
141+
${CLI11_headerLoc}/Config.hpp
142+
${CLI11_headerLoc}/ConfigFwd.hpp
143+
${CLI11_headerLoc}/Error.hpp
144+
${CLI11_headerLoc}/Formatter.hpp
145+
${CLI11_headerLoc}/FormatterFwd.hpp
146+
${CLI11_headerLoc}/Macros.hpp
147+
${CLI11_headerLoc}/Option.hpp
148+
${CLI11_headerLoc}/Split.hpp
149+
${CLI11_headerLoc}/StringTools.hpp
150+
${CLI11_headerLoc}/TypeTools.hpp
151+
${CLI11_headerLoc}/Validators.hpp
152+
${CLI11_headerLoc}/Version.hpp
153+
${CLI11_headerLoc}/Encoding.hpp
154+
${CLI11_headerLoc}/Argv.hpp)
155+
156+
set(CLI11_impl_headers
157+
${CLI11_headerLoc}/impl/App_inl.hpp
158+
${CLI11_headerLoc}/impl/Config_inl.hpp
159+
${CLI11_headerLoc}/impl/Formatter_inl.hpp
160+
${CLI11_headerLoc}/impl/Option_inl.hpp
161+
${CLI11_headerLoc}/impl/Split_inl.hpp
162+
${CLI11_headerLoc}/impl/StringTools_inl.hpp
163+
${CLI11_headerLoc}/impl/Validators_inl.hpp
164+
${CLI11_headerLoc}/impl/Encoding_inl.hpp
165+
${CLI11_headerLoc}/impl/Argv_inl.hpp)
166+
167+
set(CLI11_library_headers ${CLI11_headerLoc}/CLI.hpp ${CLI11_headerLoc}/Timer.hpp)
168+
135169
# build the fuzzing example or fuzz entry point
136170
add_subdirectory(fuzz)
137171

138172
add_subdirectory(src)
173+
add_subdirectory(single-include)
139174

140175
# Allow tests to be run on CUDA
141176
if(CLI11_CUDA_TESTS)

cmake/CLIsingle.hpp.in

Lines changed: 0 additions & 10 deletions
This file was deleted.

single-include/CMakeLists.txt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
if(CLI11_SINGLE_FILE)
2+
# Single file test
3+
if(CMAKE_VERSION VERSION_LESS 3.12)
4+
find_package(PythonInterp REQUIRED)
5+
add_executable(Python::Interpreter IMPORTED)
6+
set_target_properties(Python::Interpreter PROPERTIES IMPORTED_LOCATION "${PYTHON_EXECUTABLE}"
7+
VERSION "${PYTHON_VERSION_STRING}")
8+
else()
9+
find_package(
10+
Python
11+
COMPONENTS Interpreter
12+
REQUIRED)
13+
endif()
14+
15+
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/single-include")
16+
add_custom_command(
17+
OUTPUT "${PROJECT_BINARY_DIR}/single-include/CLI11.hpp"
18+
COMMAND
19+
Python::Interpreter "${PROJECT_SOURCE_DIR}/scripts/MakeSingleHeader.py" ${CLI11_headers}
20+
${CLI11_impl_headers} --main "${PROJECT_SOURCE_DIR}/CLI11.hpp.in" --output
21+
"${PROJECT_BINARY_DIR}/single-include/CLI11.hpp" --version "${CLI11_VERSION}"
22+
DEPENDS "${PROJECT_SOURCE_DIR}/include/CLI/CLI.hpp" ${CLI11_headers} ${CLI11_impl_headers})
23+
add_custom_target(CLI11-generate-single-file ALL
24+
DEPENDS "${PROJECT_BINARY_DIR}/single-include/CLI11.hpp")
25+
set_property(TARGET CLI11-generate-single-file PROPERTY FOLDER "Scripts")
26+
if(CLI11_INSTALL)
27+
install(FILES "${PROJECT_BINARY_DIR}/single-include/CLI11.hpp"
28+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
29+
endif()
30+
add_library(CLI11_SINGLE INTERFACE)
31+
target_link_libraries(CLI11_SINGLE INTERFACE CLI11)
32+
add_dependencies(CLI11_SINGLE CLI11-generate-single-file)
33+
target_compile_definitions(CLI11_SINGLE INTERFACE -DCLI11_SINGLE_FILE)
34+
target_include_directories(
35+
CLI11_SINGLE INTERFACE $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/single-include/>
36+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
37+
endif()

src/CMakeLists.txt

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,3 @@
1-
set(CLI11_headerLoc "${PROJECT_SOURCE_DIR}/include/CLI")
2-
3-
set(CLI11_headers
4-
${CLI11_headerLoc}/App.hpp
5-
${CLI11_headerLoc}/Config.hpp
6-
${CLI11_headerLoc}/ConfigFwd.hpp
7-
${CLI11_headerLoc}/Error.hpp
8-
${CLI11_headerLoc}/Formatter.hpp
9-
${CLI11_headerLoc}/FormatterFwd.hpp
10-
${CLI11_headerLoc}/Macros.hpp
11-
${CLI11_headerLoc}/Option.hpp
12-
${CLI11_headerLoc}/Split.hpp
13-
${CLI11_headerLoc}/StringTools.hpp
14-
${CLI11_headerLoc}/TypeTools.hpp
15-
${CLI11_headerLoc}/Validators.hpp
16-
${CLI11_headerLoc}/Version.hpp
17-
${CLI11_headerLoc}/Encoding.hpp
18-
${CLI11_headerLoc}/Argv.hpp)
19-
20-
set(CLI11_implLoc "${PROJECT_SOURCE_DIR}/include/CLI/impl")
21-
22-
set(CLI11_impl_headers
23-
${CLI11_implLoc}/App_inl.hpp
24-
${CLI11_implLoc}/Config_inl.hpp
25-
${CLI11_implLoc}/Formatter_inl.hpp
26-
${CLI11_implLoc}/Option_inl.hpp
27-
${CLI11_implLoc}/Split_inl.hpp
28-
${CLI11_implLoc}/StringTools_inl.hpp
29-
${CLI11_implLoc}/Validators_inl.hpp
30-
${CLI11_implLoc}/Encoding_inl.hpp
31-
${CLI11_implLoc}/Argv_inl.hpp)
32-
33-
set(CLI11_library_headers ${CLI11_headerLoc}/CLI.hpp ${CLI11_headerLoc}/Timer.hpp)
34-
351
if(CLI11_PRECOMPILED)
362
# Create static lib
373
file(GLOB CLI11_precompile_sources "${PROJECT_SOURCE_DIR}/src/*.cpp")
@@ -84,48 +50,6 @@ if(CMAKE_CXX_STANDARD LESS 14)
8450
endif()
8551
endif()
8652

87-
if(CLI11_SINGLE_FILE)
88-
# Single file test
89-
if(CMAKE_VERSION VERSION_LESS 3.12)
90-
find_package(PythonInterp REQUIRED)
91-
add_executable(Python::Interpreter IMPORTED)
92-
set_target_properties(Python::Interpreter PROPERTIES IMPORTED_LOCATION "${PYTHON_EXECUTABLE}"
93-
VERSION "${PYTHON_VERSION_STRING}")
94-
else()
95-
find_package(
96-
Python
97-
COMPONENTS Interpreter
98-
REQUIRED)
99-
endif()
100-
101-
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/include")
102-
add_custom_command(
103-
OUTPUT "${PROJECT_BINARY_DIR}/include/CLI11.hpp"
104-
COMMAND
105-
Python::Interpreter "${PROJECT_SOURCE_DIR}/scripts/MakeSingleHeader.py" ${CLI11_headers}
106-
${CLI11_impl_headers} --main "${PROJECT_SOURCE_DIR}/CLI11.hpp.in" --output
107-
"${PROJECT_BINARY_DIR}/include/CLI11.hpp" --version "${CLI11_VERSION}"
108-
DEPENDS "${PROJECT_SOURCE_DIR}/include/CLI/CLI.hpp" ${CLI11_headers} ${CLI11_impl_headers})
109-
add_custom_target(CLI11-generate-single-file ALL
110-
DEPENDS "${PROJECT_BINARY_DIR}/include/CLI11.hpp")
111-
set_property(TARGET CLI11-generate-single-file PROPERTY FOLDER "Scripts")
112-
if(CLI11_INSTALL)
113-
install(FILES "${PROJECT_BINARY_DIR}/include/CLI11.hpp"
114-
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
115-
configure_file("${CLI11_SOURCE_DIR}/cmake/CLIsingle.hpp.in"
116-
"${PROJECT_BINARY_DIR}/include/CLI/CLI.hpp" @ONLY)
117-
install(FILES "${PROJECT_BINARY_DIR}/include/CLI/CLI.hpp"
118-
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/CLI)
119-
endif()
120-
add_library(CLI11_SINGLE INTERFACE)
121-
target_link_libraries(CLI11_SINGLE INTERFACE CLI11)
122-
add_dependencies(CLI11_SINGLE CLI11-generate-single-file)
123-
target_compile_definitions(CLI11_SINGLE INTERFACE -DCLI11_SINGLE_FILE)
124-
target_include_directories(
125-
CLI11_SINGLE INTERFACE $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include/>
126-
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
127-
endif()
128-
12953
if(CLI11_INSTALL)
13054

13155
# Make an export target

tests/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ foreach(DATA_FILE IN LISTS DATA_FILES)
118118
endforeach()
119119
add_custom_target(cli11_test_data DEPENDS ${DATA_FILES})
120120

121+
# Make a shim if we are building single file tests
122+
if(CLI11_SINGLE_FILE AND CLI11_INSTALL_PACKAGE_TESTS)
123+
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_single/CLI/CLI.hpp" "#include <CLI11.hpp>")
124+
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/test_single/CLI/CLI.hpp" DESTINATION include/CLI)
125+
endif()
126+
121127
# Build dependent applications which are launched from test code
122128
set(CLI11_DEPENDENT_APPLICATIONS ensure_utf8 ensure_utf8_twice)
123129

0 commit comments

Comments
 (0)