aboutsummaryrefslogtreecommitdiff
path: root/cmake/Common
diff options
context:
space:
mode:
authorDavid Vincze <david.vincze@arm.com>2019-06-27 16:33:08 +0200
committerDavid Vincze <david.vincze@arm.com>2019-08-28 16:51:05 +0200
commita3e84c74fc970601f297cc03d0f2d9c6975d8025 (patch)
tree92effa633c3a45cc30f2cb2693c8f2062d9c9623 /cmake/Common
parent91b71efeb2e3f13e151abee668968b8f987a4375 (diff)
downloadtrusted-firmware-m-a3e84c74fc970601f297cc03d0f2d9c6975d8025.tar.gz
Build: Fix linker and preprocess define in cmake
This patch fixes the embedded_set_target_link_defines custom function to handle more than one pre-processor defines and also modifies the compiler_preprocess_file custom function to handle additional macro definitions and include paths (the gnuarm specific version of this function already handles these). Change-Id: I46c6ae8c98d20e6e2eb8379eda460a0f973abf8e Signed-off-by: David Vincze <david.vincze@arm.com>
Diffstat (limited to 'cmake/Common')
-rw-r--r--cmake/Common/BuildSys.cmake4
-rw-r--r--cmake/Common/CompilerArmClangCommon.cmake21
2 files changed, 21 insertions, 4 deletions
diff --git a/cmake/Common/BuildSys.cmake b/cmake/Common/BuildSys.cmake
index 396e131d36..741042c143 100644
--- a/cmake/Common/BuildSys.cmake
+++ b/cmake/Common/BuildSys.cmake
@@ -656,8 +656,8 @@ endfunction()
#
function(embedded_set_target_link_defines)
set( _OPTIONS_ARGS ) #Option (on/off) arguments (e.g. IGNORE_CASE)
- set( _ONE_VALUE_ARGS TARGET DEFINES) #Single option arguments (e.g. PATH "./foo/bar")
- set( _MULTI_VALUE_ARGS ) #List arguments (e.g. LANGUAGES C ASM CXX)
+ set( _ONE_VALUE_ARGS TARGET) #Single option arguments (e.g. PATH "./foo/bar")
+ set( _MULTI_VALUE_ARGS DEFINES) #List arguments (e.g. LANGUAGES C ASM CXX)
cmake_parse_arguments(_MY_PARAMS "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} )
if (NOT DEFINED _MY_PARAMS_TARGET)
diff --git a/cmake/Common/CompilerArmClangCommon.cmake b/cmake/Common/CompilerArmClangCommon.cmake
index 98174739f6..191ed54560 100644
--- a/cmake/Common/CompilerArmClangCommon.cmake
+++ b/cmake/Common/CompilerArmClangCommon.cmake
@@ -192,13 +192,15 @@ endfunction()
# DST - (mandatory) - output file for the preprocessing
# TARGET_PREFIX - (optional) - prefix for the target that this function creates and which manages the preprocessing
# BEFORE_TARGET - (optional) - target which is dependent on the preprocessing target in the below function
+# DEFINES - (optional) - additional command line switches from macro definitions for preprocessing
+# INCLUDES - (optional) - additional command line switches from include paths for preprocessing
function(compiler_preprocess_file)
#Option (on/off) arguments.
set( _OPTIONS_ARGS)
#Single option arguments.
set( _ONE_VALUE_ARGS SRC DST TARGET_PREFIX BEFORE_TARGET)
#List arguments
- set( _MULTI_VALUE_ARGS)
+ set( _MULTI_VALUE_ARGS DEFINES INCLUDES)
cmake_parse_arguments(_MY_PARAMS "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} )
#Check passed parameters
@@ -216,6 +218,21 @@ function(compiler_preprocess_file)
endif()
endif()
+ #Compose additional command line switches from macro definitions.
+ set(_FLAGS "")
+ if (_MY_PARAMS_DEFINES)
+ foreach(_DEFINE IN LISTS _MY_PARAMS_DEFINES)
+ list(APPEND _FLAGS "-D${_DEFINE}")
+ endforeach()
+ endif()
+
+ #Compose additional command line switches from include paths.
+ if (_MY_PARAMS_INCLUDES)
+ foreach(_INCLUDE IN LISTS _MY_PARAMS_INCLUDES)
+ list(APPEND _FLAGS "-I${_INCLUDE}")
+ endforeach()
+ endif()
+
#The compiler flag might contain leading spaces which can fail the preprocess operation, these are removed
STRING(STRIP ${CMAKE_C_FLAGS_CPU} _MY_TEMP_CMAKE_C_FLAGS_CPU)
#If a string contains spaces, then it is inserted amongst quotation marks. Furthermore the compiler fails if it is
@@ -228,7 +245,7 @@ function(compiler_preprocess_file)
endforeach()
add_custom_command(OUTPUT ${_MY_PARAMS_DST}
- COMMAND ${CMAKE_C_COMPILER} ${_LOCAL_CMAKE_C_FLAGS_CPU} -E -P -xc ${_MY_PARAMS_SRC} -o ${_MY_PARAMS_DST}
+ COMMAND ${CMAKE_C_COMPILER} ${_LOCAL_CMAKE_C_FLAGS_CPU} -E -P -xc ${_FLAGS} ${_MY_PARAMS_SRC} -o ${_MY_PARAMS_DST}
DEPENDS ${_MY_PARAMS_SRC}
COMMENT "Preprocess the ${_MY_PARAMS_SRC} file"
)