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

feat: precompiled all #762

Merged
merged 14 commits into from
Aug 23, 2022
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
4 changes: 4 additions & 0 deletions .ci/azure-build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
steps:
# Needed on GCC 4.8 docker image for some reason
- script: mkdir build
displalyName: "Make build directory"

- task: CMake@1
inputs:
cmakeArgs:
Expand Down
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# modernize-avoid-c-arrays trips up in TEMPLATE_TEST_CASE catch macro
# modernize-return-braced-init-list triggers on lambdas ?
# modernize-make-unique requires C++14
# readability-avoid-const-params-in-decls Affected by the pre-compile split

Checks: |
*bugprone*,
Expand Down Expand Up @@ -39,7 +40,6 @@ Checks: |
*performance*,
-performance-unnecessary-value-param,
-performance-inefficient-string-concatenation,
readability-avoid-const-params-in-decls,
readability-const-return-type,
readability-container-size-empty,
readability-delete-null-pointer,
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
strategy:
matrix:
std: ["11", "14", "17", "20"]
precompile: ["ON", "OFF"]
steps:
- uses: actions/checkout@v3

Expand All @@ -33,6 +34,7 @@ jobs:
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
-DCLI11_SINGLE_FILE_TESTS=OFF \
-DCLI11_EXAMPLES=OFF \
-DCLI11_PRECOMPILED=${{matrix.precompile}} \
-DCMAKE_BUILD_TYPE=Coverage

- name: Build
Expand Down
34 changes: 17 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,23 @@ repos:
- id: markdownlint
args: ["--style=scripts/mdlint_style.rb"]

- repo: local
hooks:
- id: remarklint
name: remarklint
language: node
entry: remark
types: [markdown]
args: ["--frail", "--quiet"]
additional_dependencies:
[
remark,
remark-lint,
remark-cli,
remark-preset-lint-recommended,
remark-lint-list-item-indent,
remark-lint-no-undefined-references,
]
# - repo: local
# hooks:
# - id: remarklint
# name: remarklint
# language: node
# entry: remark
# types: [markdown]
# args: ["--frail", "--quiet"]
# additional_dependencies:
# [
# remark,
# remark-lint,
# remark-cli,
# remark-preset-lint-recommended,
# remark-lint-list-item-indent,
# remark-lint-no-undefined-references,
# ]

- repo: local
hooks:
Expand Down
14 changes: 14 additions & 0 deletions CLI11.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,38 @@ namespace {namespace} {{

{string_tools_hpp}

{string_tools_inl_hpp}

{error_hpp}

{type_tools_hpp}

{split_hpp}

{split_inl_hpp}

{config_fwd_hpp}

{validators_hpp}

{validators_inl_hpp}

{formatter_fwd_hpp}

{option_hpp}

{option_inl_hpp}

{app_hpp}

{app_inl_hpp}

{config_hpp}

{config_inl_hpp}

{formatter_hpp}

{formatter_inl_hpp}

}} // namespace {namespace}
54 changes: 39 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ endif()

option(CLI11_WARNINGS_AS_ERRORS "Turn all warnings into errors (for CI)")
option(CLI11_SINGLE_FILE "Generate a single header file")
option(CLI11_PRECOMPILED "Generate a precompiled static library instead of a header-only" OFF)
cmake_dependent_option(CLI11_SANITIZERS "Download the sanitizers CMake config" OFF
"NOT CMAKE_VERSION VERSION_LESS 3.11" OFF)

Expand Down Expand Up @@ -105,6 +106,11 @@ 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)
# Sanity check
message(FATAL_ERROR "CLI11_PRECOMPILE and CLI11_SINGLE_FILE are mutually exclusive")
endif()

if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
endif()
Expand Down Expand Up @@ -160,13 +166,35 @@ if(NOT CMAKE_VERSION VERSION_LESS 3.13)
target_link_options(CLI11_warnings INTERFACE $<$<BOOL:${CLI11_FORCE_LIBCXX}>:-stdlib=libc++>)
endif()

# To see in IDE, headers must be listed for target
set(MAYBE_CONFIGURE_DEPENDS "")
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND NOT CMAKE_VERSION VERSION_LESS 3.12)
list(INSERT MAYBE_CONFIGURE_DEPENDS 0 CONFIGURE_DEPENDS)
endif()

