From: Ben Boeckel Date: Wed, 4 Feb 2015 16:39:06 +0000 (-0500) Subject: Use foreach(IN LISTS) syntax in CMake code X-Git-Tag: accepted/tizen/base/20180629.140029~7167^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=91498e200292ef5f309fc0b7420f8a5bc8e308cc;p=platform%2Fupstream%2Fcoreclr.git Use foreach(IN LISTS) syntax in CMake code It avoids extra separation on semicolons if there are any and skips a variable expansion. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index ae7e9de..145b798 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ function(get_compile_definitions DefinitionName) # Get the current list of definitions get_directory_property(COMPILE_DEFINITIONS_LIST COMPILE_DEFINITIONS) - foreach(DEFINITION ${COMPILE_DEFINITIONS_LIST}) + foreach(DEFINITION IN LISTS COMPILE_DEFINITIONS_LIST) if (${DEFINITION} MATCHES "^\\$<\\$]+)>:([^>]+)>$") # The entries that contain generator expressions must have the -D inside of the # expression. So we transform e.g. $<$:_DEBUG> to $<$:-D_DEBUG> @@ -38,7 +38,7 @@ endfunction(get_compile_definitions) # Build a list of include directories by putting -I in front of each include dir. function(get_include_directories IncludeDirectories) get_directory_property(dirs INCLUDE_DIRECTORIES) - foreach(dir ${dirs}) + foreach(dir IN LISTS dirs) set(INC_DIRECTORIES ${INC_DIRECTORIES} -I${dir}) endforeach() set(${IncludeDirectories} ${INC_DIRECTORIES} PARENT_SCOPE) @@ -49,7 +49,7 @@ endfunction(get_include_directories) # The parameters after the RetSources are the input files. function(convert_to_absolute_path RetSources) set(Sources ${ARGN}) - foreach(Source ${Sources}) + foreach(Source IN LISTS Sources) set(AbsolutePathSources ${AbsolutePathSources} ${CMAKE_CURRENT_SOURCE_DIR}/${Source}) endforeach() set(${RetSources} ${AbsolutePathSources} PARENT_SCOPE) @@ -76,17 +76,17 @@ if (WIN32) # For multi-configuration toolset (as Visual Studio) # set the different configuration defines. # First DEBUG - foreach (Definition ${CLR_DEFINES_DEBUG_INIT}) + foreach (Definition IN LISTS CLR_DEFINES_DEBUG_INIT) set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$:${Definition}>) endforeach (Definition) # Then RELEASE - foreach (Definition ${CLR_DEFINES_RELEASE_INIT}) + foreach (Definition IN LISTS CLR_DEFINES_RELEASE_INIT) set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$:${Definition}>) endforeach (Definition) # And then RELWITHDEBINFO - foreach (Definition ${CLR_DEFINES_RELWITHDEBINFO_INIT}) + foreach (Definition IN LISTS CLR_DEFINES_RELWITHDEBINFO_INIT) set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$:${Definition}>) endforeach (Definition) diff --git a/src/inc/CMakeLists.txt b/src/inc/CMakeLists.txt index e8f52de..d27a3b8 100644 --- a/src/inc/CMakeLists.txt +++ b/src/inc/CMakeLists.txt @@ -31,7 +31,7 @@ get_include_directories(MIDL_INCLUDE_DIRECTORIES) # Run custom midl command over each idl file FIND_PROGRAM( MIDL midl.exe ) -foreach(GENERATE_IDL ${CORGUIDS_IDL_SOURCES}) +foreach(GENERATE_IDL IN LISTS CORGUIDS_IDL_SOURCES) get_filename_component(IDLNAME ${GENERATE_IDL} NAME_WE) set(OUT_NAME ${CMAKE_CURRENT_BINARY_DIR}/idls_out/${IDLNAME}_i.c) set(CORGUIDS_SOURCES ${CORGUIDS_SOURCES} ${OUT_NAME}) @@ -50,7 +50,7 @@ add_compile_options(/TC) else() #The MIDL tool exists for Windows only, so for other systems, we have the prebuilt xxx_i.c files checked in -foreach(IDL_SOURCE ${CORGUIDS_IDL_SOURCES}) +foreach(IDL_SOURCE IN LISTS CORGUIDS_IDL_SOURCES) get_filename_component(IDLNAME ${IDL_SOURCE} NAME_WE) set(C_SOURCE ../pal/prebuilt/idl/${IDLNAME}_i.c) set(CORGUIDS_SOURCES ${CORGUIDS_SOURCES} ${C_SOURCE}) diff --git a/src/vm/wks/CMakeLists.txt b/src/vm/wks/CMakeLists.txt index 2f7c16d..a0d2745 100644 --- a/src/vm/wks/CMakeLists.txt +++ b/src/vm/wks/CMakeLists.txt @@ -9,7 +9,7 @@ get_directory_property(COMPILE_DEFINITIONS_LIST COMPILE_DEFINITIONS) # Extract the definitions for the ASM code. Since there is a bug in the cmake that prevents us from # using the generator expressions, we split the definitions into lists based on the configuration. -foreach(DEFINITION ${COMPILE_DEFINITIONS_LIST}) +foreach(DEFINITION IN LISTS COMPILE_DEFINITIONS_LIST) if (${DEFINITION} MATCHES "^\\$<\\$]+)>:([^>]+)>$") # The entry contains generator expression, so insert the definition into a definitions list # corresponding to the config @@ -23,7 +23,7 @@ endforeach() # Add defines for the ASM. Unfortunately setting it on the target is ignored for asm by the cmake, so we have # to set it on the sources. set_property(SOURCE ${VM_SOURCES_WKS_AMD64_ASM} PROPERTY COMPILE_DEFINITIONS ${ASM_DEFINITIONS}) -foreach(CONFIG ${CMAKE_CONFIGURATION_TYPES}) +foreach(CONFIG IN LISTS CMAKE_CONFIGURATION_TYPES) string(TOUPPER ${CONFIG} CONFIG) set_property(SOURCE ${VM_SOURCES_WKS_AMD64_ASM} PROPERTY COMPILE_DEFINITIONS_${CONFIG} ${ASM_DEFINITIONS_${CONFIG}}) endforeach()