Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: move single file to own folder #1030

Merged
merged 3 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
35 changes: 35 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 0 additions & 10 deletions cmake/CLIsingle.hpp.in

This file was deleted.

37 changes: 37 additions & 0 deletions single-include/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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 $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/single-include/>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
endif()
76 changes: 0 additions & 76 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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")
Expand Down Expand Up @@ -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 $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include/>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
endif()

if(CLI11_INSTALL)

# Make an export target
Expand Down
6 changes: 6 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 <CLI11.hpp>")
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)

Expand Down
Loading