@@ -25,6 +25,21 @@ function(_find_sources _base_path _pattern _return_var)
2525
2626endfunction ()
2727
28+ #=============================================================================#
29+ # Finds header files matching the pre-defined header-file pattern under the given path.
30+ # This functions searchs explicitly for header-files such as '*.h'.
31+ # Search could also be recursive (With sub-directories) if the optional 'RECURSE' option is passed.
32+ # _base_path - Top-Directory path to search source files in.
33+ # _return_var - Name of variable in parent-scope holding the return value.
34+ # Returns - List of header files in the given path
35+ #=============================================================================#
36+ function (find_header_files _base_path _return_var)
37+
38+ _find_sources("${_base_path} " "${ARDUINO_CMAKE_HEADER_FILES_PATTERN} " headers ${ARGN} )
39+ set (${_return_var} "${headers} " PARENT_SCOPE)
40+
41+ endfunction ()
42+
2843#=============================================================================#
2944# Finds source files matching the pre-defined source-file pattern under the given path.
3045# This functions searchs explicitly for source-files such as '*.c'.
@@ -41,20 +56,35 @@ function(find_source_files _base_path _return_var)
4156endfunction ()
4257
4358#=============================================================================#
44- # Finds header files matching the pre-defined header-file pattern under the given path.
45- # This functions searchs explicitly for header-files such as '*.h'.
46- # Search could also be recursive (With sub-directories) if the optional 'RECURSE' option is passed.
59+ # Recursively finds header files under the given path, excluding those that don't belong to a library,
60+ # such as files under the 'exmaples' directory (In case sources reside under lib's root directory).
4761# _base_path - Top-Directory path to search source files in.
4862# _return_var - Name of variable in parent-scope holding the return value.
49- # Returns - List of header files in the given path
63+ # Returns - List of source files in the given path
5064#=============================================================================#
51- function (find_header_files _base_path _return_var)
65+ function (find_library_header_files _base_path _return_var)
5266
53- _find_sources("${_base_path} " "${ARDUINO_CMAKE_HEADER_FILES_PATTERN} " headers ${ARGN} )
67+ find_header_files(${_base_path} headers RECURSE) # Library headers are always searched recursively
68+ list (FILTER headers EXCLUDE REGEX "${ARDUINO_CMAKE_EXCLUDED_LIBRARY_SOURCES_PATTERN} " )
5469 set (${_return_var} "${headers} " PARENT_SCOPE)
5570
5671endfunction ()
5772
73+ #=============================================================================#
74+ # Recursively finds source files under the given path, excluding those that don't belong to a library,
75+ # such as files under the 'exmaples' directory (In case sources reside under lib's root directory).
76+ # _base_path - Top-Directory path to search source files in.
77+ # _return_var - Name of variable in parent-scope holding the return value.
78+ # Returns - List of source files in the given path
79+ #=============================================================================#
80+ function (find_library_source_files _base_path _return_var)
81+
82+ find_source_files(${_base_path} sources RECURSE) # Library sources are always searched recursively
83+ list (FILTER sources EXCLUDE REGEX "${ARDUINO_CMAKE_EXCLUDED_LIBRARY_SOURCES_PATTERN} " )
84+ set (${_return_var} "${sources} " PARENT_SCOPE)
85+
86+ endfunction ()
87+
5888#=============================================================================#
5989# Finds sketch files matching the pre-defined sketch-file pattern under the given path.
6090# This functions searchs explicitly for sketch-files such as '*.ino'.
0 commit comments