-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only build tests if testing is enabled
This commit ensures that tests are only compiled by default if BUILD_TESTING is enabled when generating the CMake configuration. There should be no change in behavior, as BUILD_TESTING defaults to ON.
- Loading branch information
Showing
2 changed files
with
18 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
file(GLOB test | ||
"*.cpp" | ||
) | ||
|
||
foreach(testfile ${test}) | ||
# ${testfile} is in the format of test/SomeTest.cpp | ||
string(REPLACE ".cpp" "_test" no_ext_name ${testfile}) | ||
# ${no_ext_name} is in the format of test/SomeTest_test | ||
get_filename_component(test_bin ${no_ext_name} NAME) | ||
# ${test_bin} is in the format of SomeTest_test | ||
add_executable(${test_bin} ${testfile}) | ||
target_link_libraries(${test_bin} PRIVATE sparta gmock_main) | ||
add_test(NAME ${testfile} COMMAND ${test_bin}) | ||
endforeach() |