forked from raspberrypi/pico-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
37 lines (31 loc) · 1.31 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# 1 Create an INTERFACE library aggregating all the common parts of the application
add_library(common_stuff INTERFACE)
# note cmake policy is to use absolute paths for interface libraries.
target_sources(common_stuff INTERFACE
${CMAKE_CURRENT_LIST_DIR}/main.c
${CMAKE_CURRENT_LIST_DIR}/other.c
)
target_compile_definitions(common_stuff INTERFACE
A_DEFINE_THAT_IS_SHARED=123
)
# can include library dependencies here
target_link_libraries(common_stuff INTERFACE
pico_stdlib
)
# 2 Create the first executable including all the common stuff...
# we can set compile definitions for this executable here too. Because
# we depend on an INTERFACE library (common_stuff) we
# will pick up all of its definitions/dependencies too
add_executable(build_variant1)
target_link_libraries(build_variant1 common_stuff)
target_compile_definitions(build_variant1 PRIVATE
A_DEFINE_THAT_IS_NOT_SHARED=456)
pico_add_extra_outputs(build_variant1)
# 3 Create a second executable including all the common stuff
# this version also sets the DO_EXTRA define
add_executable(build_variant2)
target_link_libraries(build_variant2 common_stuff)
target_compile_definitions(build_variant2 PRIVATE
A_DEFINE_THAT_IS_NOT_SHARED=789
DO_EXTRA)
pico_add_extra_outputs(build_variant2)