|
1 |
|
2 if(APPLE) |
|
3 set(CMAKE_FIND_FRAMEWORK "FIRST") |
|
4 |
|
5 #what system are we building for |
|
6 set(minimum_macosx_version $ENV{MACOSX_DEPLOYMENT_TARGET}) |
|
7 |
|
8 #detect on which system we are: if sw_vers cannot be found for any reason (re)use minimum_macosx_version |
|
9 find_program(sw_vers sw_vers) |
|
10 if(sw_vers) |
|
11 execute_process(COMMAND ${sw_vers} "-productVersion" |
|
12 OUTPUT_VARIABLE current_macosx_version |
|
13 OUTPUT_STRIP_TRAILING_WHITESPACE) |
|
14 string(REGEX REPLACE "([0-9]+.[0-9]+).[0-9]+" "\\1" current_macosx_version ${current_macosx_version}) |
|
15 else() |
|
16 if(NOT minimum_macosx_version) |
|
17 message(FATAL_ERROR "sw_vers not found! Need explicit MACOSX_DEPLOYMENT_TARGET variable set") |
|
18 else() |
|
19 message(${WARNING} "sw_vers not found! Fallback to MACOSX_DEPLOYMENT_TARGET variable") |
|
20 set(current_macosx_version ${minimum_macosx_version}) |
|
21 endif() |
|
22 endif() |
|
23 |
|
24 #if nothing is set, we deploy only for the current system |
|
25 if(NOT minimum_macosx_version) |
|
26 set(minimum_macosx_version ${current_macosx_version}) |
|
27 endif() |
|
28 |
|
29 #lower systems don't have enough processing power anyway |
|
30 if (minimum_macosx_version VERSION_LESS "10.4") |
|
31 message(FATAL_ERROR "Hedgewars is not supported on Mac OS X pre-10.4") |
|
32 endif() |
|
33 |
|
34 #workaround for http://playcontrol.net/ewing/jibberjabber/big_behind-the-scenes_chang.html#SDL_mixer (Update 2) |
|
35 if(current_macosx_version VERSION_EQUAL "10.4") |
|
36 find_package(SDL_mixer REQUIRED) |
|
37 set(DYLIB_SMPEG "-dylib_file @loader_path/Frameworks/smpeg.framework/Versions/A/smpeg:${SDLMIXER_LIBRARY}/Versions/A/Frameworks/smpeg.framework/Versions/A/smpeg") |
|
38 set(DYLIB_MIKMOD "-dylib_file @loader_path/Frameworks/mikmod.framework/Versions/A/mikmod:${SDLMIXER_LIBRARY}/Versions/A/Frameworks/mikmod.framework/Versions/A/mikmod") |
|
39 set(CMAKE_C_FLAGS "${DYLIB_SMPEG} ${DYLIB_MIKMOD}") |
|
40 list(APPEND pascal_flags "-k${DYLIB_SMPEG}" "-k${DYLIB_MIKMOD}") |
|
41 endif() |
|
42 |
|
43 #CMAKE_OSX_ARCHITECTURES and CMAKE_OSX_SYSROOT need to be set for universal binary and correct linking |
|
44 if(NOT CMAKE_OSX_ARCHITECTURES) |
|
45 if(current_macosx_version VERSION_LESS "10.6") |
|
46 if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "powerpc*") |
|
47 set(CMAKE_OSX_ARCHITECTURES "ppc7400") |
|
48 else() |
|
49 set(CMAKE_OSX_ARCHITECTURES "i386") |
|
50 endif() |
|
51 else() |
|
52 set(CMAKE_OSX_ARCHITECTURES "x86_64") |
|
53 endif() |
|
54 endif() |
|
55 |
|
56 #CMAKE_OSX_SYSROOT is set at the system version we are supposed to build on |
|
57 #we need to provide the correct one when host and target differ |
|
58 if(NOT ${minimum_macosx_version} VERSION_EQUAL ${current_macosx_version}) |
|
59 if(minimum_macosx_version VERSION_EQUAL "10.4") |
|
60 set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.4u.sdk/") |
|
61 set(CMAKE_C_COMPILER "/Developer/usr/bin/gcc-4.0") |
|
62 set(CMAKE_CXX_COMPILER "/Developer/usr/bin/g++-4.0") |
|
63 else() |
|
64 string(REGEX REPLACE "([0-9]+.[0-9]+).[0-9]+" "\\1" sdk_version ${minimum_macosx_version}) |
|
65 set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX${sdk_version}.sdk/") |
|
66 endif() |
|
67 endif() |
|
68 |
|
69 #add user framework directory, other paths can be passed via FPFLAGS |
|
70 list(APPEND pascal_flags "-Ff~/Library/Frameworks") |
|
71 #set deployment target |
|
72 list(APPEND pascal_flags "-k-macosx_version_min" "-k${minimum_macosx_version}" "-XR${CMAKE_OSX_SYSROOT}") |
|
73 |
|
74 endif(APPLE) |
|
75 |
|
76 if(WINDOWS) |
|
77 #this flags prevents a few dll hell problems |
|
78 set(CMAKE_C_FLAGS "-static-libgcc ${CMAKE_C_FLAGS}") |
|
79 endif(WINDOWS) |
|
80 |