Commit 8e87df2a6cb82ec30cf14cd2743f7c8dbbddb76d
Committed by
Henry Schreiner
1 parent
10772e5d
Adding GTest improvments
Showing
3 changed files
with
23 additions
and
2 deletions
CHANGELOG.md
| ... | ... | @@ -12,6 +12,8 @@ |
| 12 | 12 | * Subcommand now support groups [#46](https://github.com/CLIUtils/CLI11/pull/46) |
| 13 | 13 | * `CLI::RuntimeError` added, for easy exit with error codes [#45](https://github.com/CLIUtils/CLI11/pull/45) |
| 14 | 14 | * The clang-format script is now no longer "hidden" [#48](https://github.com/CLIUtils/CLI11/pull/48) |
| 15 | +* The order is now preserved for subcommands (list and callbacks) [#49](https://github.com/CLIUtils/CLI11/pull/49) | |
| 16 | +* Tests now run individually, utilizing CMake 3.10 additions if possible | |
| 15 | 17 | |
| 16 | 18 | |
| 17 | 19 | ## Version 1.2 | ... | ... |
cmake/AddGoogletest.cmake
| ... | ... | @@ -32,11 +32,29 @@ set_target_properties(check PROPERTIES FOLDER "Scripts") |
| 32 | 32 | # More modern way to do the last line, less messy but needs newish CMake: |
| 33 | 33 | # target_include_directories(gtest INTERFACE ${gtest_SOURCE_DIR}/include) |
| 34 | 34 | |
| 35 | + | |
| 36 | +if(GOOGLE_TEST_INDIVIDUAL) | |
| 37 | + include(GoogleTest) | |
| 38 | +endif() | |
| 39 | + | |
| 35 | 40 | # Target must already exist |
| 36 | 41 | macro(add_gtest TESTNAME) |
| 37 | 42 | target_link_libraries(${TESTNAME} PUBLIC gtest gmock gtest_main) |
| 38 | - add_test(${TESTNAME} ${TESTNAME}) | |
| 39 | - set_target_properties(${TESTNAME} PROPERTIES FOLDER "Tests") | |
| 43 | + | |
| 44 | + if(GOOGLE_TEST_INDIVIDUAL) | |
| 45 | + if(CMAKE_VERSION VERSION_LESS 3.10) | |
| 46 | + gtest_add_tests(TARGET ${TESTNAME} | |
| 47 | + TEST_LIST TmpTestList) | |
| 48 | + set_tests_properties(${TmpTestList} PROPERTIES FOLDER "Tests") | |
| 49 | + else() | |
| 50 | + gtest_discover_tests(${TESTNAME} | |
| 51 | + PROPERTIES FOLDER "Tests") | |
| 52 | + endif() | |
| 53 | + else() | |
| 54 | + add_test(${TESTNAME} ${TESTNAME}) | |
| 55 | + set_target_properties(${TESTNAME} PROPERTIES FOLDER "Tests") | |
| 56 | + endif() | |
| 57 | + | |
| 40 | 58 | endmacro() |
| 41 | 59 | |
| 42 | 60 | mark_as_advanced( | ... | ... |