From 43725b82c5fa459ecc0ec98d21cee4c751cd33fd Mon Sep 17 00:00:00 2001 From: Hank Anderson Date: Wed, 18 Feb 2015 12:23:17 -0600 Subject: [PATCH] ParseMakefileVars now replaces Makefile vars with CMake vars. --- cmake/utils.cmake | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/cmake/utils.cmake b/cmake/utils.cmake index fbb546dbe..c77b762e6 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -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)