Skip to content
This repository was archived by the owner on Apr 17, 2023. It is now read-only.

Commit e180f9a

Browse files
committed
Completed support for header-only libraries - Code still needs refactoring.
1 parent 9513432 commit e180f9a

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

cmake/Platform/Targets/ArduinoCMakeLibraryTarget.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ function(_add_arduino_cmake_library _target_name _board_id _sources)
4545
list(LENGTH library_ARCH num_of_libs_archs)
4646
if (${num_of_libs_archs} GREATER 1)
4747
# Exclude all unsupported architectures, request filter in regex mode
48-
_get_unsupported_architectures("${library_ARCH}" arch_filter REGEX)
48+
_get_unsupported_architectures("${parsed_args_ARCH}" arch_filter REGEX)
4949
set(filter_type EXCLUDE)
5050
else ()
51-
set(arch_filter "src\\/[^/]+\\.|${library_ARCH}")
51+
set(arch_filter "src\\/[^/]+\\.|${parsed_args_ARCH}")
5252
set(filter_type INCLUDE)
5353
endif ()
5454
list(FILTER _sources ${filter_type} REGEX ${arch_filter})
@@ -115,6 +115,6 @@ function(_link_arduino_cmake_library _target_name _library_name)
115115
target_include_directories(${_library_name} ${scope} "${core_lib_includes}")
116116
target_link_libraries(${_library_name} ${scope} ${core_target})
117117

118-
target_link_libraries(${_target_name} ${scope} ${_library_name})
118+
target_link_libraries(${_target_name} PRIVATE ${_library_name})
119119

120120
endfunction()

cmake/Platform/Targets/ArduinoLibraryTarget.cmake

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,6 @@ function(_get_unsupported_architectures _arch_list _return_var)
6969

7070
endfunction()
7171

72-
function(add_arduino_header_only_library _target_name _board_id)
73-
74-
_add_arduino_cmake_library(${_target_name} ${_board_id} "${_sources}" INTERFACE "${ARGN}")
75-
76-
endfunction()
77-
7872
#=============================================================================#
7973
# Creates a library target for the given name and sources.
8074
# As it's an Arduino library, it also finds and links all dependent platform libraries (if any).
@@ -92,6 +86,15 @@ function(add_arduino_library _target_name _board_id _sources)
9286

9387
endfunction()
9488

89+
function(add_arduino_header_only_library _target_name _board_id)
90+
91+
cmake_parse_arguments(parsed_args "ARCH" "" "HEADERS" ${ARGN})
92+
93+
_add_arduino_cmake_library(${_target_name} ${_board_id} "${parsed_args_HEADERS}"
94+
INTERFACE ${parsed_args_ARCH})
95+
96+
endfunction()
97+
9598
#=============================================================================#
9699
# Finds an Arduino library with the given library name and creates a library target from it
97100
# with the given target name.
@@ -139,8 +142,9 @@ function(find_arduino_library _target_name _library_name _board_id)
139142
message(SEND_ERROR "${error_message}")
140143
else ()
141144
if (parsed_args_HEADER_ONLY)
142-
add_arduino_header_only_library(${_target_name} ${_board_id} "${library_headers}"
143-
INTERFACE ARCH ${lib_arch})
145+
add_arduino_header_only_library(${_target_name} ${_board_id}
146+
ARCH ${lib_arch}
147+
HEADERS ${library_headers})
144148
else ()
145149
find_library_source_files("${library_path}" library_sources)
146150
if (NOT library_sources)
@@ -151,7 +155,8 @@ function(find_arduino_library _target_name _library_name _board_id)
151155
message(SEND_ERROR "${error_message}")
152156
else ()
153157
set(sources ${library_headers} ${library_sources})
154-
add_arduino_library(${_target_name} ${_board_id} "${sources}" ARCH ${lib_arch})
158+
add_arduino_library(${_target_name} ${_board_id} "${sources}"
159+
ARCH ${lib_arch})
155160
endif ()
156161
endif ()
157162
endif ()

0 commit comments

Comments
 (0)