use add_flag_append more, correctly set a few flags
authorkoda
Thu, 27 Jun 2013 12:02:40 +0200
changeset 9268 8a9075ed0aab
parent 9265 a0e7e7a1c3f8
child 9271 118cc5c1f677
use add_flag_append more, correctly set a few flags
cmake_modules/platform.cmake
hedgewars/CMakeLists.txt
--- a/cmake_modules/platform.cmake	Thu Jun 27 11:38:14 2013 +0200
+++ b/cmake_modules/platform.cmake	Thu Jun 27 12:02:40 2013 +0200
@@ -2,10 +2,10 @@
 if(APPLE)
     set(CMAKE_FIND_FRAMEWORK "FIRST")
 
-#what system are we building for
+    #what system are we building for
     set(minimum_macosx_version $ENV{MACOSX_DEPLOYMENT_TARGET})
 
-#detect on which system we are: if sw_vers cannot be found for any reason (re)use minimum_macosx_version
+    #detect on which system we are: if sw_vers cannot be found for any reason (re)use minimum_macosx_version
     find_program(sw_vers sw_vers)
     if(sw_vers)
         execute_process(COMMAND ${sw_vers} "-productVersion"
@@ -21,41 +21,39 @@
         endif()
     endif()
 
-#if nothing is set, we deploy only for the current system
+    #if nothing is set, we deploy only for the current system
     if(NOT minimum_macosx_version)
         set(minimum_macosx_version ${current_macosx_version})
     endif()
 
-#lower systems don't have enough processing power anyway
+    #lower systems don't have enough processing power anyway
     if (minimum_macosx_version VERSION_LESS "10.4")
         message(FATAL_ERROR "Hedgewars is not supported on Mac OS X pre-10.4")
     endif()
 
-#workaround for http://playcontrol.net/ewing/jibberjabber/big_behind-the-scenes_chang.html#SDL_mixer (Update 2)
+    #workaround for http://playcontrol.net/ewing/jibberjabber/big_behind-the-scenes_chang.html#SDL_mixer (Update 2)
     if(current_macosx_version VERSION_EQUAL "10.4")
         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(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${DYLIB_SMPEG} ${DYLIB_MIKMOD}")
-        set(CMAKE_CX_FLAGS "${CMAKE_CX_FLAGS} ${DYLIB_SMPEG} ${DYLIB_MIKMOD}")
-        list(APPEND pascal_flags "-k${DYLIB_SMPEG}" "-k${DYLIB_MIKMOD}")
+        add_flag_append(CMAKE_C_FLAGS "${DYLIB_SMPEG} ${DYLIB_MIKMOD}")
+        add_flag_append(CMAKE_CXX_FLAGS "${DYLIB_SMPEG} ${DYLIB_MIKMOD}")
+        add_flag_append(CMAKE_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
     if(NOT CMAKE_OSX_ARCHITECTURES)
         if(current_macosx_version VERSION_LESS "10.6")
+            #SDL is only 32 bit on lower OS
             if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "powerpc*")
                 set(CMAKE_OSX_ARCHITECTURES "ppc7400")
             else()
                 set(CMAKE_OSX_ARCHITECTURES "i386")
             endif()
-        else()
-            set(CMAKE_OSX_ARCHITECTURES "x86_64")
         endif()
     endif()
 
-#CMAKE_OSX_SYSROOT is set at the system version we are supposed to build on
-#we need to provide the correct one when host and target differ
+    #CMAKE_OSX_SYSROOT is set at the system version we are supposed to build on
+    #we need to provide the correct one when host and target differ
     if(NOT ${minimum_macosx_version} VERSION_EQUAL ${current_macosx_version})
         if(minimum_macosx_version VERSION_EQUAL "10.4")
             set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.4u.sdk/")
@@ -65,19 +63,18 @@
             string(REGEX REPLACE "([0-9]+.[0-9]+).[0-9]+" "\\1" sdk_version ${minimum_macosx_version})
             set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX${sdk_version}.sdk/")
         endif()
+        add_flag_append(CMAKE_Pascal_FLAGS "-XR${CMAKE_OSX_SYSROOT}")
+        add_flag_append(CMAKE_Pascal_FLAGS "-k-macosx_version_min -k${minimum_macosx_version}")
     endif()
 
-#add user framework directory, other paths can be passed via FPFLAGS
-    list(APPEND pascal_flags "-Ff~/Library/Frameworks")
-#set deployment target
-    list(APPEND pascal_flags "-k-macosx_version_min" "-k${minimum_macosx_version}" "-XR${CMAKE_OSX_SYSROOT}")
-
+    #add user framework directory, other paths can be passed via FPFLAGS
+    add_flag_append(CMAKE_Pascal_FLAGS "-Ff~/Library/Frameworks")
 endif(APPLE)
 
 if(MINGW)
     #this flags prevents a few dll hell problems
-    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc ")
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc ")
+    add_flag_append(CMAKE_C_FLAGS "-static-libgcc")
+    add_flag_append(CMAKE_CXX_FLAGS "-static-libgcc")
 endif(MINGW)
 
 if(WIN32)
--- a/hedgewars/CMakeLists.txt	Thu Jun 27 11:38:14 2013 +0200
+++ b/hedgewars/CMakeLists.txt	Thu Jun 27 12:02:40 2013 +0200
@@ -123,11 +123,6 @@
         list(APPEND HW_LINK_LIBS SDLmain)
         add_flag_append(CMAKE_Pascal_FLAGS -Fl${LIBRARY_OUTPUT_PATH})
     endif()
-
-    #when sysroot is set, make sure that fpc picks it
-    if(CMAKE_OSX_SYSROOT)
-        set(add_flag_append "-XD${CMAKE_OSX_SYSROOT}")
-    endif(CMAKE_OSX_SYSROOT)
 endif(APPLE)
 
 if(FFMPEG_FOUND)