GCI2012: CMake List Append
authorWillie Zhu
Sun, 30 Dec 2012 02:43:24 +0100
changeset 8347 716c05f19401
parent 8346 3443e0de2c9d
child 8348 c039ac6f33e0
GCI2012: CMake List Append
CMakeLists.txt
QTfrontend/CMakeLists.txt
cmake_modules/FindSDL_Extras.cmake
hedgewars/CMakeLists.txt
--- a/CMakeLists.txt	Sat Dec 29 22:50:10 2012 +0100
+++ b/CMakeLists.txt	Sun Dec 30 02:43:24 2012 +0100
@@ -130,8 +130,8 @@
         find_package(SDL_mixer REQUIRED)
         set(DYLIB_SMPEG "-dylib_file @loader_path/Frameworks/smpeg.framework/Versions/A/smpeg:${SDLMIXER_LIBRARY}/Versions/A/Frameworks/smpeg.framework/Versions/A/smpeg")
         set(DYLIB_MIKMOD "-dylib_file @loader_path/Frameworks/mikmod.framework/Versions/A/mikmod:${SDLMIXER_LIBRARY}/Versions/A/Frameworks/mikmod.framework/Versions/A/mikmod")
-        set(pascal_flags "-k${DYLIB_SMPEG}" "-k${DYLIB_MIKMOD}" ${pascal_flags})
-        set(CMAKE_C_FLAGS "${DYLIB_SMPEG}" "${DYLIB_MIKMOD}" ${CMAKE_C_FLAGS})
+        set(CMAKE_C_FLAGS "${DYLIB_SMPEG}" "${DYLIB_MIKMOD}")
+        list(APPEND pascal_flags "-k${DYLIB_SMPEG}" "-k${DYLIB_MIKMOD}")
     endif()
 
     #CMAKE_OSX_ARCHITECTURES and CMAKE_OSX_SYSROOT need to be set for universal binary and correct linking
@@ -161,9 +161,9 @@
     endif()
 
     #add user framework directory, other paths can be passed via FPFLAGS
-    set(pascal_flags "-Ff~/Library/Frameworks" ${pascal_flags})
+    list(APPEND pascal_flags "-Ff~/Library/Frameworks")
     #set deployment target
-    set(pascal_flags "-k-macosx_version_min" "-k${minimum_macosx_version}" "-XR${CMAKE_OSX_SYSROOT}" ${pascal_flags})
+    list(APPEND pascal_flags "-k-macosx_version_min" "-k${minimum_macosx_version}" "-XR${CMAKE_OSX_SYSROOT}")
 
     #silly libav that always brings in VideoDecoderAcceleration, avaible only from 10.6.3
     if(NOT NOVIDEOREC AND ${minimum_macosx_version} VERSION_LESS "10.6")
@@ -184,7 +184,7 @@
 endif (CMAKE_BUILD_TYPE)
 
 #set default flags values for all projects (unless MINIMAL_FLAGS is true)
-if(NOT MINIMAL_FLAGS)
+if(NOT ${MINIMAL_FLAGS})
     set(CMAKE_C_FLAGS "-pipe")
     set(CMAKE_C_FLAGS_RELEASE "-w -Os -fomit-frame-pointer")
     set(CMAKE_C_FLAGS_DEBUG "-Wall -O0 -g -DDEBUG")
@@ -210,7 +210,7 @@
     endif()
 endif()
 
