From 0e1e16fa6507a36e858501819ea2a39d2de266e1 Mon Sep 17 00:00:00 2001 From: Henry Fredrick Schreiner Date: Sat, 11 May 2019 16:41:54 +0200 Subject: [PATCH 01/14] build-testing better supported --- CHANGELOG.md | 3 ++- CMakeLists.txt | 25 ++++++++++++++++++------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bbdc1b39e..0ec5edc33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ Set handling has been completely replaced by a new backend that works as a Valid * Cleanup for shadow warnings [#232] * Better alignment on multiline descriptions [#269] * Better support for aarch64 [#266] +* Respect `BUILD_TESTING` only if CLI11 is the main project; otherwise, `CLI11_TESTING` must be used > ### Converting from CLI11 1.7: > @@ -85,7 +86,7 @@ Passing the same subcommand multiple times is better supported. Several new feat * Parsing is now done in phases: `shortcurcuits`, `ini`, `env`, `callbacks`, and `requirements`; all subcommands complete a phase before moving on. [#179] * Calling parse multiple times is now officially supported without `clear` (automatic). [#179] * Dropped the mostly undocumented `short_circuit` property, as help flag parsing is a bit more complex, and the default callback behavior of options now works properly. [#179] -* Use the standard `BUILD_TESTING` over `CLI11_TESTING` if defined (`CLI11_TESTING` may eventually be removed) [#183] +* Use the standard `BUILD_TESTING` over `CLI11_TESTING` if defined [#183] * Cleanup warnings [#191] * Remove deprecated names: `set_footer`, `set_name`, `set_callback`, and `set_type_name`. Use without the `set_` instead. [#192] diff --git a/CMakeLists.txt b/CMakeLists.txt index 6dc6df558..ff99a9071 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -149,14 +149,25 @@ if(CLI11_SINGLE_FILE) target_include_directories(CLI11_SINGLE INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/include/") endif() -cmake_dependent_option(CLI11_SINGLE_FILE_TESTS "Duplicate all the tests for a single file build" OFF "CLI11_SINGLE_FILE" OFF) - -cmake_dependent_option(CLI11_TESTING "Build the tests and add them" ON "CUR_PROJ" OFF) -if(DEFINED BUILD_TESTING) - cmake_dependent_option(CLI11_TESTING "" ON "BUILD_TESTING" OFF) - message(STATUS "BUILD_TESTING is defined and it supersedes CLI11_TESTING. Has forced to ${CLI11_TESTING}") +cmake_dependent_option(CLI11_SINGLE_FILE_TESTS + "Duplicate all the tests for a single file build" + OFF + "CLI11_SINGLE_FILE" + OFF) + +cmake_dependent_option(CLI11_TESTING + "Build the tests and add them (BUILD_TESTING also works if this is the main project)" + ON + "CUR_PROJ" + OFF) + +if(DEFINED BUILD_TESTING AND CUR_PROJ) + set(CLI11_TESTING_INTERNAL ON) +else() + set(CLI11_TESTING_INTERNAL "${CLI11_TESTING}") endif() -if(CLI11_TESTING) + +if(CLI11_TESTING_INTERNAL) enable_testing() add_subdirectory(tests) endif() From e4e5d6f7e63443ef610d9fe8ba16492eeb013244 Mon Sep 17 00:00:00 2001 From: Henry Fredrick Schreiner Date: Sat, 11 May 2019 16:49:36 +0200 Subject: [PATCH 02/14] Add formatting to Azure --- .editorconfig | 2 ++ azure-pipelines.yml | 9 +++++++++ scripts/check_style_docker.sh | 4 ++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.editorconfig b/.editorconfig index 35463abd0..979b04950 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,3 +7,5 @@ insert_final_newline = true end_of_line = lf trim_trailing_whitespace = true +[*.yml] +indent_size = 2 diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 328bbc3e3..69dd377a9 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -7,6 +7,13 @@ trigger: - master jobs: +- job: ClangFormat + pool: + vmImage: 'ubuntu-16.04' + steps: + - script: scripts/check_style_docker.sh + displayName: Check format + - job: Linux pool: vmImage: 'ubuntu-16.04' @@ -24,3 +31,5 @@ jobs: vmImage: 'vs2017-win2016' steps: - template: .ci/azure-steps.yml + + diff --git a/scripts/check_style_docker.sh b/scripts/check_style_docker.sh index 9030dc51e..d0ba21ba7 100755 --- a/scripts/check_style_docker.sh +++ b/scripts/check_style_docker.sh @@ -5,8 +5,8 @@ CLANG_FORMAT=saschpe/clang-format:5.0.1 set -evx -docker run --rm -it ${CLANG_FORMAT} --version -docker run --rm -it -v "$(pwd)":/workdir -w /workdir ${CLANG_FORMAT} -style=file -sort-includes -i $(git ls-files -- '*.cpp' '*.hpp') +docker run --rm ${CLANG_FORMAT} --version +docker run --rm -v "$(pwd)":/workdir -w /workdir ${CLANG_FORMAT} -style=file -sort-includes -i $(git ls-files -- '*.cpp' '*.hpp') git diff --exit-code --color From fc835ad3b64918ab75aeb02cd1d68c873ea6e569 Mon Sep 17 00:00:00 2001 From: Henry Fredrick Schreiner Date: Sat, 11 May 2019 20:28:26 +0200 Subject: [PATCH 03/14] Adding more jobs to Azure --- azure-pipelines.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 69dd377a9..3e196710b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -32,4 +32,26 @@ jobs: steps: - template: .ci/azure-steps.yml +- job: Docker + pool: + vmImage: 'ubuntu-16.04' + strategy: + matrix: + gcc9: + containerImage: gcc:9 + gcc4.7: + containerImage: gcc:4.7 + clang3.5: + containerImage: silkeh/clang:3.5 + clang8: + containerImage: silkeh/clang:8 + container: $[ variables['containerImage'] ] + steps: + - script: | + mkdir $HOME/cmake + wget -qO- "https://cmake.org/files/v3.14/cmake-3.14.3-Linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C $HOME/cmake + displayName: Install CMake + - bash: echo "##vso[task.prependpath]$HOME/cmake/bin" + displayName: Add CMake to PATH + - template: .ci/azure-steps.yml From b92d2939e94ee9d1ce6fd5fc8dca412f333757da Mon Sep 17 00:00:00 2001 From: Henry Fredrick Schreiner Date: Sat, 11 May 2019 22:48:24 +0200 Subject: [PATCH 04/14] Control --- .ci/azure-steps.yml | 8 ++----- azure-pipelines.yml | 54 ++++++++++++++++++++++++++++----------------- 2 files changed, 36 insertions(+), 26 deletions(-) diff --git a/.ci/azure-steps.yml b/.ci/azure-steps.yml index 3ac2b35c4..c6a9d875f 100644 --- a/.ci/azure-steps.yml +++ b/.ci/azure-steps.yml @@ -1,18 +1,14 @@ steps: -- checkout: self - fetchDepth: 50 - submodules: true - - task: CMake@1 inputs: - cmakeArgs: .. -DCLI12_SINGLE_FILE=ON -DCLI11_CXX_STD=14 -DCLI11_SINGLE_FILE_TESTS=ON -DCMAKE_BUILD_TYPE=Debug + cmakeArgs: .. -DCLI11_SINGLE_FILE=$(cli11.single) -DCLI11_CXX_STD=$(cli11.std) -DCLI11_SINGLE_FILE_TESTS=$(cli11.single) -DCMAKE_BUILD_TYPE=$(cli11.build_type) displayName: 'Configure' - script: cmake --build . -j displayName: 'Build' workingDirectory: build -- script: ctest --output-on-failure -C Debug +- script: ctest --output-on-failure -C $(cli11.build_type) displayName: 'Test' workingDirectory: build diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 3e196710b..015f2957f 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -6,7 +6,13 @@ trigger: - master +variables: + cli11.single: ON + cli11.std: 14 + cli11.build_type: Debug + jobs: + - job: ClangFormat pool: vmImage: 'ubuntu-16.04' @@ -14,44 +20,52 @@ jobs: - script: scripts/check_style_docker.sh displayName: Check format -- job: Linux - pool: - vmImage: 'ubuntu-16.04' - steps: - - template: .ci/azure-steps.yml - -- job: macOS - pool: - vmImage: 'macOS-10.13' - steps: - - template: .ci/azure-steps.yml - -- job: Windows +- job: Native + strategy: + matrix: + Linux: + vmImage: 'ubuntu-16.04' + macOS: + vmImage: 'macOS-10.14' + Windows: + vmImage: 'vs2017-win2016' pool: - vmImage: 'vs2017-win2016' + vmImage: $(vmImage) steps: - template: .ci/azure-steps.yml - job: Docker + variables: + cli11.single: OFF pool: vmImage: 'ubuntu-16.04' strategy: matrix: gcc9: containerImage: gcc:9 + cli11.std: 17 gcc4.7: containerImage: gcc:4.7 - clang3.5: - containerImage: silkeh/clang:3.5 + cli11.std: 11 + clang3.4: + containerImage: silkeh/clang:3.4 + cli11.std: 11 clang8: containerImage: silkeh/clang:8 + cli11.std: 14 container: $[ variables['containerImage'] ] steps: + # Note that silkeh/clang does not include ca-certificates, so check the shasum for verification - script: | - mkdir $HOME/cmake - wget -qO- "https://cmake.org/files/v3.14/cmake-3.14.3-Linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C $HOME/cmake - displayName: Install CMake - - bash: echo "##vso[task.prependpath]$HOME/cmake/bin" + wget --no-check-certificate "https://cmake.org/files/v3.14/cmake-3.14.3-Linux-x86_64.tar.gz" + echo "29faa62fb3a0b6323caa3d9557e1a5f1205614c0d4c5c2a9917f16a74f7eff68 cmake-3.14.3-Linux-x86_64.tar.gz" | shasum -sca 256 + displayName: Download CMake + - task: ExtractFiles@1 + inputs: + archiveFilePatterns: 'cmake*.tar.gz' + destinationFolder: 'cmake_program' + displayName: Extract CMake + - bash: echo "##vso[task.prependpath]$(Build.SourcesDirectory)/cmake_program/cmake-3.14.3-Linux-x86_64/bin" displayName: Add CMake to PATH - template: .ci/azure-steps.yml From e6e014ce2bab94bef52babbfe10c154977993c2c Mon Sep 17 00:00:00 2001 From: Henry Fredrick Schreiner Date: Sun, 12 May 2019 08:40:50 +0200 Subject: [PATCH 05/14] Allow libc++ to be used on linux --- .ci/azure-steps.yml | 2 +- CMakeLists.txt | 9 +++++++++ azure-pipelines.yml | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.ci/azure-steps.yml b/.ci/azure-steps.yml index c6a9d875f..f4665c71f 100644 --- a/.ci/azure-steps.yml +++ b/.ci/azure-steps.yml @@ -2,7 +2,7 @@ steps: - task: CMake@1 inputs: - cmakeArgs: .. -DCLI11_SINGLE_FILE=$(cli11.single) -DCLI11_CXX_STD=$(cli11.std) -DCLI11_SINGLE_FILE_TESTS=$(cli11.single) -DCMAKE_BUILD_TYPE=$(cli11.build_type) + cmakeArgs: .. -DCLI11_SINGLE_FILE=$(cli11.single) -DCLI11_CXX_STD=$(cli11.std) -DCLI11_SINGLE_FILE_TESTS=$(cli11.single) -DCMAKE_BUILD_TYPE=$(cli11.build_type) $(cli11.options) displayName: 'Configure' - script: cmake --build . -j diff --git a/CMakeLists.txt b/CMakeLists.txt index ff99a9071..315ea3e9e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,15 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) # User settable set(CLI11_CXX_STD "11" CACHE STRING "The CMake standard to require") + # Special override for Clang on Linux (useful with an old stdlibc++ and a newer clang) + if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + option(CLI11_FORCE_LIBCXX "Force Clang to use libc++ instead of libstdc++ (Linux only)" OFF) + if(CLI11_FORCE_LIBCXX) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++abi") + endif() + endif() + set(CUR_PROJ ON) set(CMAKE_CXX_STANDARD ${CLI11_CXX_STD}) set(CMAKE_CXX_EXTENSIONS OFF) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 015f2957f..b93b58707 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -50,9 +50,11 @@ jobs: clang3.4: containerImage: silkeh/clang:3.4 cli11.std: 11 + cli11.options: -DCLI11_FORCE_LIBCXX=ON clang8: containerImage: silkeh/clang:8 cli11.std: 14 + cli11.options: -DCLI11_FORCE_LIBCXX=ON container: $[ variables['containerImage'] ] steps: # Note that silkeh/clang does not include ca-certificates, so check the shasum for verification From 2f4e7a9a3d80553a2a82bea112394a64f1f6d430 Mon Sep 17 00:00:00 2001 From: Henry Fredrick Schreiner Date: Sun, 12 May 2019 08:41:03 +0200 Subject: [PATCH 06/14] Fix modernize message --- include/CLI/Timer.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/CLI/Timer.hpp b/include/CLI/Timer.hpp index 61039c2cd..9b0ed8b50 100644 --- a/include/CLI/Timer.hpp +++ b/include/CLI/Timer.hpp @@ -10,6 +10,7 @@ #endif #include +#include #include #include #include @@ -86,9 +87,9 @@ class Timer { /// This prints out a time string from a time std::string make_time_str(double time) const { auto print_it = [](double x, std::string unit) { - char buffer[50]; - std::snprintf(buffer, 50, "%.5g", x); - return buffer + std::string(" ") + unit; + std::array buffer; + std::snprintf(buffer.data(), 50, "%.5g", x); + return buffer.data() + std::string(" ") + unit; }; if(time < .000001) From d8c4659d58084f0ef50616fef996711ebe2458df Mon Sep 17 00:00:00 2001 From: Henry Fredrick Schreiner Date: Sun, 12 May 2019 08:52:08 +0200 Subject: [PATCH 07/14] Fix variable --- azure-pipelines.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index b93b58707..01e73321a 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -10,6 +10,7 @@ variables: cli11.single: ON cli11.std: 14 cli11.build_type: Debug + cli11.options: jobs: From 64d8bfd9394b661545ca72a7a5ee0e18d810d0e8 Mon Sep 17 00:00:00 2001 From: Henry Fredrick Schreiner Date: Sun, 12 May 2019 09:02:09 +0200 Subject: [PATCH 08/14] fixup! Fix modernize message --- include/CLI/Timer.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/CLI/Timer.hpp b/include/CLI/Timer.hpp index 9b0ed8b50..0a82dbcff 100644 --- a/include/CLI/Timer.hpp +++ b/include/CLI/Timer.hpp @@ -9,8 +9,8 @@ #define _GLIBCXX_USE_NANOSLEEP #endif -#include #include +#include #include #include #include From 5b2819ecc284ee55643fc922467edc67048479aa Mon Sep 17 00:00:00 2001 From: Henry Fredrick Schreiner Date: Sun, 12 May 2019 11:35:34 +0200 Subject: [PATCH 09/14] Drop auto exp. optional --- CMakeLists.txt | 2 +- azure-pipelines.yml | 1 - include/CLI/Optional.hpp | 6 +----- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 315ea3e9e..7c7026087 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,7 +32,7 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) option(CLI11_FORCE_LIBCXX "Force Clang to use libc++ instead of libstdc++ (Linux only)" OFF) if(CLI11_FORCE_LIBCXX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++abi") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++") endif() endif() diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 01e73321a..a3530c853 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -51,7 +51,6 @@ jobs: clang3.4: containerImage: silkeh/clang:3.4 cli11.std: 11 - cli11.options: -DCLI11_FORCE_LIBCXX=ON clang8: containerImage: silkeh/clang:8 cli11.std: 14 diff --git a/include/CLI/Optional.hpp b/include/CLI/Optional.hpp index f3212671e..6e60fb606 100644 --- a/include/CLI/Optional.hpp +++ b/include/CLI/Optional.hpp @@ -19,11 +19,7 @@ #define CLI11_STD_OPTIONAL 0 #endif -#if defined(CLI11_CPP14) && __has_include() && \ - !defined(CLI11_EXPERIMENTAL_OPTIONAL) \ - && (!defined(CLI11_STD_OPTIONAL) || CLI11_STD_OPTIONAL == 0) -#define CLI11_EXPERIMENTAL_OPTIONAL 1 -#elif !defined(CLI11_EXPERIMENTAL_OPTIONAL) +#if !defined(CLI11_EXPERIMENTAL_OPTIONAL) #define CLI11_EXPERIMENTAL_OPTIONAL 0 #endif From 81404bb8b59e843154d0aef503763600efdff994 Mon Sep 17 00:00:00 2001 From: Henry Fredrick Schreiner Date: Mon, 13 May 2019 10:46:22 +0200 Subject: [PATCH 10/14] Update readme, better user id in docker --- CHANGELOG.md | 4 +++- README.md | 2 +- scripts/check_style_docker.sh | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ec5edc33..c5bd6b7b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,7 +21,8 @@ Set handling has been completely replaced by a new backend that works as a Valid * Cleanup for shadow warnings [#232] * Better alignment on multiline descriptions [#269] * Better support for aarch64 [#266] -* Respect `BUILD_TESTING` only if CLI11 is the main project; otherwise, `CLI11_TESTING` must be used +* Respect `BUILD_TESTING` only if CLI11 is the main project; otherwise, `CLI11_TESTING` must be used [#277] +* Drop auto-detection of experimental optional; must be enabled explicitly (too fragile) [#277] > ### Converting from CLI11 1.7: > @@ -55,6 +56,7 @@ Set handling has been completely replaced by a new backend that works as a Valid [#265]: https://github.com/CLIUtils/CLI11/pull/265 [#266]: https://github.com/CLIUtils/CLI11/pull/266 [#269]: https://github.com/CLIUtils/CLI11/pull/269 +[#277]: https://github.com/CLIUtils/CLI11/pull/277 ## Version 1.7.1: Quick patch diff --git a/README.md b/README.md index 3e4d22f14..dd7173009 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ An acceptable CLI parser library should be all of the following: - Easy to include (i.e., header only, one file if possible, **no external requirements**). - Short, simple syntax: This is one of the main reasons to use a CLI parser, it should make variables from the command line nearly as easy to define as any other variables. If most of your program is hidden in CLI parsing, this is a problem for readability. -- C++11 or better: Should work with GCC 4.8+ (default on CentOS/RHEL 7), Clang 3.5+, AppleClang 7+, NVCC 7.0+, or MSVC 2015+. +- C++11 or better: Should work with GCC 4.8+ (default on CentOS/RHEL 7), Clang 3.4+, AppleClang 7+, NVCC 7.0+, or MSVC 2015+. - Work on Linux, macOS, and Windows. - Well tested using [Travis][] (Linux) and [AppVeyor][] (Windows) or [Azure][] (all three). "Well" is defined as having good coverage measured by [CodeCov][]. - Clear help printing. diff --git a/scripts/check_style_docker.sh b/scripts/check_style_docker.sh index d0ba21ba7..3defb2406 100755 --- a/scripts/check_style_docker.sh +++ b/scripts/check_style_docker.sh @@ -1,12 +1,13 @@ #!/usr/bin/env sh # Also good but untagged: CLANG_FORMAT=unibeautify/clang-format +# This might provide more control in the future: silkeh/clang:8 (etc) CLANG_FORMAT=saschpe/clang-format:5.0.1 set -evx docker run --rm ${CLANG_FORMAT} --version -docker run --rm -v "$(pwd)":/workdir -w /workdir ${CLANG_FORMAT} -style=file -sort-includes -i $(git ls-files -- '*.cpp' '*.hpp') +docker run --rm --user $(id -u):$(id -g) -v "$(pwd)":/workdir -w /workdir ${CLANG_FORMAT} -style=file -sort-includes -i $(git ls-files -- '*.cpp' '*.hpp') git diff --exit-code --color From 78dd97ec0a47b0793ac44baa7c4cc668c8cdc7be Mon Sep 17 00:00:00 2001 From: Henry Fredrick Schreiner Date: Mon, 13 May 2019 22:03:38 +0200 Subject: [PATCH 11/14] Fix BUILD_TESTING --- CMakeLists.txt | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c7026087..8b950705b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,12 +2,13 @@ cmake_minimum_required(VERSION 3.4) # Note: this is a header only library. If you have an older CMake than 3.4, # just add the CLI11/include directory and that's all you need to do. -# Make sure users don't get warnings on a tested (3.4 to 3.13) version +# Make sure users don't get warnings on a tested (3.4 to 3.14) version # of CMake. For most of the policies, the new version is better (hence the change). -if(${CMAKE_VERSION} VERSION_LESS 3.13) +# We don't use the 3.4...3.14 syntax because of a bug in a version of MSVC +if(${CMAKE_VERSION} VERSION_LESS 3.14) cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) else() - cmake_policy(VERSION 3.13) + cmake_policy(VERSION 3.14) endif() set(VERSION_REGEX "#define CLI11_VERSION[ \t]+\"(.+)\"") @@ -164,16 +165,14 @@ cmake_dependent_option(CLI11_SINGLE_FILE_TESTS "CLI11_SINGLE_FILE" OFF) -cmake_dependent_option(CLI11_TESTING - "Build the tests and add them (BUILD_TESTING also works if this is the main project)" - ON - "CUR_PROJ" - OFF) -if(DEFINED BUILD_TESTING AND CUR_PROJ) - set(CLI11_TESTING_INTERNAL ON) -else() +if(DEFINED CLI11_TESTING) set(CLI11_TESTING_INTERNAL "${CLI11_TESTING}") +elseif(CUR_PROJ) + option(BUILD_TESTING "Build the tests" ON) + set(CLI11_TESTING_INTERNAL "${BUILD_TESTING}") +else() + set(CLI11_TESTING_INTERNAL OFF) endif() if(CLI11_TESTING_INTERNAL) From 7c1c2903f4b441f8f82af9319f76450b49cf67bd Mon Sep 17 00:00:00 2001 From: Henry Fredrick Schreiner Date: Mon, 13 May 2019 22:05:35 +0200 Subject: [PATCH 12/14] Drop format from travis, leave tidy for now --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 78e1f02f5..d640b3631 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,7 +29,6 @@ matrix: - CHECK_STYLE=yes script: - cd "${TRAVIS_BUILD_DIR}" - - scripts/check_style.sh - .ci/check_tidy.sh # Docs and clang 3.5 From 91144e6e148e541c453bc00310c4e286f8ba7255 Mon Sep 17 00:00:00 2001 From: Henry Fredrick Schreiner Date: Tue, 14 May 2019 12:17:26 +0200 Subject: [PATCH 13/14] Check tidy and format --- .ci/{azure-steps.yml => azure-build.yml} | 3 --- .ci/azure-cmake.yml | 16 ++++++++++++ .ci/azure-test.yml | 5 ++++ azure-pipelines.yml | 33 ++++++++++++------------ 4 files changed, 38 insertions(+), 19 deletions(-) rename .ci/{azure-steps.yml => azure-build.yml} (75%) create mode 100644 .ci/azure-cmake.yml create mode 100644 .ci/azure-test.yml diff --git a/.ci/azure-steps.yml b/.ci/azure-build.yml similarity index 75% rename from .ci/azure-steps.yml rename to .ci/azure-build.yml index f4665c71f..7c33bfe1a 100644 --- a/.ci/azure-steps.yml +++ b/.ci/azure-build.yml @@ -9,6 +9,3 @@ steps: displayName: 'Build' workingDirectory: build -- script: ctest --output-on-failure -C $(cli11.build_type) - displayName: 'Test' - workingDirectory: build diff --git a/.ci/azure-cmake.yml b/.ci/azure-cmake.yml new file mode 100644 index 000000000..59b6ceb32 --- /dev/null +++ b/.ci/azure-cmake.yml @@ -0,0 +1,16 @@ +steps: + +# Note that silkeh/clang does not include ca-certificates, so check the shasum for verification +- bash: | + wget --no-check-certificate "https://cmake.org/files/v3.14/cmake-3.14.3-Linux-x86_64.tar.gz" + echo "29faa62fb3a0b6323caa3d9557e1a5f1205614c0d4c5c2a9917f16a74f7eff68 cmake-3.14.3-Linux-x86_64.tar.gz" | shasum -sca 256 + displayName: Download CMake + +- task: ExtractFiles@1 + inputs: + archiveFilePatterns: 'cmake*.tar.gz' + destinationFolder: 'cmake_program' + displayName: Extract CMake + +- bash: echo "##vso[task.prependpath]$(Build.SourcesDirectory)/cmake_program/cmake-3.14.3-Linux-x86_64/bin" + displayName: Add CMake to PATH diff --git a/.ci/azure-test.yml b/.ci/azure-test.yml new file mode 100644 index 000000000..b56daa1ff --- /dev/null +++ b/.ci/azure-test.yml @@ -0,0 +1,5 @@ +steps: + +- script: ctest --output-on-failure -C $(cli11.build_type) + displayName: 'Test' + workingDirectory: build diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a3530c853..082371657 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -14,12 +14,22 @@ variables: jobs: -- job: ClangFormat +- job: ClangFormatTidy + variables: + CXX_FLAGS: "-Werror -Wcast-align -Wfloat-equal -Wimplicit-atomic-properties -Wmissing-declarations -Woverlength-strings -Wshadow -Wstrict-selector-match -Wundeclared-selector -Wunreachable-code -std=c++11" + cli11.options: -DCLANG_TIDY_FIX=ON + cli11.std: 11 + cli11.single: OFF pool: vmImage: 'ubuntu-16.04' + container: silkeh/clang:5 steps: - - script: scripts/check_style_docker.sh + - script: scripts/check_style.sh displayName: Check format + - template: .ci/azure-cmake.yml + - template: .ci/azure-build.yml + - script: git diff --exit-code --color + displayName: Check tidy - job: Native strategy: @@ -33,7 +43,8 @@ jobs: pool: vmImage: $(vmImage) steps: - - template: .ci/azure-steps.yml + - template: .ci/azure-build.yml + - template: .ci/azure-test.yml - job: Docker variables: @@ -57,17 +68,7 @@ jobs: cli11.options: -DCLI11_FORCE_LIBCXX=ON container: $[ variables['containerImage'] ] steps: - # Note that silkeh/clang does not include ca-certificates, so check the shasum for verification - - script: | - wget --no-check-certificate "https://cmake.org/files/v3.14/cmake-3.14.3-Linux-x86_64.tar.gz" - echo "29faa62fb3a0b6323caa3d9557e1a5f1205614c0d4c5c2a9917f16a74f7eff68 cmake-3.14.3-Linux-x86_64.tar.gz" | shasum -sca 256 - displayName: Download CMake - - task: ExtractFiles@1 - inputs: - archiveFilePatterns: 'cmake*.tar.gz' - destinationFolder: 'cmake_program' - displayName: Extract CMake - - bash: echo "##vso[task.prependpath]$(Build.SourcesDirectory)/cmake_program/cmake-3.14.3-Linux-x86_64/bin" - displayName: Add CMake to PATH - - template: .ci/azure-steps.yml + - template: .ci/azure-cmake.yml + - template: .ci/azure-build.yml + - template: .ci/azure-test.yml From a3113e4dd5ef863d1c14c8d62d3d7e5c2aba3702 Mon Sep 17 00:00:00 2001 From: Henry Fredrick Schreiner Date: Tue, 14 May 2019 12:35:50 +0200 Subject: [PATCH 14/14] Tidy fully on Azure now --- .ci/azure-build.yml | 2 +- .ci/check_tidy.sh | 21 --------------------- .travis.yml | 8 -------- azure-pipelines.yml | 2 ++ 4 files changed, 3 insertions(+), 30 deletions(-) delete mode 100755 .ci/check_tidy.sh diff --git a/.ci/azure-build.yml b/.ci/azure-build.yml index 7c33bfe1a..e6b37f8e8 100644 --- a/.ci/azure-build.yml +++ b/.ci/azure-build.yml @@ -5,7 +5,7 @@ steps: cmakeArgs: .. -DCLI11_SINGLE_FILE=$(cli11.single) -DCLI11_CXX_STD=$(cli11.std) -DCLI11_SINGLE_FILE_TESTS=$(cli11.single) -DCMAKE_BUILD_TYPE=$(cli11.build_type) $(cli11.options) displayName: 'Configure' -- script: cmake --build . -j +- script: cmake --build . $(cli11.threadopt) displayName: 'Build' workingDirectory: build diff --git a/.ci/check_tidy.sh b/.ci/check_tidy.sh deleted file mode 100755 index 505b68eb9..000000000 --- a/.ci/check_tidy.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env bash - -echo -en "travis_fold:start:script.build\\r" -echo "Building with tidy on..." -set -evx - -mkdir -p build-tidy -cd build-tidy -CXX_FLAGS="-Werror -Wcast-align -Wfloat-equal -Wimplicit-atomic-properties -Wmissing-declarations -Woverlength-strings -Wshadow -Wstrict-selector-match -Wundeclared-selector -Wunreachable-code -std=c++11" cmake .. -DCLANG_TIDY_FIX=ON -cmake --build . - -set -evx -echo -en "travis_fold:end:script.build\\r" -echo -en "travis_fold:start:script.compare\\r" -echo "Checking git diff..." -set -evx - -git diff --exit-code --color - -set +evx -echo -en "travis_fold:end:script.compare\\r" diff --git a/.travis.yml b/.travis.yml index d640b3631..fb7d17ff7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,14 +23,6 @@ matrix: - .ci/make_and_test.sh 14 - .ci/make_and_test.sh 17 - # Check style/tidy - - compiler: clang - env: - - CHECK_STYLE=yes - script: - - cd "${TRAVIS_BUILD_DIR}" - - .ci/check_tidy.sh - # Docs and clang 3.5 - compiler: clang env: diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 082371657..0c2f5bafb 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -11,6 +11,7 @@ variables: cli11.std: 14 cli11.build_type: Debug cli11.options: + cli11.threadopt: -j jobs: @@ -20,6 +21,7 @@ jobs: cli11.options: -DCLANG_TIDY_FIX=ON cli11.std: 11 cli11.single: OFF + cli11.threadopt: pool: vmImage: 'ubuntu-16.04' container: silkeh/clang:5