Skip to content

Commit 3ae428f

Browse files
author
Felipe Torrezan
authored
Fix linker options (#44)
* Added compiler and linker options for CM4 * Mention forced reconfiguration
1 parent 62a823d commit 3ae428f

File tree

6 files changed

+24
-6
lines changed

6 files changed

+24
-6
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ target_sources(tutorial PRIVATE tutorial.c)
5050
target_compile_options(tutorial PRIVATE --cpu=cortex-m4)
5151
5252
# linker options
53-
target_link_options(tutorial PRIVATE --semihosting)
53+
target_link_options(tutorial PRIVATE
54+
--cpu=cortex-m4
55+
--semihosting)
5456
```
5557

5658
### Enabling the IAR Compiler
@@ -126,7 +128,7 @@ add_test(NAME tutorialTest
126128
set_tests_properties(tutorialTest PROPERTIES PASS_REGULAR_EXPRESSION "Hello world!")
127129
```
128130

129-
- Since `CMakeLists.txt` was modified, the build system needs to be reconfigured:
131+
- Since `CMakeLists.txt` was modified, the build system needs to be reconfigured. Rebuilding the project will automatically force reconfiguration, creating the `CTestTestfile.cmake` file:
130132
```
131133
cmake --build .
132134
```

examples/libs/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ add_subdirectory()
1212
# TODO 5: Link the `lib` against `libs`
1313
target_link_libraries()
1414

15-
target_link_options(libs PRIVATE --semihosting)
15+
target_compile_options(libs PRIVATE --cpu=cortex-m4)
16+
17+
target_link_options(libs PRIVATE
18+
--cpu=cortex-m4
19+
--semihosting)
1620

1721
enable_testing()
1822

examples/libs/lib/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ target_sources()
66

77
# TODO 3: Using the `PUBLIC` scope, expose the `lib` headers (inc) to other targets
88
target_include_directories()
9+
10+
target_compile_options(lib PRIVATE --cpu=cortex-m4)

examples/mix/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ add_executable(mix)
88
# TODO 2: Add `fun.s` source to the `mix` target
99
target_sources(mix PRIVATE main.c)
1010

11-
target_link_options(mix PRIVATE --semihosting)
11+
target_compile_options(mix PRIVATE --cpu=cortex-m4)
12+
13+
target_link_options(mix PRIVATE
14+
--cpu=cortex-m4
15+
--semihosting)
1216

1317
enable_testing()
1418

examples/version/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ configure_file()
1313
# TODO 3: Add the Project Binary Directory to the target's include directories
1414
target_include_directories()
1515

16-
target_link_options(version PRIVATE --semihosting)
16+
target_compile_options(version PRIVATE --cpu=cortex-m4)
17+
18+
target_link_options(version PRIVATE
19+
--cpu=cortex-m4
20+
--semihosting)
1721

1822
enable_testing()
1923

tutorial/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ target_sources(tutorial PRIVATE tutorial.c)
1414
target_compile_options(tutorial PRIVATE --cpu=cortex-m4)
1515

1616
# linker options
17-
target_link_options(tutorial PRIVATE --semihosting)
17+
target_link_options(tutorial PRIVATE
18+
--cpu=cortex-m4
19+
--semihosting)
1820

1921
# TODO 1: Enable testing in CMake
2022

0 commit comments

Comments
 (0)