This repository was archived by the owner on Apr 17, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +21
-3
lines changed Expand file tree Collapse file tree 4 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -33,8 +33,7 @@ function(resolve_sketch_headers _target_name _board_id _sketch_file)
3333 foreach (header ${sketch_headers} )
3434 # Header name without extension (such as '.h') can represent an Arduino/Platform library
3535 # So first we should check whether it's a library
36- string (REGEX MATCH "(.+)\\ ." "${header} " header_we_match)
37- set (header_we ${CMAKE_MATCH_1} )
36+ get_name_without_file_extension("${header} " header_we)
3837
3938 if (${header_we} IN_LIST ARDUINO_CMAKE_PLATFORM_LIBRARIES)
4039 link_platform_library(${_target_name} ${header_we} ${_board_id} )
Original file line number Diff line number Diff line change @@ -29,13 +29,20 @@ endfunction()
2929#=============================================================================#
3030function (get_source_file_included_headers _source_file _return_var)
3131
32+ cmake_parse_arguments (headers "WE" "" "" ${ARGN} )
33+
3234 file (STRINGS "${_source_file} " source_lines) # Loc = Lines of code
3335 list (FILTER source_lines INCLUDE REGEX ${ARDUINO_CMAKE_HEADER_INCLUDE_REGEX_PATTERN} )
3436
3537 # Extract header names from inclusion
3638 foreach (loc ${source_lines} )
3739 string (REGEX MATCH ${ARDUINO_CMAKE_HEADER_NAME_REGEX_PATTERN} ${loc} match)
38- list (APPEND headers ${CMAKE_MATCH_1} )
40+ if (headers_WE)
41+ get_name_without_file_extension("${CMAKE_MATCH_1} " header_name)
42+ else ()
43+ set (header_name ${CMAKE_MATCH_1} )
44+ endif ()
45+ list (APPEND headers ${header_name} )
3946 endforeach ()
4047
4148 set (${_return_var} ${headers} PARENT_SCOPE)
Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ function(set_internal_search_patterns)
1212 "Regex pattern matching a header's name when wrapped in inclusion line" )
1313 set (ARDUINO_CMAKE_HEADER_FILE_EXTENSION_REGEX_PATTERN ".+\\ .h.*$" CACHE STRING
1414 "Regex pattern matching all header file extensions" )
15+ set (ARDUINO_CMAKE_NAME_WE_REGEX_PATTERN "(.+)\\ ." CACHE STRING
16+ "Regex pattern matching name without file extension" )
1517 set (ARDUINO_CMAKE_FUNCTION_REGEX_PATTERN "^([a-z]|[A-Z])+.*\( ([a-z]|[A-Z])*\) " CACHE STRING
1618 "Regex pattern matching a function signature in a source file" )
1719
Original file line number Diff line number Diff line change @@ -66,3 +66,13 @@ function(get_core_lib_target_name _board_id _return_var)
6666 set (${_return_var} ${core_lib_target_name} PARENT_SCOPE)
6767
6868endfunction ()
69+
70+ #=============================================================================#
71+ # Extracts a name symbol without possible file extension (marked usually by a dot ('.').
72+ # _input_string - String containing name symbol and possibly file extension.
73+ # _output_string - Name of a CMake variable that will hold the extraction result.
74+ #=============================================================================#
75+ macro (get_name_without_file_extension _input_string _output_string)
76+ string (REGEX MATCH "${ARDUINO_CMAKE_NAME_WE_REGEX_PATTERN} " "${_input_string} " match)
77+ set (${_output_string} ${CMAKE_MATCH_1} )
78+ endmacro ()
You can’t perform that action at this time.
0 commit comments