29 #if nothing is set, we deploy only for the current system |
29 #if nothing is set, we deploy only for the current system |
30 if(NOT minimum_macosx_version) |
30 if(NOT minimum_macosx_version) |
31 set(minimum_macosx_version ${current_macosx_version}) |
31 set(minimum_macosx_version ${current_macosx_version}) |
32 endif() |
32 endif() |
33 |
33 |
34 #lower systems don't have enough processing power anyway |
34 #10.3 systems don't have enough processing power anyway |
35 if (minimum_macosx_version VERSION_LESS "10.4") |
35 #10.4 does not have @rpath support (which SDL uses) |
36 message(FATAL_ERROR "Hedgewars is not supported on Mac OS X pre-10.4") |
36 if(minimum_macosx_version VERSION_LESS "10.5") |
37 endif() |
37 message(FATAL_ERROR "Hedgewars is not supported on your version of Mac OS X") |
38 |
|
39 #workaround for http://playcontrol.net/ewing/jibberjabber/big_behind-the-scenes_chang.html#SDL_mixer (Update 2) |
|
40 if(current_macosx_version VERSION_EQUAL "10.4") |
|
41 find_package(SDL_mixer REQUIRED) |
|
42 set(DYLIB_SMPEG "-dylib_file @loader_path/Frameworks/smpeg.framework/Versions/A/smpeg:${SDLMIXER_LIBRARY}/Versions/A/Frameworks/smpeg.framework/Versions/A/smpeg") |
|
43 set(DYLIB_MIKMOD "-dylib_file @loader_path/Frameworks/mikmod.framework/Versions/A/mikmod:${SDLMIXER_LIBRARY}/Versions/A/Frameworks/mikmod.framework/Versions/A/mikmod") |
|
44 add_flag_append(CMAKE_C_FLAGS "${DYLIB_SMPEG} ${DYLIB_MIKMOD}") |
|
45 add_flag_append(CMAKE_CXX_FLAGS "${DYLIB_SMPEG} ${DYLIB_MIKMOD}") |
|
46 add_flag_append(CMAKE_Pascal_FLAGS "-k${DYLIB_SMPEG} -k${DYLIB_MIKMOD}") |
|
47 endif() |
38 endif() |
48 |
39 |
49 if(NOT CMAKE_OSX_ARCHITECTURES) |
40 if(NOT CMAKE_OSX_ARCHITECTURES) |
50 if(current_macosx_version VERSION_LESS "10.6") |
41 if(current_macosx_version VERSION_LESS "10.6") |
51 #SDL is only 32 bit on lower OS |
42 #SDL is only 32 bit on older OS version |
52 if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "powerpc*") |
43 if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "powerpc*") |
53 set(CMAKE_OSX_ARCHITECTURES "ppc7400") |
44 set(CMAKE_OSX_ARCHITECTURES "ppc7400") |
54 else() |
45 else() |
55 set(CMAKE_OSX_ARCHITECTURES "i386") |
46 set(CMAKE_OSX_ARCHITECTURES "i386") |
56 endif() |
47 endif() |
71 else() |
62 else() |
72 message(FATAL_ERROR "Unknown architecture present in CMAKE_OSX_ARCHITECTURES (${CMAKE_OSX_ARCHITECTURES})") |
63 message(FATAL_ERROR "Unknown architecture present in CMAKE_OSX_ARCHITECTURES (${CMAKE_OSX_ARCHITECTURES})") |
73 endif() |
64 endif() |
74 list(LENGTH CMAKE_OSX_ARCHITECTURES num_of_archs) |
65 list(LENGTH CMAKE_OSX_ARCHITECTURES num_of_archs) |
75 if(num_of_archs GREATER 1) |
66 if(num_of_archs GREATER 1) |
76 message(${WARNING} "Only one architecture in CMAKE_OSX_ARCHITECTURES is currently supported, picking the first one") |
67 message("*** Only one architecture in CMAKE_OSX_ARCHITECTURES is supported, picking the first one ***") |
77 endif() |
68 endif() |
78 elseif(CMAKE_SIZEOF_VOID_P MATCHES "8") |
69 elseif(CMAKE_SIZEOF_VOID_P MATCHES "8") |
79 #if that variable is not set check if we are on x86_64 and if so force it, else use default |
70 #if that variable is not set check if we are on x86_64 and if so force it, else use default |
80 add_flag_prepend(CMAKE_Pascal_FLAGS -Px86_64) |
71 add_flag_prepend(CMAKE_Pascal_FLAGS -Px86_64) |
81 endif() |
72 endif() |
82 |
73 |
83 #CMAKE_OSX_SYSROOT is set at the system version we are supposed to build on |
74 #CMAKE_OSX_SYSROOT is set at the system version we are supposed to build on |
84 #we need to provide the correct one when host and target differ |
75 #we need to provide the correct one when host and target differ |
85 if(NOT ${minimum_macosx_version} VERSION_EQUAL ${current_macosx_version}) |
76 if(NOT CMAKE_OSX_SYSROOT AND |
86 if(minimum_macosx_version VERSION_EQUAL "10.4") |
77 NOT ${minimum_macosx_version} VERSION_EQUAL ${current_macosx_version}) |
87 set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.4u.sdk/") |
78 find_program(xcrun xcrun) |
88 set(CMAKE_C_COMPILER "/Developer/usr/bin/gcc-4.0") |
79 if(xcrun) |
89 set(CMAKE_CXX_COMPILER "/Developer/usr/bin/g++-4.0") |
80 execute_process(COMMAND ${xcrun} "--show-sdk-path" |
|
81 OUTPUT_VARIABLE current_sdk_path |
|
82 OUTPUT_STRIP_TRAILING_WHITESPACE) |
|
83 string(REPLACE "${current_macosx_version}" |
|
84 "${minimum_macosx_version}" |
|
85 CMAKE_OSX_SYSROOT |
|
86 "${current_sdk_path}") |
90 else() |
87 else() |
91 string(REGEX REPLACE "([0-9]+.[0-9]+).[0-9]+" "\\1" sdk_version ${minimum_macosx_version}) |
88 message("*** xcrun not found! Build will work on ${current_macosx_version} only ***") |
92 set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX${sdk_version}.sdk/") |
|
93 endif() |
89 endif() |
|
90 endif() |
|
91 if(CMAKE_OSX_SYSROOT) |
94 add_flag_append(CMAKE_Pascal_FLAGS "-XR${CMAKE_OSX_SYSROOT}") |
92 add_flag_append(CMAKE_Pascal_FLAGS "-XR${CMAKE_OSX_SYSROOT}") |
95 add_flag_append(CMAKE_Pascal_FLAGS "-k-macosx_version_min -k${minimum_macosx_version}") |
93 add_flag_append(CMAKE_Pascal_FLAGS "-k-macosx_version_min -k${minimum_macosx_version}") |
|
94 add_flag_append(CMAKE_Pascal_FLAGS "-k-L${LIBRARY_OUTPUT_PATH} -Fl${LIBRARY_OUTPUT_PATH}") |
96 endif() |
95 endif() |
97 |
96 |
98 #add user framework directory |
97 #add user framework directory |
99 add_flag_append(CMAKE_Pascal_FLAGS "-Ff~/Library/Frameworks") |
98 add_flag_append(CMAKE_Pascal_FLAGS "-Ff~/Library/Frameworks") |
|
99 |
|
100 #workaround older cmake versions |
|
101 if(${CMAKE_VERSION} VERSION_LESS "2.8.12") |
|
102 add_flag_append(CMAKE_C_LINK_FLAGS "-Wl,-rpath -Wl,${CMAKE_INSTALL_RPATH}") |
|
103 add_flag_append(CMAKE_CXX_LINK_FLAGS "-Wl,-rpath -Wl,${CMAKE_INSTALL_RPATH}") |
|
104 add_flag_append(CMAKE_Pascal_LINK_FLAGS "-k-rpath -k${CMAKE_INSTALL_RPATH}") |
|
105 endif() |
100 endif(APPLE) |
106 endif(APPLE) |
101 |
107 |
102 if(MINGW) |
108 if(MINGW) |
103 #this flags prevents a few dll hell problems |
109 #this flags prevents a few dll hell problems |
104 add_flag_append(CMAKE_C_FLAGS "-static-libgcc") |
110 add_flag_append(CMAKE_C_FLAGS "-static-libgcc") |