Use list(APPEND) rather than set(var ${var} ...) in CMake
authorBen Boeckel <mathstuf@gmail.com>
Wed, 4 Feb 2015 16:53:59 +0000 (11:53 -0500)
committerBen Boeckel <mathstuf@gmail.com>
Sun, 8 Feb 2015 02:06:44 +0000 (21:06 -0500)
This avoids a variable expansion and avoids the chances of a typo being
introduced in variable names.

14 files changed:
CMakeLists.txt
src/ToolBox/SOS/Strike/CMakeLists.txt
src/debug/daccess/CMakeLists.txt
src/debug/ee/CMakeLists.txt
src/dlls/dbgshim/CmakeLists.txt
src/dlls/mscordac/CMakeLists.txt
src/dlls/mscordbi/CMakeLists.txt
src/dlls/mscoree/CMakeLists.txt
src/dlls/mscoree/coreclr/CMakeLists.txt
src/inc/CMakeLists.txt
src/utilcode/CMakeLists.txt
src/utilcode/staticnohost/CMakeLists.txt
src/vm/CMakeLists.txt
src/vm/wks/CMakeLists.txt

index 0958c9d..096cee3 100644 (file)
@@ -30,7 +30,7 @@ function(get_compile_definitions DefinitionName)
         else()
             set(DEFINITION -D${DEFINITION})
         endif()
-        set(DEFINITIONS ${DEFINITIONS} ${DEFINITION})
+        list(APPEND DEFINITIONS ${DEFINITION})
     endforeach()
     set(${DefinitionName} ${DEFINITIONS} PARENT_SCOPE)
 endfunction(get_compile_definitions)
@@ -39,7 +39,7 @@ endfunction(get_compile_definitions)
 function(get_include_directories IncludeDirectories)
     get_directory_property(dirs INCLUDE_DIRECTORIES)
     foreach(dir IN LISTS dirs)
-        set(INC_DIRECTORIES ${INC_DIRECTORIES} -I${dir})
+        list(APPEND INC_DIRECTORIES -I${dir})
     endforeach()
     set(${IncludeDirectories} ${INC_DIRECTORIES} PARENT_SCOPE)
 endfunction(get_include_directories)
@@ -50,7 +50,7 @@ endfunction(get_include_directories)
 function(convert_to_absolute_path RetSources)
     set(Sources ${ARGN})
     foreach(Source IN LISTS Sources)
-        set(AbsolutePathSources ${AbsolutePathSources} ${CMAKE_CURRENT_SOURCE_DIR}/${Source})
+        list(APPEND AbsolutePathSources ${CMAKE_CURRENT_SOURCE_DIR}/${Source})
     endforeach()            
     set(${RetSources} ${AbsolutePathSources} PARENT_SCOPE)
 endfunction(convert_to_absolute_path)
index bf8cc2b..b6e52b7 100644 (file)
@@ -43,13 +43,13 @@ set(SOS_SOURCES_AMD64
   disasmX86.cpp
 )
 
-set(SOS_SOURCES ${SOS_SOURCES} ${SOS_SOURCES_AMD64})
+list(APPEND SOS_SOURCES ${SOS_SOURCES_AMD64})
 
 add_definitions(-DFX_VER_INTERNALNAME_STR=SOS.dll)
 
 #Preprocess exports definition file
 preprocess_def_file(${CMAKE_CURRENT_SOURCE_DIR}/sos.def ${CMAKE_CURRENT_BINARY_DIR}/sos.def)
