Skip to content

Commit d257401

Browse files
committed
[cmake] Support header only libraries
1 parent 553c4c7 commit d257401

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

tools/build_script_generator/cmake/resources/CMakeLists.txt.in

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ add_library({{ repo }} OBJECT
2727
{{ file | relocate | modm.posixify }}
2828
%% endfor
2929
)
30-
30+
%% else
31+
add_library({{ repo }} INTERFACE )
3132
%% endif
3233

3334
%% if per_file_attr | length
@@ -44,18 +45,31 @@ add_library({{ repo }}_arch_options INTERFACE)
4445
modm_target_config_create({{ repo }} {{ repo }}_arch_options {{ repo }}_options {{ repo }}_warnings)
4546

4647
%% if include_paths | length
47-
target_include_directories({{ repo }} SYSTEM PUBLIC
48+
target_include_directories({{ repo }} SYSTEM
49+
%% if sources | length
50+
PUBLIC
51+
%% else
52+
INTERFACE
53+
%% endif
4854
%% for path in include_paths | sort
4955
{{ path | relocate | modm.posixify }}
5056
%% endfor
5157
)
5258

5359
%% endif
5460

61+
5562
target_link_libraries({{ repo }}
63+
%% if sources | length
5664
PUBLIC
65+
%% else
66+
INTERFACE
67+
%%endif
5768
{{ repo }}_arch_options
69+
%% if sources | length
5870
PRIVATE
5971
project_options
6072
{{ repo }}_options
61-
{{ repo }}_warnings)
73+
{{ repo }}_warnings
74+
%% endif
75+
)

0 commit comments

Comments
 (0)