Skip to content

Commit 35aa92d

Browse files
update supported cmake versions and add some tests with newer compilers (#972)
Update and test with some newer compilers and cmake versions --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 9dfeefe commit 35aa92d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+416
-356
lines changed

.ci/azure-cmake-new.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
steps:
2+
# Note that silkeh/clang does not include ca-certificates, so check the shasum for verification
3+
- bash: |
4+
wget --no-check-certificate "https://cmake.org/files/v3.28/cmake-3.28.0-linux-x86_64.tar.gz"
5+
echo "898f0b5ca6e2ea5286998e97bd33f030d7d09f18ca4b88be661fdfbad5dadd88 cmake-3.28.0-linux-x86_64.tar.gz" | shasum -sca 256
6+
displayName: Download CMake
7+
8+
- task: ExtractFiles@1
9+
inputs:
10+
archiveFilePatterns: "cmake*.tar.gz"
11+
destinationFolder: "cmake_program"
12+
displayName: Extract CMake
13+
14+
- bash:
15+
echo
16+
"##vso[task.prependpath]$(Build.SourcesDirectory)/cmake_program/cmake-3.28.0-linux-x86_64/bin"
17+
displayName: Add CMake to PATH

.clang-tidy

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# modernize-avoid-c-arrays trips up in TEMPLATE_TEST_CASE catch macro
77
# modernize-return-braced-init-list triggers on lambdas ?
88
# modernize-make-unique requires C++14
9+
# modernize-type_traits requires C++17
910
# readability-avoid-const-params-in-decls Affected by the pre-compile split
1011

1112
Checks: |
@@ -37,6 +38,8 @@ Checks: |
3738
-modernize-concat-nested-namespaces,
3839
-modernize-return-braced-init-list,
3940
-modernize-make-unique,
41+
-modernize-type-traits,
42+
-modernize-macro-to-enum,
4043
*performance*,
4144
-performance-unnecessary-value-param,
4245
-performance-inefficient-string-concatenation,

.github/workflows/tests.yml

+9-3
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
clang-tidy:
6161
name: Clang-Tidy
6262
runs-on: ubuntu-latest
63-
container: silkeh/clang:14
63+
container: silkeh/clang:17
6464
steps:
6565
- uses: actions/checkout@v4
6666

@@ -91,7 +91,7 @@ jobs:
9191
cuda12-build:
9292
name: CUDA 12 build only
9393
runs-on: ubuntu-latest
94-
container: nvidia/cuda:12.1.0-devel-ubuntu22.04
94+
container: nvidia/cuda:12.3.1-devel-ubuntu22.04
9595
steps:
9696
- name: Add build tools
9797
run: apt-get update && apt-get install -y wget git cmake
@@ -336,9 +336,15 @@ jobs:
336336
args: -DCLI11_SANITIZERS=ON -DCLI11_BUILD_EXAMPLES_JSON=ON
337337
if: success() || failure()
338338

339-
- name: Check CMake 3.27 (full)
339+
- name: Check CMake 3.27
340340
uses: ./.github/actions/quick_cmake
341341
with:
342342
cmake-version: "3.27"
343+
if: success() || failure()
344+
345+
- name: Check CMake 3.28 (full)
346+
uses: ./.github/actions/quick_cmake
347+
with:
348+
cmake-version: "3.28"
343349
args: -DCLI11_SANITIZERS=ON -DCLI11_BUILD_EXAMPLES_JSON=ON
344350
if: success() || failure()

CMakeLists.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ cmake_minimum_required(VERSION 3.5)
22
# Note: this is a header only library. If you have an older CMake than 3.5,
33
# just add the CLI11/include directory and that's all you need to do.
44

5-
# Make sure users don't get warnings on a tested (3.5 to 3.26) version
5+
# Make sure users don't get warnings on a tested (3.5 to 3.28) version
66
# of CMake. For most of the policies, the new version is better (hence the change).
7-
# We don't use the 3.5...3.26 syntax because of a bug in an older MSVC's
7+
# We don't use the 3.5...3.28 syntax because of a bug in an older MSVC's
88
# built-in and modified CMake 3.11
9-
if(${CMAKE_VERSION} VERSION_LESS 3.26)
9+
if(${CMAKE_VERSION} VERSION_LESS 3.28)
1010
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
1111
else()
12-
cmake_policy(VERSION 3.26)
12+
cmake_policy(VERSION 3.28)
1313
endif()
1414

1515
set(VERSION_REGEX "#define CLI11_VERSION[ \t]+\"(.+)\"")

azure-pipelines.yml

+25
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,28 @@ jobs:
150150
- template: .ci/azure-cmake.yml
151151
- template: .ci/azure-build.yml
152152
- template: .ci/azure-test.yml
153+
154+
- job: Docker_new
155+
variables:
156+
cli11.single: OFF
157+
pool:
158+
vmImage: "ubuntu-latest"
159+
strategy:
160+
matrix:
161+
gcc13:
162+
containerImage: gcc:13
163+
cli11.std: 17
164+
cli11.options: -DCMAKE_CXX_FLAGS="-Wstrict-overflow=5"
165+
gcc12:
166+
containerImage: gcc:12
167+
cli11.std: 20
168+
cli11.options: -DCMAKE_CXX_FLAGS="-Wredundant-decls -Wconversion"
169+
clang17_20:
170+
containerImage: silkeh/clang:17
171+
cli11.std: 23
172+
cli11.options: -DCMAKE_CXX_FLAGS=-std=c++23
173+
container: $[ variables['containerImage'] ]
174+
steps:
175+
- template: .ci/azure-cmake-new.yml
176+
- template: .ci/azure-build.yml
177+
- template: .ci/azure-test.yml

book/chapters/options.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ CLI::Option* opt = app.add_flag("--opt");
283283
CLI11_PARSE(app, argv, argc);
284284

285285
if(* opt)
286-
std::cout << "Flag received " << opt->count() << " times." << std::endl;
286+
std::cout << "Flag received " << opt->count() << " times." << '\n';
287287
```
288288
289289
## Inheritance of defaults

examples/arg_capture.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ int main(int argc, const char *argv[]) {
2525
subcom->alias("--sub");
2626
CLI11_PARSE(app, argc, argv);
2727

28-
std::cout << "value=" << value << std::endl;
28+
std::cout << "value=" << value << '\n';
2929
std::cout << "after Args:";
3030
for(const auto &aarg : subcom->remaining()) {
3131
std::cout << aarg << " ";
3232
}
33-
std::cout << std::endl;
33+
std::cout << '\n';
3434
}

examples/config_app.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ int main(int argc, char **argv) {
4040
}
4141

4242
std::cout << "Working on file: " << file << ", direct count: " << app.count("--file")
43-
<< ", opt count: " << opt->count() << std::endl;
43+
<< ", opt count: " << opt->count() << '\n';
4444
std::cout << "Working on count: " << count << ", direct count: " << app.count("--count")
45-
<< ", opt count: " << copt->count() << std::endl;
45+
<< ", opt count: " << copt->count() << '\n';
4646
std::cout << "Received flag: " << v << " (" << flag->count() << ") times\n";
47-
std::cout << "Some value: " << value << std::endl;
47+
std::cout << "Some value: " << value << '\n';
4848

4949
return 0;
5050
}

examples/custom_parse.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ using DoubleValues = Values<double>;
2323

2424
// the lexical cast operator should be in the same namespace as the type for ADL to work properly
2525
bool lexical_cast(const std::string &input, Values<double> & /*v*/) {
26-
std::cout << "called correct lexical_cast function ! val: " << input << std::endl;
26+
std::cout << "called correct lexical_cast function ! val: " << input << '\n';
2727
return true;
2828
}
2929

examples/digit_args.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ int main(int argc, char **argv) {
1616

1717
CLI11_PARSE(app, argc, argv);
1818

19-
std::cout << "value = " << val << std::endl;
19+
std::cout << "value = " << val << '\n';
2020
return 0;
2121
}

examples/enum.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ int main(int argc, char **argv) {
2727

2828
// CLI11's built in enum streaming can be used outside CLI11 like this:
2929
using CLI::enums::operator<<;
30-
std::cout << "Enum received: " << level << std::endl;
30+
std::cout << "Enum received: " << level << '\n';
3131

3232
return 0;
3333
}

examples/enum_ostream.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ int main(int argc, char **argv) {
4444

4545
// CLI11's built in enum streaming can be used outside CLI11 like this:
4646
using CLI::enums::operator<<;
47-
std::cout << "Enum received: " << level << std::endl;
47+
std::cout << "Enum received: " << level << '\n';
4848

4949
return 0;
5050
}

examples/formatter.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ int main(int argc, char **argv) {
3131

3232
CLI11_PARSE(app, argc, argv);
3333

34-
std::cout << "This app was meant to show off the formatter, run with -h" << std::endl;
34+
std::cout << "This app was meant to show off the formatter, run with -h" << '\n';
3535

3636
return 0;
3737
}

examples/groups.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ int main(int argc, char **argv) {
3030
}
3131

3232
std::cout << "Working on file: " << file << ", direct count: " << app.count("--file")
33-
<< ", opt count: " << opt->count() << std::endl;
33+
<< ", opt count: " << opt->count() << '\n';
3434
std::cout << "Working on count: " << count << ", direct count: " << app.count("--count")
35-
<< ", opt count: " << copt->count() << std::endl;
36-
std::cout << "Some value: " << value << std::endl;
35+
<< ", opt count: " << copt->count() << '\n';
36+
std::cout << "Some value: " << value << '\n';
3737

3838
return 0;
3939
}

examples/inter_argument_order.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ int main(int argc, char **argv) {
4646

4747
// Prove the vector is correct
4848
for(auto &pair : keyval) {
49-
std::cout << pair.first << " : " << pair.second << std::endl;
49+
std::cout << pair.first << " : " << pair.second << '\n';
5050
}
5151
}

examples/modhelp.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ Note that this will not shortcut `->required` and other similar options.)raw"};
2626
if(*help)
2727
throw CLI::CallForHelp();
2828
} catch(const CLI::Error &e) {
29-
std::cout << "Option -a string in help: " << some_option << std::endl;
29+
std::cout << "Option -a string in help: " << some_option << '\n';
3030
return test.exit(e);
3131
}
3232

33-
std::cout << "Option -a string: " << some_option << std::endl;
33+
std::cout << "Option -a string: " << some_option << '\n';
3434
return 0;
3535
}

examples/option_groups.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ int main(int argc, char **argv) {
3333
CLI11_PARSE(app, argc, argv);
3434

3535
std::string format_type = (csv) ? std::string("CSV") : ((human) ? "human readable" : "binary");
36-
std::cout << "Selected " << format_type << " format" << std::endl;
36+
std::cout << "Selected " << format_type << " format\n";
3737
if(!fileLoc.empty()) {
38-
std::cout << " sent to file " << fileLoc << std::endl;
38+
std::cout << " sent to file " << fileLoc << '\n';
3939
} else if(!networkAddress.empty()) {
40-
std::cout << " sent over network to " << networkAddress << std::endl;
40+
std::cout << " sent over network to " << networkAddress << '\n';
4141
} else {
42-
std::cout << " sent to std::cout" << std::endl;
42+
std::cout << " sent to std::cout\n";
4343
}
4444

4545
return 0;

examples/prefix_command.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ int main(int argc, char **argv) {
2525
for(int v : vals)
2626
std::cout << ": " << v << " ";
2727

28-
std::cout << std::endl << "Remaining commands: ";
28+
std::cout << '\n' << "Remaining commands: ";
2929

3030
for(const auto &com : more_comms)
3131
std::cout << com << " ";
32-
std::cout << std::endl;
32+
std::cout << '\n';
3333

3434
return 0;
3535
}

examples/shapes.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ int main(int argc, char **argv) {
1818
int circle_counter{0};
1919
circle->callback([&radius, &circle_counter] {
2020
++circle_counter;
21-
std::cout << "circle" << circle_counter << " with radius " << radius << std::endl;
21+
std::cout << "circle" << circle_counter << " with radius " << radius << '\n';
2222
});
2323

2424
circle->add_option("radius", radius, "the radius of the circle")->required();
@@ -32,7 +32,7 @@ int main(int argc, char **argv) {
3232
if(edge2 == 0) {
3333
edge2 = edge1;
3434
}
35-
std::cout << "rectangle" << rect_counter << " with edges [" << edge1 << ',' << edge2 << "]" << std::endl;
35+
std::cout << "rectangle" << rect_counter << " with edges [" << edge1 << ',' << edge2 << "]\n";
3636
edge2 = 0;
3737
});
3838

@@ -45,7 +45,7 @@ int main(int argc, char **argv) {
4545
tri->callback([&sides, &tri_counter] {
4646
++tri_counter;
4747

48-
std::cout << "triangle" << tri_counter << " with sides [" << CLI::detail::join(sides) << "]" << std::endl;
48+
std::cout << "triangle" << tri_counter << " with sides [" << CLI::detail::join(sides) << "]\n";
4949
});
5050

5151
tri->add_option("sides", sides, "the side lengths of the triangle");

examples/simple.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ int main(int argc, char **argv) {
2828
CLI11_PARSE(app, argc, argv);
2929

3030
std::cout << "Working on file: " << file << ", direct count: " << app.count("--file")
31-
<< ", opt count: " << opt->count() << std::endl;
31+
<< ", opt count: " << opt->count() << '\n';
3232
std::cout << "Working on count: " << count << ", direct count: " << app.count("--count")
33-
<< ", opt count: " << copt->count() << std::endl;
33+
<< ", opt count: " << copt->count() << '\n';
3434
std::cout << "Received flag: " << v << " (" << flag->count() << ") times\n";
35-
std::cout << "Some value: " << value << std::endl;
35+
std::cout << "Some value: " << value << '\n';
3636

3737
return 0;
3838
}

examples/subcom_help.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ int main(int argc, char *argv[]) {
1515
cli_sub.add_option("sub_arg", sub_arg, "Argument for subcommand")->required();
1616
CLI11_PARSE(cli_global, argc, argv);
1717
if(cli_sub) {
18-
std::cout << "Got: " << sub_arg << std::endl;
18+
std::cout << "Got: " << sub_arg << '\n';
1919
}
2020
return 0;
2121
}

examples/subcom_in_files/subcommand_a.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ void setup_subcommand_a(CLI::App &app) {
3030
/// but having a separate function is cleaner.
3131
void run_subcommand_a(SubcommandAOptions const &opt) {
3232
// Do stuff...
33-
std::cout << "Working on file: " << opt.file << std::endl;
33+
std::cout << "Working on file: " << opt.file << '\n';
3434
if(opt.with_foo) {
35-
std::cout << "Using foo!" << std::endl;
35+
std::cout << "Using foo!" << '\n';
3636
}
3737
}

examples/subcom_partitioned.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ int main(int argc, char **argv) {
3737
}
3838

3939
std::cout << "Working on file: " << file << ", direct count: " << impOpt->count("--file")
40-
<< ", opt count: " << opt->count() << std::endl;
40+
<< ", opt count: " << opt->count() << '\n';
4141
std::cout << "Working on count: " << count << ", direct count: " << impOpt->count("--count")
42-
<< ", opt count: " << copt->count() << std::endl;
43-
std::cout << "Some value: " << value << std::endl;
42+
<< ", opt count: " << copt->count() << '\n';
43+
std::cout << "Some value: " << value << '\n';
4444

4545
return 0;
4646
}

examples/subcommands.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,11 @@ int main(int argc, char **argv) {
2424

2525
CLI11_PARSE(app, argc, argv);
2626

27-
std::cout << "Working on --file from start: " << file << std::endl;
28-
std::cout << "Working on --count from stop: " << s->count() << ", direct count: " << stop->count("--count")
29-
<< std::endl;
30-
std::cout << "Count of --random flag: " << app.count("--random") << std::endl;
27+
std::cout << "Working on --file from start: " << file << '\n';
28+
std::cout << "Working on --count from stop: " << s->count() << ", direct count: " << stop->count("--count") << '\n';
29+
std::cout << "Count of --random flag: " << app.count("--random") << '\n';
3130
for(auto *subcom : app.get_subcommands())
32-
std::cout << "Subcommand: " << subcom->get_name() << std::endl;
31+
std::cout << "Subcommand: " << subcom->get_name() << '\n';
3332

3433
return 0;
3534
}

examples/testEXE.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ int main(int argc, const char *argv[]) {
1919
auto *subcom = app.add_subcommand("sub", "")->prefix_command();
2020
CLI11_PARSE(app, argc, argv);
2121

22-
std::cout << "value =" << value << std::endl;
22+
std::cout << "value =" << value << '\n';
2323
std::cout << "after Args:";
2424
for(const auto &aarg : subcom->remaining()) {
2525
std::cout << aarg << " ";
2626
}
27-
std::cout << std::endl;
27+
std::cout << '\n';
2828
}

examples/validators.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ int main(int argc, char **argv) {
1919
app.add_option("-v,--value", count, "Value in range")->check(CLI::Range(3, 6));
2020
CLI11_PARSE(app, argc, argv);
2121

22-
std::cout << "Try printing help or failing the validator" << std::endl;
22+
std::cout << "Try printing help or failing the validator" << '\n';
2323

2424
return 0;
2525
}

include/CLI/Timer.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class AutoTimer : public Timer {
126126
// GCC 4.7 does not support using inheriting constructors.
127127

128128
/// This destructor prints the string
129-
~AutoTimer() { std::cout << to_string() << std::endl; }
129+
~AutoTimer() { std::cout << to_string() << '\n'; }
130130
};
131131

132132
} // namespace CLI

0 commit comments

Comments
 (0)