File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ option(TUTORIAL_ENABLE_IPO "Check for and use IPO support" ON)
88
99# TODO6: Add a default-ON option named BUILD_TESTING with a doc string of:
1010# "Enable testing and build tests"
11-
11+ option ( BUILD_TESTING "Enable testing and build tests" ON )
1212if (TUTORIAL_ENABLE_IPO)
1313 include (CheckIPOSupported )
1414 check_ipo_supported (RESULT result OUTPUT output )
@@ -25,5 +25,9 @@ endif()
2525
2626# TODO7: Conditional on the value of BUILD_TESTING, enable testing and add the
2727# Tests subdirectory to the project
28+ if (BUILD_TESTING)
29+ enable_testing ()
30+ add_subdirectory (Tests )
31+ endif ()
2832
2933add_subdirectory (MathFunctions )
Original file line number Diff line number Diff line change 77 "description" : " Preset to use with the tutorial" ,
88 "binaryDir" : " ${sourceDir}/build" ,
99 "cacheVariables" : {
10+ "CMAKE_CXX_COMPILER" :" g++-13" ,
11+ "CMAKE_EXPORT_COMPILE_COMMANDS" :" ON" ,
12+
1013 "TUTORIAL_USE_STD_SQRT" : " OFF" ,
1114 "TUTORIAL_ENABLE_IPO" : " OFF"
1215 }
Original file line number Diff line number Diff line change 11# TODO1: Add an executable target for the tests
2-
2+ add_executable ( TestMath )
33# TODO2: Add the TestMathFunctions.cxx file to the test target's sources
4-
4+ target_sources (TestMath
5+ PRIVATE
6+ TestMathFunctions.cxx )
57# TODO3: Add the MathFunctions library to the test target's link libraries
6-
8+ target_link_libraries (TestMath
9+ PRIVATE
10+ MathFunctions )
711# TODO4: Write a function that takes a single operation name as an argument.
812# The function will call add_test() with the operation name as the NAME
913# of the test, and a COMMAND of the form: <TestTarget> <operation name>
10-
11-
14+ function (MathFunctionTest op )
15+ add_test (
16+ NAME ${op}
17+ COMMAND TestMath ${op}
18+ )
19+ endfunction (MathFunctionTest op )
1220# TODO5: Call the function for all four supported operations:
1321# add, mul, sqrt, sub
22+ MathFunctionTest (add )
23+ MathFunctionTest (mul )
24+ MathFunctionTest (sqrt )
25+ MathFunctionTest (sub )
You can’t perform that action at this time.
0 commit comments