1010#=============================================================================#
1111function (find_arduino_library _target_name _library_name _board_id)
1212
13- set (argument_options "3RD_PARTY" )
13+ set (argument_options "3RD_PARTY" "HEADER_ONLY" )
1414 cmake_parse_arguments (parsed_args "${argument_options} " "" "" ${ARGN} )
1515
1616 if (NOT parsed_args_3RD_PARTY)
@@ -26,24 +26,32 @@ function(find_arduino_library _target_name _library_name _board_id)
2626 if (${library_properties_file} MATCHES "NOTFOUND" )
2727 message (SEND_ERROR "Couldn't find library named ${_library_name} " )
2828 else () # Library is found
29+
2930 get_filename_component (library_path ${library_properties_file} DIRECTORY )
3031
3132 find_library_header_files("${library_path} " library_headers)
33+
3234 if (NOT library_headers)
33- set (error_message "Couldn't find any header files for the ${_library_name} library" )
34- message (SEND_ERROR "${error_message} " )
35+ message (SEND_ERROR "Couldn't find any header files for the ${_library_name} library" )
3536 else ()
36- find_library_source_files("${library_path} " library_sources)
37- if (NOT library_sources)
38- string (CONCAT error_message
39- "Couldn't find any source files for the ${_library_name} library - "
40- "Is it a header-only library?\n "
41- "If so, please pass the HEADER_ONLY option as an argument to the function" )
42- message (SEND_ERROR "${error_message} " )
37+
38+ if (parsed_args_HEADER_ONLY)
39+ add_arduino_header_only_library(${_target_name} ${_board_id} ${library_headers} )
4340 else ()
44- set (sources ${library_headers} ${library_sources} )
45- add_arduino_library(${_target_name} ${_board_id} ${library_path} "${sources} "
46- LIB_PROPS_FILE ${library_properties_file} )
41+ find_library_source_files("${library_path} " library_sources)
42+
43+ if (NOT library_sources)
44+ message (SEND_ERROR "Couldn't find any source files for the "
45+ "${_library_name} library - Is it a header-only library?"
46+ "If so, please pass the HEADER_ONLY option "
47+ "as an argument to the function" )
48+ else ()
49+ set (sources ${library_headers} ${library_sources} )
50+
51+ add_arduino_library(${_target_name} ${_board_id} ${library_path} "${sources} "
52+ LIB_PROPS_FILE ${library_properties_file} )
53+ endif ()
54+
4755 endif ()
4856 endif ()
4957 endif ()
0 commit comments