chore: move single file to own folder (#1030)

See https://github.com/CLIUtils/CLI11/pull/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>
This commit is contained in:
Henry Schreiner
2024-05-01 12:02:16 -04:00
committed by GitHub
parent 9ee42deb29
commit bd6462f62f
6 changed files with 80 additions and 93 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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"

View File

@@ -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()

View File

@@ -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 $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include/>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
endif()
if(CLI11_INSTALL)
# Make an export target

View File

@@ -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)