From f99b18d573f0966e9c432a83c76ce2a20485dcd4 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Thu, 9 Apr 2020 12:41:16 +0200 Subject: [PATCH] handle multiline arguments in makefile correctly --- ports/gsl/CMakeLists.txt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ports/gsl/CMakeLists.txt b/ports/gsl/CMakeLists.txt index 0027fe291..2d37f37e9 100644 --- a/ports/gsl/CMakeLists.txt +++ b/ports/gsl/CMakeLists.txt @@ -9,7 +9,8 @@ function(extract_from_makefile PATTERN RETURN FILEPATH) string(REGEX MATCH "${PATTERN}" CONTENTS "${MAKEFILE_CONTENT}") set(CONTENTS ${CMAKE_MATCH_1}) # Split string into list - string(REGEX REPLACE "[ \t]+" ";" CONTENTS "${CONTENTS}") + string(REGEX REPLACE "([\t ]+(\\\\\n)?)+" ";" CONTENTS "${CONTENTS}") + string(REGEX REPLACE "[\t ]*\\\\\n[\t ]*;" "" CONTENTS "${CONTENTS}") if("${CONTENTS}" STREQUAL "") message(AUTHOR_WARNING "No match for \"${PATTERN}\" found in file ${FILEPATH}") endif() @@ -19,8 +20,8 @@ endfunction(extract_from_makefile) # Function to extract C sources from makefile function(extract_sources SUBFOLDER ALLSOURCES) - extract_from_makefile("lib[a-zA-Z1-9_]*_la_SOURCES[ \t]*=[ \t]*([^\n]*)" SOURCEFILES "${SUBFOLDER}/Makefile.am") - # Add the folder in front of the file names + extract_from_makefile("lib[a-zA-Z1-9_]*_la_SOURCES[ \t]*=[ \t]*(((\\\\\n)?[^\n])*)" SOURCEFILES "${SUBFOLDER}/Makefile.am") + # Add the folder in front of the file names string(REGEX REPLACE "([^;]+)" "${SUBFOLDER}/\\1" SOURCEFILES "${SOURCEFILES}") # Return set(${ALLSOURCES} ${${ALLSOURCES}} ${SOURCEFILES} PARENT_SCOPE) @@ -28,7 +29,7 @@ endfunction(extract_sources) set(SOURCES) set(CBLAS_SOURCES) -extract_from_makefile("SUBDIRS = ([^\n]*)" FOLDERS "./Makefile.am") +extract_from_makefile("SUBDIRS = (((\\\\\n)?[^\n])*)" FOLDERS "./Makefile.am") extract_sources("." SOURCES) foreach(DIR IN LISTS FOLDERS) if("${DIR}" STREQUAL "cblas")