11cmake_minimum_required (VERSION 3.20 )
22
3- # TODO 1: Add the `project()`'s `VERSION` and set it to `2.7.1`
43project (Project LANGUAGES C )
54
6- add_executable (version )
5+ add_executable (target )
76
8- target_sources (version PRIVATE main.c )
7+ target_sources (target PRIVATE main.c )
98
10- # TODO 2: Configure `version.h.in` to generate `version.h`
11- configure_file ()
9+ # TODO 1: Set the target's `VERSION` to 1.2.3
1210
13- # TODO 3: Add the Project Binary Directory to the target's include directories
14- target_include_directories ()
1511
16- target_compile_options (version PRIVATE --cpu=cortex-m4 )
1712
18- target_link_options (version PRIVATE
13+
14+ # TODO 2: Expose the target's `VERSION` to the application
15+
16+
17+
18+
19+
20+
21+ # TODO 3: Configure `version.h` from `version.h.in`
22+
23+
24+
25+
26+
27+ # TODO 4: Add `build/include/` to target's include directories
28+
29+
30+ target_compile_options (target PRIVATE
31+ --cpu=cortex-m4
32+ --no_wrap_diagnostics
33+ )
34+
35+ target_link_options (target PRIVATE
1936 --cpu=cortex-m4
2037 --semihosting )
2138
@@ -24,17 +41,27 @@ enable_testing()
2441cmake_path (GET CMAKE_C_COMPILER PARENT_PATH BIN_DIR )
2542cmake_path (GET BIN_DIR PARENT_PATH TOOLKIT_DIR )
2643cmake_path (GET TOOLKIT_DIR FILENAME TOOLKIT )
27- add_test (NAME version -test
28- COMMAND ${BIN_DIR} /../../common/bin/CSpyBat
29- # C-SPY drivers for the Arm simulator via command line interface
30- ${BIN_DIR} /${CMAKE_SHARED_LIBRARY_PREFIX}${TOOLKIT}PROC${CMAKE_SHARED_LIBRARY_SUFFIX}
31- ${BIN_DIR} /${CMAKE_SHARED_LIBRARY_PREFIX}${TOOLKIT}SIM2${CMAKE_SHARED_LIBRARY_SUFFIX}
32- --plugin=${BIN_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}${TOOLKIT}LibsupportUniversal${CMAKE_SHARED_LIBRARY_SUFFIX}
33- # The target executable (built with debug information)
34- --debug_file=$<TARGET_FILE:version>
35- # C-SPY driver options
36- --backend
37- --cpu=cortex-m4
38- --semihosting )
39-
40- set_tests_properties (version -test PROPERTIES PASS_REGULAR_EXPRESSION "2.7.1" )
44+
45+ macro (iar_cspysim TESTNAME EXPECTED )
46+ add_test (NAME ${TESTNAME} -test
47+ COMMAND ${BIN_DIR} /../../common/bin/CSpyBat
48+ # C-SPY drivers for the Arm simulator via command line interface
49+ ${BIN_DIR} /${CMAKE_SHARED_LIBRARY_PREFIX}${TOOLKIT}PROC${CMAKE_SHARED_LIBRARY_SUFFIX}
50+ ${BIN_DIR} /${CMAKE_SHARED_LIBRARY_PREFIX}${TOOLKIT}SIM2${CMAKE_SHARED_LIBRARY_SUFFIX}
51+ --plugin=${BIN_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}${TOOLKIT}LibsupportUniversal${CMAKE_SHARED_LIBRARY_SUFFIX}
52+ # The target executable (built with debug information)
53+ --debug_file=$<TARGET_FILE:target>
54+ # C-SPY driver options
55+ --backend
56+ --cpu=cortex-m4
57+ --semihosting
58+ )
59+ set_tests_properties (${TESTNAME} -test PROPERTIES
60+ PASS_REGULAR_EXPRESSION ${EXPECTED}
61+ )
62+ endmacro ()
63+
64+ # Add tests for the string-formatted version and for the integer-formatted version
65+ iar_cspysim ("string-version" "String version: $<TARGET_PROPERTY :target ,VERSION >" )
66+ iar_cspysim ("integer-version" "Integer version: $<TARGET_PROPERTY :target ,VERSION >" )
67+
0 commit comments