-set(SOS_SOURCES ${SOS_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/sos.def)
+list(APPEND SOS_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/sos.def)
 
 set(SOS_LIBRARY
   corguids
index 0920bd8..cdea533 100644 (file)
@@ -36,13 +36,11 @@ set(DACCESS_SOURCES
 if(IS_64BIT_BUILD EQUAL 1)
   include_directories(amd64)
 
-  set(DACCESS_SOURCES
-    ${DACCESS_SOURCES}
+  list(APPEND DACCESS_SOURCES
     amd64/primitives.cpp
   )
 else()
-  set(DACCESS_SOURCES
-    ${DACCESS_SOURCES}
+  list(APPEND DACCESS_SOURCES
     i386/primitives.cpp
   )
 endif(IS_64BIT_BUILD EQUAL 1)
index 4cbfe4c..f0f8735 100644 (file)
@@ -33,8 +33,7 @@ set(CORDBEE_SOURCES_DAC
 )
 
 if(WIN32)
-  set(CORDBEE_SOURCES_WKS
-    ${CORDBEE_SOURCES_WKS}
+  list(APPEND CORDBEE_SOURCES_WKS
     # The following files need to be ported to Linux
     inprocdac.cpp
     dbgtransportproxy.cpp
@@ -43,9 +42,9 @@ if(WIN32)
 endif(WIN32)
 
 if (IS_64BIT_BUILD EQUAL 1)
-  set(CORDBEE_SOURCES_WKS ${CORDBEE_SOURCES_WKS} amd64/amd64walker.cpp)
+  list(APPEND CORDBEE_SOURCES_WKS amd64/amd64walker.cpp)
 else ()
-  set(CORDBEE_SOURCES_WKS ${CORDBEE_SOURCES_WKS} i386/x86walker.cpp)
+  list(APPEND CORDBEE_SOURCES_WKS i386/x86walker.cpp)
 endif (IS_64BIT_BUILD EQUAL 1)
 
 convert_to_absolute_path(CORDBEE_SOURCES_DAC ${CORDBEE_SOURCES_DAC})
@@ -54,4 +53,4 @@ convert_to_absolute_path(CORDBEE_SOURCES_WKS ${CORDBEE_SOURCES_WKS})
 set(CORDBEE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
 
 add_subdirectory(dac)
-add_subdirectory(wks)
\ No newline at end of file
+add_subdirectory(wks)
index fde787d..14bf983 100644 (file)
@@ -12,7 +12,7 @@ add_definitions(-DFX_VER_INTERNALNAME_STR=dbgshim.dll)
 
 preprocess_def_file(${CMAKE_CURRENT_SOURCE_DIR}/dbgshim.ntdef ${CMAKE_CURRENT_BINARY_DIR}/dbgshim.def)
 
-set(DBGSHIM_SOURCES ${DBGSHIM_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/dbgshim.def)
+list(APPEND DBGSHIM_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/dbgshim.def)
 
 add_library(dbgshim SHARED ${DBGSHIM_SOURCES})
 
index d50ab5d..ee39e99 100644 (file)
@@ -9,7 +9,7 @@ set(CLR_DAC_SOURCES
 add_definitions(-DFX_VER_INTERNALNAME_STR=mscordaccore.dll)
 
 if(WIN32)
-    set(CLR_DAC_SOURCES ${CLR_DAC_SOURCES}
+    list(APPEND CLR_DAC_SOURCES
         Native.rc
     )
     set(DEF_SOURCES
@@ -65,8 +65,7 @@ if(WIN32)
         ${STATIC_MT_CRT_LIB}
     )
 else()
-    set(COREDAC_LIBRARIES
-        ${COREDAC_LIBRARIES}
+    list(APPEND COREDAC_LIBRARIES
         palrt
     )
 endif(WIN32)
index 23c6b4b..627da37 100644 (file)
@@ -5,7 +5,7 @@ set(MSCORDBI_SOURCES
 if(WIN32)
     add_definitions(-DFX_VER_INTERNALNAME_STR=mscordbi.dll)
 
-    set(MSCORDBI_SOURCES ${MSCORDBI_SOURCES}
+    list(APPEND MSCORDBI_SOURCES
         Native.rc
     )
 
@@ -16,7 +16,7 @@ if(WIN32)
 
     preprocess_def_file(${DEF_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/mscordbi.def)
 
-    set(MSCORDBI_SOURCES ${MSCORDBI_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/mscordbi.def)
+    list(APPEND MSCORDBI_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/mscordbi.def)
 endif(WIN32)
 
 add_library(mscordbi SHARED
@@ -35,8 +35,7 @@ set(COREDBI_LIBRARIES
 ) 
 
 if(WIN32)
-    set(COREDBI_LIBRARIES
-        ${COREDBI_LIBRARIES}
+    list(APPEND COREDBI_LIBRARIES
         ipcmanager-staticcrt
         mdhotdata-staticcrt
         mdwinmd_dbi
@@ -53,8 +52,7 @@ if(WIN32)
     target_link_libraries(mscordbi ${COREDBI_LIBRARIES})
 
 elseif(CLR_CMAKE_PLATFORM_UNIX)
-    set(COREDBI_LIBRARIES
-        ${COREDBI_LIBRARIES}
+    list(APPEND COREDBI_LIBRARIES
         mdhotdata_full
         palrt
         CoreClrPal
index 5ed608a..346ec0d 100644 (file)
@@ -5,7 +5,7 @@ set(CLR_SOURCES
 )
 
 if(WIN32)
-set(CLR_SOURCES ${CLR_SOURCES}
+list(APPEND CLR_SOURCES
     comcallunmarshal.cpp
     delayload.cpp
     Native.rc
@@ -16,7 +16,7 @@ set (DEF_SOURCES
 )
 convert_to_absolute_path(DEF_SOURCES ${DEF_SOURCES})
 else()
-set(CLR_SOURCES ${CLR_SOURCES}
+list(APPEND CLR_SOURCES
     unixinterface.cpp
 )
 endif(WIN32)
index 2d346b2..46b2936 100644 (file)
@@ -1,7 +1,7 @@
 if (WIN32)
 preprocess_def_file(${DEF_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/coreclr.def)
 
-set(CLR_SOURCES ${CLR_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/coreclr.def)
+list(APPEND CLR_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/coreclr.def)
 
 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /ENTRY:CoreDllMain")
 
@@ -59,8 +59,7 @@ set(CORECLR_LIBRARIES
 )
 
 if(WIN32)
-    set(CORECLR_LIBRARIES
-        ${CORECLR_LIBRARIES}
+    list(APPEND CORECLR_LIBRARIES
         mdwinmd_wks
         comnls_wks
         comcrypt_wks
@@ -78,8 +77,7 @@ if(WIN32)
         RuntimeObject.lib
     )
 else()
-    set(CORECLR_LIBRARIES
-        ${CORECLR_LIBRARIES}
+    list(APPEND CORECLR_LIBRARIES
         CoreClrPal
         palrt
     )
@@ -94,8 +92,8 @@ if(WIN32)
     # Add dac table & debug resource to coreclr
     get_include_directories(INC_DIR)
     get_compile_definitions(PREPROCESS_DEFINITIONS)
-    set(INC_DIR ${INC_DIR} -I${CLR_DIR}/src/vm -I${CLR_DIR}/src/vm/amd64 -I${CLR_DIR}/src/debug/ee -I${CLR_DIR}/src/gc)
-    set(PREPROCESS_DEFINITIONS ${PREPROCESS_DEFINITIONS} -DDACCESS_COMPILE -DDBG_TARGET_64BIT=1 -DDBG_TARGET_WIN64=1 -DDBG_TARGET_AMD64=1)
+    list(APPEND INC_DIR -I${CLR_DIR}/src/vm -I${CLR_DIR}/src/vm/amd64 -I${CLR_DIR}/src/debug/ee -I${CLR_DIR}/src/gc)
+    list(APPEND PREPROCESS_DEFINITIONS -DDACCESS_COMPILE -DDBG_TARGET_64BIT=1 -DDBG_TARGET_WIN64=1 -DDBG_TARGET_AMD64=1)
     add_custom_command(TARGET coreclr
         POST_BUILD
         COMMAND ${CMAKE_CXX_COMPILER} /P /EP /TP ${PREPROCESS_DEFINITIONS} ${INC_DIR} /Fi${CMAKE_CURRENT_BINARY_DIR}/daccess.i  ${CLR_DIR}/src/debug/daccess/daccess.cpp
index d27a3b8..66037d2 100644 (file)
@@ -34,7 +34,7 @@ FIND_PROGRAM( MIDL midl.exe )
 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})
+   list(APPEND CORGUIDS_SOURCES ${OUT_NAME})
    add_custom_command(OUTPUT ${OUT_NAME}
                       COMMAND ${MIDL} ${MIDL_INCLUDE_DIRECTORIES} /h ${CMAKE_CURRENT_BINARY_DIR}/idls_out/${IDLNAME}.h ${MIDL_DEFINITIONS} /out ${CMAKE_CURRENT_BINARY_DIR}/idls_out ${CMAKE_CURRENT_SOURCE_DIR}/${GENERATE_IDL}
                       DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${GENERATE_IDL} 
@@ -53,7 +53,7 @@ else()
 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})
+   list(APPEND CORGUIDS_SOURCES ${C_SOURCE})
 endforeach(IDL_SOURCE)
 
 endif(WIN32)
index ea760e4..3d2140b 100644 (file)
@@ -72,8 +72,7 @@ set(UTILCODE_SOURCES
 # They should be moved out from here into the declaration
 # of UTILCODE_SOURCES above after fixing compiler errors.
 if(WIN32)
-  set(UTILCODE_SOURCES 
-    ${UTILCODE_SOURCES}
+  list(APPEND UTILCODE_SOURCES 
     appxutil.cpp
     dlwrap.cpp
     downlevel.cpp
index f28aa97..254ada1 100644 (file)
@@ -3,9 +3,9 @@ add_definitions(-DSELF_NO_HOST)
 if(WIN32)
      add_definitions(-D_CRTIMP=) # use static version of crt
 
-     set(UTILCODE_SOURCES ${UTILCODE_SOURCES} ../hostimpl.cpp)
+     list(APPEND UTILCODE_SOURCES ../hostimpl.cpp)
 
      add_library(utilcodestaticnohost STATIC ${UTILCODE_SOURCES})
 elseif(CLR_CMAKE_PLATFORM_UNIX)
      add_library(utilcodestaticnohost STATIC ${UTILCODE_SOURCES})
-endif(WIN32)
\ No newline at end of file
+endif(WIN32)
index 14591c3..f777e41 100644 (file)
@@ -257,8 +257,7 @@ set(VM_SOURCES_DAC_AND_WKS_WIN32
     winrttypenameconverter.cpp
 )
 
-set(VM_SOURCES_WKS 
-    ${VM_SOURCES_WKS}
+list(APPEND VM_SOURCES_WKS 
     ${VM_SOURCES_DAC_AND_WKS_WIN32}
     marvin32.cpp # move out of win32 when FEATURE_RANDOMIZED_STRING_HASHING is enabled for linux
     # These should not be included for Linux
@@ -294,8 +293,7 @@ set(VM_SOURCES_WKS
     winrthelpers.cpp    
 )
 
-set(VM_SOURCES_DAC 
-    ${VM_SOURCES_DAC}
+list(APPEND VM_SOURCES_DAC 
     ${VM_SOURCES_DAC_AND_WKS_WIN32}
     # These should not be included for Linux
     clrprivbinderwinrt.cpp
@@ -358,8 +356,7 @@ set(VM_SOURCES_WKS_AMD64
 
 if(CLR_CMAKE_PLATFORM_UNIX)
 
-set(VM_SOURCES_WKS_AMD64
-    ${VM_SOURCES_WKS_AMD64}
+list(APPEND VM_SOURCES_WKS_AMD64
     ${AMD64_SOURCES_DIR}/unixstubs.cpp
 )
 
@@ -371,14 +368,12 @@ set(VM_SOURCES_DAC_AMD64
     exceptionhandling.cpp
 )
 
-set(VM_SOURCES_WKS 
-    ${VM_SOURCES_WKS}
+list(APPEND VM_SOURCES_WKS 
     ${VM_SOURCES_WKS_AMD64}
     ${VM_SOURCES_DAC_AND_WKS_AMD64}
 )
 
-set(VM_SOURCES_DAC
-    ${VM_SOURCES_DAC}
+list(APPEND VM_SOURCES_DAC
     ${VM_SOURCES_DAC_AMD64}
     ${VM_SOURCES_DAC_AND_WKS_AMD64}
 )
index a0d2745..49d45cc 100644 (file)
@@ -16,7 +16,7 @@ foreach(DEFINITION IN LISTS COMPILE_DEFINITIONS_LIST)
         string(TOUPPER ${CMAKE_MATCH_1} CONFIG)
         set(ASM_DEFINITIONS_${CONFIG} ${ASM_DEFINITIONS_${CONFIG}} ${CMAKE_MATCH_2}) 
     else()
-        set(ASM_DEFINITIONS ${ASM_DEFINITIONS} ${DEFINITION})        
+        list(APPEND ASM_DEFINITIONS ${DEFINITION})        
     endif()
 endforeach()