From a1c91f3c07b88d11ebd3ec13cac7ded631d93c8e Mon Sep 17 00:00:00 2001 From: Michael Kuhn Date: Sat, 9 Mar 2019 04:06:22 +0100 Subject: Fix find_headers to also look for C++ headers and Fortran modules (#10798) Currently, only C headers are considered, causing build failures for packages depending on, e.g., netcdf-fortran and xerces-c. Additionally, the regex used to look for the include path component did not consider word boundaries, causing false matches. --- lib/spack/llnl/util/filesystem.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/spack/llnl/util/filesystem.py b/lib/spack/llnl/util/filesystem.py index 01e9f540f0..00e4dc5f37 100644 --- a/lib/spack/llnl/util/filesystem.py +++ b/lib/spack/llnl/util/filesystem.py @@ -957,7 +957,9 @@ class HeaderList(FileList): commonly used compiler flags or names. """ - include_regex = re.compile(r'(.*)(include)(.*)') + # Make sure to only match complete words, otherwise path components such + # as "xinclude" will cause false matches. + include_regex = re.compile(r'(.*)(\binclude\b)(.*)') def __init__(self, files): super(HeaderList, self).__init__(files) @@ -1122,10 +1124,11 @@ def find_headers(headers, root, recursive=False): raise TypeError(message) # Construct the right suffix for the headers - suffix = 'h' + suffixes = ['h', 'hpp', 'mod'] # List of headers we are searching with suffixes - headers = ['{0}.{1}'.format(header, suffix) for header in headers] + headers = ['{0}.{1}'.format(header, suffix) for header in headers + for suffix in suffixes] return HeaderList(find(root, headers, recursive)) -- cgit v1.2.3-70-g09d2