This repository was archived by the owner on Apr 17, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +24
-14
lines changed
examples/3rd-party-library Expand file tree Collapse file tree 3 files changed +24
-14
lines changed Original file line number Diff line number Diff line change @@ -95,6 +95,15 @@ function(_link_arduino_cmake_library _target_name _library_name)
9595 set (scope_options "PRIVATE" "PUBLIC" "INTERFACE" )
9696 cmake_parse_arguments (link_library "${scope_options} " "BOARD_CORE_TARGET" "" ${ARGN} )
9797
98+ # Now, link library to executable
99+ if (link_library_PUBLIC)
100+ set (scope PUBLIC )
101+ elseif (link_library_INTERFACE)
102+ set (scope INTERFACE )
103+ else ()
104+ set (scope PRIVATE )
105+ endif ()
106+
98107 # First, include core lib's directories in library as well
99108 if (link_library_BOARD_CORE_TARGET)
100109 set (core_target ${link_library_BOARD_CORE_TARGET} )
@@ -103,17 +112,9 @@ function(_link_arduino_cmake_library _target_name _library_name)
103112 endif ()
104113
105114 get_target_property (core_lib_includes ${core_target} INCLUDE_DIRECTORIES )
106- target_include_directories (${_library_name} PUBLIC "${core_lib_includes} " )
107- target_link_libraries (${_library_name} PUBLIC ${core_target} )
115+ target_include_directories (${_library_name} ${scope} "${core_lib_includes} " )
116+ target_link_libraries (${_library_name} ${scope} ${core_target} )
108117
109- # Now, link library to executable
110- if (link_library_PUBLIC)
111- set (scope PUBLIC )
112- elseif (link_library_INTERFACE)
113- set (scope INTERFACE )
114- else ()
115- set (scope PRIVATE )
116- endif ()
117118 target_link_libraries (${_target_name} ${scope} ${_library_name} )
118119
119120endfunction ()
Original file line number Diff line number Diff line change @@ -167,9 +167,12 @@ endfunction()
167167# _target_name - Name of the "executable" target.
168168# _library_target_name - Name of the library target.
169169# _board_id - Board ID associated with the linked Core Lib.
170+ # [HEADER_ONLY] - Whether library is a header-only library, i.e has no source files
170171#=============================================================================#
171172function (link_arduino_library _target_name _library_target_name _board_id)
172173
174+ cmake_parse_arguments (parsed_args "HEADER_ONLY" "" "" ${ARGN} )
175+
173176 get_core_lib_target_name(${_board_id} core_lib_target)
174177
175178 if (NOT TARGET ${_target_name} )
@@ -180,8 +183,14 @@ function(link_arduino_library _target_name _library_target_name _board_id)
180183 message (FATAL_ERROR "Core Library target doesn't exist. This is bad and should be reported" )
181184 endif ()
182185
183- _link_arduino_cmake_library(${_target_name} ${_library_target_name}
184- PUBLIC
185- BOARD_CORE_TARGET ${core_lib_target} )
186+ if (parsed_args_HEADER_ONLY)
187+ _link_arduino_cmake_library(${_target_name} ${_library_target_name}
188+ INTERFACE
189+ BOARD_CORE_TARGET ${core_lib_target} )
190+ else ()
191+ _link_arduino_cmake_library(${_target_name} ${_library_target_name}
192+ PUBLIC
193+ BOARD_CORE_TARGET ${core_lib_target} )
194+ endif ()
186195
187196endfunction ()
Original file line number Diff line number Diff line change @@ -26,4 +26,4 @@ find_arduino_library(EnableInterrupt EnableInterrupt ${board_id} 3RD_PARTY HEADE
2626# Link all libraries to our previously created target
2727link_arduino_library(3rd_Party_Arduino_Library Adafruit_NeoPixel ${board_id} )
2828link_arduino_library(3rd_Party_Arduino_Library Adafruit_GFX ${board_id} )
29- link_arduino_library(3rd_Party_Arduino_Library EnableInterrupt ${board_id} )
29+ link_arduino_library(3rd_Party_Arduino_Library EnableInterrupt ${board_id} HEADER_ONLY )
You can’t perform that action at this time.
0 commit comments