file(GLOB CLI11_headers ${MAYBE_CONFIGURE_DEPENDS} "${PROJECT_SOURCE_DIR}/include/CLI/*.hpp")
file(GLOB CLI11_impl_headers ${MAYBE_CONFIGURE_DEPENDS}
"${PROJECT_SOURCE_DIR}/include/CLI/impl/*.hpp")

if(CLI11_PRECOMPILED)
# Create static lib
file(GLOB CLI11_precompile_sources "${PROJECT_SOURCE_DIR}/src/*.cpp")
add_library(CLI11 STATIC ${CLI11_headers} ${CLI11_impl_headers} ${CLI11_precompile_sources})
target_compile_definitions(CLI11 PUBLIC -DCLI11_COMPILE)

set(PUBLIC_OR_INTERFACE PUBLIC)
else()
add_library(CLI11 INTERFACE)
set(PUBLIC_OR_INTERFACE INTERFACE)
endif()

# Allow IDE's to group targets into folders
add_library(CLI11 INTERFACE)
add_library(CLI11::CLI11 ALIAS CLI11) # for add_subdirectory calls

# Duplicated because CMake adds the current source dir if you don't.
target_include_directories(CLI11 INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
target_include_directories(
CLI11 ${PUBLIC_OR_INTERFACE} $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)

if(CMAKE_VERSION VERSION_LESS 3.8)
# This might not be a complete list
Expand All @@ -184,14 +212,6 @@ else()
target_compile_features(CLI11 INTERFACE cxx_std_11)
endif()

# To see in IDE, headers must be listed for target
set(header-patterns "${PROJECT_SOURCE_DIR}/include/CLI/*")
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND NOT CMAKE_VERSION VERSION_LESS 3.12)
list(INSERT header-patterns 0 CONFIGURE_DEPENDS)
endif()

file(GLOB CLI11_headers ${header-patterns})

# Allow tests to be run on CUDA
if(CLI11_CUDA_TESTS)
enable_language(CUDA)
Expand All @@ -202,7 +222,10 @@ endif()

# This folder should be installed
if(CLI11_INSTALL)
install(DIRECTORY "${PROJECT_SOURCE_DIR}/include/" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
install(FILES ${CLI11_headers} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/CLI")
if(NOT CLI11_COMPILE)
install(FILES ${CLI11_impl_headers} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/CLI/impl")
endif()

# Make an export target
install(TARGETS CLI11 EXPORT CLI11Targets)
Expand Down Expand Up @@ -257,9 +280,10 @@ if(CLI11_SINGLE_FILE)
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/include/CLI11.hpp"
COMMAND
Python::Interpreter "${CMAKE_CURRENT_SOURCE_DIR}/scripts/MakeSingleHeader.py"
${CLI11_headers} --main "${CMAKE_CURRENT_SOURCE_DIR}/CLI11.hpp.in" --output
"${CMAKE_CURRENT_BINARY_DIR}/include/CLI11.hpp" --version "${CLI11_VERSION}"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/include/CLI/CLI.hpp" ${CLI11_headers})
${CLI11_headers} ${CLI11_impl_headers} --main "${CMAKE_CURRENT_SOURCE_DIR}/CLI11.hpp.in"
--output "${CMAKE_CURRENT_BINARY_DIR}/include/CLI11.hpp" --version "${CLI11_VERSION}"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/include/CLI/CLI.hpp" ${CLI11_headers}
${CLI11_impl_headers})
add_custom_target(CLI11-generate-single-file ALL
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/include/CLI11.hpp")
set_property(TARGET CLI11-generate-single-file PROPERTY FOLDER "Scripts")
Expand Down
12 changes: 12 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ variables:
cli11.std: 14
cli11.build_type: Debug
cli11.options: -DCLI11_EXAMPLES_JSON=ON
cli11.precompile: OFF
CMAKE_BUILD_PARALLEL_LEVEL: 4

jobs:
Expand All @@ -33,15 +34,26 @@ jobs:
matrix:
Linux14:
vmImage: "ubuntu-latest"
Linux14PC:
vmImage: "ubuntu-latest"
cli11.precompile: ON
macOS17:
vmImage: "macOS-latest"
cli11.std: 17
macOS11:
vmImage: "macOS-latest"
cli11.std: 11
macOS11PC:
vmImage: "macOS-latest"
cli11.std: 11
cli11.precompile: ON
Windows17:
vmImage: "windows-2019"
cli11.std: 17
Windows17PC:
vmImage: "windows-2019"
cli11.std: 17
cli11.precompile: ON
Windows11:
vmImage: "windows-2019"
cli11.std: 11
Expand Down
Loading