ParseMakefileVars now replaces Makefile vars with CMake vars.

This commit is contained in:
Hank Anderson 2015-02-18 12:23:17 -06:00
parent 14fd3d35de
commit 43725b82c5
1 changed files with 11 additions and 5 deletions

View File

@ -14,7 +14,6 @@ endfunction ()
# Reads a Makefile into CMake vars.
# TODO: respect IFDEF/IFNDEF?
# TODO: regex replace makefile vars, e.g. $(TSUFFIX) is set to the target arch in the var CGEMMOTCOPYOBJ = cgemm_otcopy$(TSUFFIX).$(SUFFIX)
macro(ParseMakefileVars MAKEFILE_IN)
message(STATUS "Reading vars from ${MAKEFILE_IN}...")
file(STRINGS ${MAKEFILE_IN} makefile_contents)
@ -23,14 +22,19 @@ macro(ParseMakefileVars MAKEFILE_IN)
if (NOT "${line_match}" STREQUAL "")
set(var_name ${CMAKE_MATCH_1})
set(var_value ${CMAKE_MATCH_2})
# check for Makefile variables in the string, e.g. $(TSUFFIX)
string(REGEX MATCHALL "\\$\\(([0-9_a-zA-Z]+)\\)" make_var_matches ${var_value})
foreach (make_var ${make_var_matches})
# strip out Makefile $() markup
string(REGEX REPLACE "\\$\\(([0-9_a-zA-Z]+)\\)" "\\1" make_var ${make_var})
# now replace the instance of the Makefile variable with the value of the CMake variable (note the double quote)
string(REPLACE "$(${make_var})" "${${make_var}}" var_value ${var_value})
endforeach ()
set(${var_name} ${var_value})
message(STATUS "found var ${var_name} = ${var_value}")
else ()
string(REGEX MATCH "include \\$\\(KERNELDIR\\)/(.+)$" line_match "${makefile_line}")
if (NOT "${line_match}" STREQUAL "")
ParseMakefileVars(${KERNELDIR}/${CMAKE_MATCH_1})
else ()
message(STATUS "couldn't parse ${makefile_line} into a var")
endif ()
endif ()
endforeach ()
@ -106,8 +110,10 @@ function(GenerateNamedObjects sources_in)
set(defines_in ${ARGV1})
endif ()
if (DEFINED ARGV2)
if (DEFINED ARGV2 AND NOT "${ARGV2}" STREQUAL "")
set(name_in ${ARGV2})
# strip off extension for kernel files that pass in the object name.
get_filename_component(name_in ${name_in} NAME_WE)
endif ()
if (DEFINED ARGV3)