@@ -14,7 +14,6 @@ endfunction ()
14
14
15
15
# Reads a Makefile into CMake vars.
16
16
# TODO: respect IFDEF/IFNDEF?
17
- # TODO: regex replace makefile vars, e.g. $(TSUFFIX) is set to the target arch in the var CGEMMOTCOPYOBJ = cgemm_otcopy$(TSUFFIX).$(SUFFIX)
18
17
macro (ParseMakefileVars MAKEFILE_IN)
19
18
message (STATUS "Reading vars from ${MAKEFILE_IN} ..." )
20
19
file (STRINGS ${MAKEFILE_IN} makefile_contents)
@@ -23,14 +22,19 @@ macro(ParseMakefileVars MAKEFILE_IN)
23
22
if (NOT "${line_match} " STREQUAL "" )
24
23
set (var_name ${CMAKE_MATCH_1} )
25
24
set (var_value ${CMAKE_MATCH_2} )
25
+ # check for Makefile variables in the string, e.g. $(TSUFFIX)
26
+ string (REGEX MATCHALL "\\ $\\ (([0-9_a-zA-Z]+)\\ )" make_var_matches ${var_value} )
27
+ foreach (make_var ${make_var_matches} )
28
+ # strip out Makefile $() markup
29
+ string (REGEX REPLACE "\\ $\\ (([0-9_a-zA-Z]+)\\ )" "\\ 1" make_var ${make_var} )
30
+ # now replace the instance of the Makefile variable with the value of the CMake variable (note the double quote)
31
+ string (REPLACE "$(${make_var} )" "${${make_var} }" var_value ${var_value} )
32
+ endforeach ()
26
33
set (${var_name} ${var_value} )
27
- message (STATUS "found var ${var_name} = ${var_value} " )
28
34
else ()
29
35
string (REGEX MATCH "include \\ $\\ (KERNELDIR\\ )/(.+)$" line_match "${makefile_line} " )
30
36
if (NOT "${line_match} " STREQUAL "" )
31
37
ParseMakefileVars(${KERNELDIR} /${CMAKE_MATCH_1} )
32
- else ()
33
- message (STATUS "couldn't parse ${makefile_line} into a var" )
34
38
endif ()
35
39
endif ()
36
40
endforeach ()
@@ -106,8 +110,10 @@ function(GenerateNamedObjects sources_in)
106
110
set (defines_in ${ARGV1} )
107
111
endif ()
108
112
109
- if (DEFINED ARGV2)
113
+ if (DEFINED ARGV2 AND NOT " ${ARGV2} " STREQUAL "" )
110
114
set (name_in ${ARGV2} )
115
+ # strip off extension for kernel files that pass in the object name.
116
+ get_filename_component (name_in ${name_in} NAME_WE )
111
117
endif ()
112
118
113
119
if (DEFINED ARGV3)
0 commit comments