-set(pascal_flags ${fpflags_parsed}              # user flags
+list(APPEND pascal_flags ${fpflags_parsed}              # user flags
                  "-vm4079,4080,4081"            # fpc output format
                  "-B"                           # compile all units
                  "-FE${PROJECT_BINARY_DIR}/bin" # fpc output directory
@@ -218,19 +218,18 @@
                  "-Cs2000000"                   # stack size
                  "-vewnq"                       # fpc output verbosity
                  "-dDEBUGFILE"                  # macro for engine output
-                 ${pascal_flags}                # adding to list
                  )
-set(haskell_flags "-O2" ${ghflags_parsed} ${haskell_flags})
+list(APPEND haskell_flags "-O2" ${ghflags_parsed})
 
 #get BUILD_TYPE and enable/disable optimisation
 message(STATUS "Using ${CMAKE_BUILD_TYPE} configuration")
 if(CMAKE_BUILD_TYPE MATCHES "DEBUG")
-    set(pascal_flags "-O-" "-g" "-gl" "-gv" ${pascal_flags})
-    set(haskell_flags "-Wall" "-debug" "-dcore-lint" "-fno-warn-unused-do-bind" ${haskell_flags})
+    list(APPEND pascal_flags "-O-" "-g" "-gl" "-gv")
+    list(APPEND haskell_flags "-Wall" "-debug" "-dcore-lint" "-fno-warn-unused-do-bind")
 else()
 #    set(pascal_flags "-O3" "-OpPENTIUM4" "-CfSSE3" "-Xs" "-Si" ${pascal_flags})
-    set(pascal_flags "-Os" "-Xs" "-Si" ${pascal_flags})
-    set(haskell_flags "-w" "-fno-warn-unused-do-bind" ${haskell_flags})
+    list(APPEND pascal_flags "-Os" "-Xs" "-Si")
+    list(APPEND haskell_flags "-w" "-fno-warn-unused-do-bind")
 endif()
 
 
@@ -264,14 +263,14 @@
     message(STATUS "LUA will be provided by the bundled sources")
     add_subdirectory(misc/liblua)
     #linking with liblua.a requires system readline
-    set(pascal_flags "-k${EXECUTABLE_OUTPUT_PATH}/lib${LUA_LIBRARY}.a" "-k-lreadline" ${pascal_flags})
+    list(APPEND pascal_flags "-k${EXECUTABLE_OUTPUT_PATH}/lib${LUA_LIBRARY}.a" "-k-lreadline")
 endif()
 
 
 #physfs library (static on unix, dll on win32)
 add_subdirectory(misc/physfs)
 if(NOT WIN32)
-    set(pascal_flags "-k${LIBRARY_OUTPUT_PATH}/libphysfs.a" ${pascal_flags})
+    list(APPEND pascal_flags "-k${LIBRARY_OUTPUT_PATH}/libphysfs.a")
 endif()
 
 
--- a/QTfrontend/CMakeLists.txt	Sat Dec 29 22:50:10 2012 +0100
+++ b/QTfrontend/CMakeLists.txt	Sun Dec 30 02:43:24 2012 +0100
@@ -62,7 +62,7 @@
 file(GLOB_RECURSE UIcpp ui/*.cpp)
 file(GLOB UtilCpp util/*.cpp)
 
-set(hwfr_src
+list(APPEND hwfr_src
     ${ModelCpp}
     ${NetCpp}
     ${UIcpp}
@@ -83,7 +83,7 @@
 
 #xfire integration
 if(WIN32)
-    set(hwfr_src ${hwfr_src} xfire.cpp ../misc/xfire/xfiregameclient.cpp)
+    list(APPEND hwfr_src xfire.cpp ../misc/xfire/xfiregameclient.cpp)
 endif(WIN32)
 
 if(MINGW)
@@ -92,9 +92,9 @@
                        COMMAND windres -I ${CMAKE_CURRENT_SOURCE_DIR}
                                -i ${CMAKE_CURRENT_SOURCE_DIR}/hedgewars.rc
                                -o ${CMAKE_CURRENT_BINARY_DIR}/hedgewars_rc.o)
-    set(hwfr_src ${hwfr_src} ${CMAKE_CURRENT_BINARY_DIR}/hedgewars_rc.o)
+    list(APPEND hwfr_src ${CMAKE_CURRENT_BINARY_DIR}/hedgewars_rc.o)
 else(MINGW)
-    set(hwfr_src ${hwfr_src} hedgewars.rc)
+    list(APPEND hwfr_src hedgewars.rc)
 endif(MINGW)
 
 file(GLOB ModelHdr model/*.h)
@@ -133,7 +133,7 @@
 if(${BUILD_ENGINE_LIBRARY})
     add_definitions(-DHWLIBRARY=1)
     set(hwlibname "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}hwengine${CMAKE_SHARED_LIBRARY_SUFFIX}")
-    set(HW_LINK_LIBS ${hwlibname} ${HW_LINK_LIBS})
+    list(APPEND HW_LINK_LIBS ${hwlibname})
 endif()
 
 qt4_add_resources(hwfr_rez_src ${hwfr_rez})
@@ -143,8 +143,8 @@
 
 if(APPLE)
     find_library(iokit_framework NAMES IOKit)
-    set(HW_LINK_LIBS ${iokit_framework} ${HW_LINK_LIBS})
-    set(hwfr_src ${hwfr_src} CocoaInitializer.mm
+    list(APPEND HW_LINK_LIBS ${iokit_framework})
+    list(APPEND hwfr_src CocoaInitializer.mm
                              InstallController.cpp
                              M3Panel.mm
                              M3InstallController.m
@@ -154,8 +154,8 @@
         find_package(Sparkle)
         if(SPARKLE_FOUND)
             add_definitions(-DSPARKLE_ENABLED)
-            set(hwfr_src ${hwfr_src} AutoUpdater.cpp SparkleAutoUpdater.mm)
-            set(HW_LINK_LIBS ${SPARKLE_LIBRARY} ${HW_LINK_LIBS})
+            list(APPEND hwfr_src AutoUpdater.cpp SparkleAutoUpdater.mm)
+            list(APPEND HW_LINK_LIBS ${SPARKLE_LIBRARY})
         endif()
     endif()
 endif()
@@ -177,22 +177,20 @@
     set_target_properties(hedgewars PROPERTIES LINK_FLAGS "-Wl,-rpath,${CMAKE_INSTALL_PREFIX}/${target_library_install_dir}")
 endif()
 
-set(HW_LINK_LIBS
+list(APPEND HW_LINK_LIBS
     physfs
     ${QT_LIBRARIES}
     ${SDL_LIBRARY}
     ${SDLMIXER_LIBRARY}
     ${FFMPEG_LIBRARIES}
-    ${HW_LINK_LIBS}
     )
 
 if(WIN32 AND NOT UNIX)
     if(NOT SDL_LIBRARY)
-        set(HW_LINK_LIBS ${HW_LINK_LIBS} SDL)
+        list(APPEND HW_LINK_LIBS SDL)
     endif()
 
-    set(HW_LINK_LIBS
-        ${HW_LINK_LIBS}
+    list(APPEND HW_LINK_LIBS
         ole32
         oleaut32
         winspool
--- a/cmake_modules/FindSDL_Extras.cmake	Sat Dec 29 22:50:10 2012 +0100
+++ b/cmake_modules/FindSDL_Extras.cmake	Sun Dec 30 02:43:24 2012 +0100
@@ -13,7 +13,7 @@
 
     if(sdlmixer_version GREATER "10209")
         message(STATUS "Mix_Init() is present")
-        set(pascal_flags "-dSDL_MIXER_NEWER" ${pascal_flags})
+        list(APPEND pascal_flags "-dSDL_MIXER_NEWER")
     endif()
 endif()
 
@@ -30,7 +30,7 @@
 
     if(sdlimage_version GREATER "010207")
         message(STATUS "IMG_Init() is present")
-        set(pascal_flags "-dSDL_IMAGE_NEWER" ${pascal_flags})
+        list(APPEND pascal_flags "-dSDL_IMAGE_NEWER")
     endif()
 endif()
 
--- a/hedgewars/CMakeLists.txt	Sat Dec 29 22:50:10 2012 +0100
+++ b/hedgewars/CMakeLists.txt	Sun Dec 30 02:43:24 2012 +0100
@@ -92,16 +92,16 @@
 
 if(${BUILD_ENGINE_LIBRARY})
     message(WARNING "Engine will be built as library (experimental)")
-    set(pascal_flags "-dHWLIBRARY" ${pascal_flags})
+    list(APPEND pascal_flags "-dHWLIBRARY")
 
     # create position independent code, only required for x68_64 builds, similar to -fPIC
     if(CMAKE_SIZEOF_VOID_P MATCHES "8")
-        set(pascal_flags "-Cg" ${pascal_flags})
+        list(APPEND pascal_flags "-Cg")
     endif(CMAKE_SIZEOF_VOID_P MATCHES "8")
 
     # due to compiler/linker issues on Max OS X 10.6 -k-no_order_inits is needed to avoid linking fail
     if(APPLE AND current_macosx_version VERSION_GREATER "10.5")
-        set(pascal_flags "-k-no_order_inits" ${pascal_flags})
+        list(APPEND pascal_flags "-k-no_order_inits")
     endif()
     set(destination_dir ${target_library_install_dir})
 else(${BUILD_ENGINE_LIBRARY})
@@ -140,20 +140,20 @@
             include_directories(${SDL_INCLUDE_DIR})
             add_library (SDLmain STATIC SDLMain.m)
             #add a dependency to the hwengine target
-            set(engine_sources ${engine_sources} SDLmain)
+            list(APPEND engine_sources SDLmain)
             set(SDLMAIN_LIB "${LIBRARY_OUTPUT_PATH}/libSDLmain.a")
         endif()
 
-        set(pascal_flags "-k${SDLMAIN_LIB}" ${pascal_flags})
+        list(APPEND pascal_flags "-k${SDLMAIN_LIB}")
     endif()
 endif(APPLE)
 
 if(NOT NOPNG)
     find_package(PNG)
     if(${PNG_FOUND})
-        set(pascal_flags "-dPNG_SCREENSHOTS" ${pascal_flags})
+        list(APPEND pascal_flags "-dPNG_SCREENSHOTS")
         if(APPLE)  # fpc png unit doesn't pull the library (see bug 21833)
-            set(pascal_flags "-k${PNG_LIBRARY}" ${pascal_flags})
+            list(APPEND pascal_flags "-k${PNG_LIBRARY}")
         endif()
     else()
         message(WARNING "Screenshots will be in BMP format because libpng was not found")
@@ -185,7 +185,7 @@
 
         #TODO: convert avwrapper to .pas unit so we can skip this step
         include_directories(${FFMPEG_INCLUDE_DIR})
-        set(pascal_flags "-dUSE_VIDEO_RECORDING" ${pascal_flags})
+        list(APPEND pascal_flags "-dUSE_VIDEO_RECORDING")
         IF (WIN32)
             # there are some problems with linking our avwrapper as static lib, so link it as shared
             add_library(avwrapper SHARED avwrapper.c)
@@ -193,7 +193,7 @@
             install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}avwrapper${CMAKE_SHARED_LIBRARY_SUFFIX}" DESTINATION ${target_library_install_dir})
         ELSE()
             add_library(avwrapper STATIC avwrapper.c)
-            set(pascal_flags "-k${FFMPEG_LIBAVCODEC}" "-k${FFMPEG_LIBAVFORMAT}" "-k${FFMPEG_LIBAVUTIL}" ${pascal_flags})
+            list(APPEND pascal_flags "-k${FFMPEG_LIBAVCODEC}" "-k${FFMPEG_LIBAVFORMAT}" "-k${FFMPEG_LIBAVUTIL}")
         ENDIF()
     else()
         message(WARNING "Could NOT find FFMPEG/LibAV, video recording will be disabled")
@@ -216,7 +216,7 @@
 else()
     #these are the dependencies for building a universal binary on Mac OS X
     foreach (build_arch ${powerpc_build} ${i386_build} ${x86_64_build})
-        set(lipo_args_list "${EXECUTABLE_OUTPUT_PATH}/hwengine.${build_arch}" ${lipo_args_list})
+        list(APPEND lipo_args_list "${EXECUTABLE_OUTPUT_PATH}/hwengine.${build_arch}")
         add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine.${build_arch}"
             COMMAND "${FPC_EXECUTABLE}"
             ARGS ${fpc_flags} -ohwengine.${build_arch} -P${build_arch}