68 set(target_dir ".") |
68 set(target_dir ".") |
69 |
69 |
70 #what system are we building for |
70 #what system are we building for |
71 set(minimum_macosx_version $ENV{MACOSX_DEPLOYMENT_TARGET}) |
71 set(minimum_macosx_version $ENV{MACOSX_DEPLOYMENT_TARGET}) |
72 |
72 |
73 #detect on which system are we |
73 #detect on which system we are: if sw_vers cannot be found for any reason (re)use minimum_macosx_version |
74 EXEC_PROGRAM("/usr/bin/sw_vers" ARGS "-productVersion" OUTPUT_VARIABLE current_macosx_version) |
74 find_program(sw_vers sw_vers) |
75 STRING(REGEX REPLACE "([0-9]+.[0-9]+).[0-9]+" "\\1" current_macosx_version ${current_macosx_version}) |
75 if(sw_vers) |
|
76 exec_program(${sw_vers} ARGS "-productVersion" OUTPUT_VARIABLE current_macosx_version) |
|
77 string(REGEX REPLACE "([0-9]+.[0-9]+).[0-9]+" "\\1" current_macosx_version ${current_macosx_version}) |
|
78 else() |
|
79 if(NOT minimum_macosx_version) |
|
80 message(FATAL_ERROR "sw_vers not found! Need explicit MACOSX_DEPLOYMENT_TARGET variable set") |
|
81 else() |
|
82 set(current_macosx_version ${minimum_macosx_version}) |
|
83 endif() |
|
84 endif() |
76 |
85 |
77 #if nothing is set, we deploy only for the current system |
86 #if nothing is set, we deploy only for the current system |
78 if(NOT minimum_macosx_version) |
87 if(NOT minimum_macosx_version) |
79 set(minimum_macosx_version ${current_macosx_version}) |
88 set(minimum_macosx_version ${current_macosx_version}) |
80 endif() |
89 endif() |
82 #lower systems don't have enough processing power anyways |
91 #lower systems don't have enough processing power anyways |
83 if (minimum_macosx_version LESS "10.4") |
92 if (minimum_macosx_version LESS "10.4") |
84 message(FATAL_ERROR "Hedgewars is not supported on Mac OS X pre-10.4") |
93 message(FATAL_ERROR "Hedgewars is not supported on Mac OS X pre-10.4") |
85 endif() |
94 endif() |
86 |
95 |
87 #this variable needs to be set for freepascal universal binary |
96 #workaround for http://playcontrol.net/ewing/jibberjabber/big_behind-the-scenes_chang.html#SDL_mixer (Update 2) |
|
97 if(current_macosx_version MATCHES "10.4") |
|
98 find_package(SDL_mixer REQUIRED) |
|
99 set(DYLIB_SMPEG "-dylib_file @loader_path/Frameworks/smpeg.framework/Versions/A/smpeg:${SDLMIXER_LIBRARY}/Versions/A/Frameworks/smpeg.framework/Versions/A/smpeg") |
|
100 set(DYLIB_MIKMOD "-dylib_file @loader_path/Frameworks/mikmod.framework/Versions/A/mikmod:${SDLMIXER_LIBRARY}/Versions/A/Frameworks/mikmod.framework/Versions/A/mikmod") |
|
101 set(pascal_flags "-k${DYLIB_SMPEG}" "-k${DYLIB_MIKMOD}" ${pascal_flags}) |
|
102 set(CMAKE_C_FLAGS "${DYLIB_SMPEG}" "${DYLIB_MIKMOD}" ${CMAKE_C_FLAGS}) |
|
103 endif() |
|
104 |
|
105 #CMAKE_OSX_ARCHITECTURES and CMAKE_OSX_SYSROOT need to be set for universal binary and correct linking |
88 if(NOT CMAKE_OSX_ARCHITECTURES) |
106 if(NOT CMAKE_OSX_ARCHITECTURES) |
89 if(current_macosx_version LESS "10.6") |
107 if(current_macosx_version LESS "10.6") |
90 if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "powerpc*") |
108 if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "powerpc*") |
91 set(CMAKE_OSX_ARCHITECTURES "ppc7400") |
109 set(CMAKE_OSX_ARCHITECTURES "ppc7400") |
92 else() |
110 else() |
95 else() |
113 else() |
96 set(CMAKE_OSX_ARCHITECTURES "x86_64") |
114 set(CMAKE_OSX_ARCHITECTURES "x86_64") |
97 endif() |
115 endif() |
98 endif() |
116 endif() |
99 |
117 |
100 #be sure to select ppc-compatible toolchains just in case |
118 #CMAKE_OSX_SYSROOT is set at the system version we are supposed to build on |
101 if(minimum_macosx_version LESS "10.6") |
119 #we need to provide the correct one when host and target differ |
102 set(CMAKE_C_COMPILER "gcc-4.0") |
120 if(NOT ${minimum_macosx_version} MATCHES ${current_macosx_version}) |
103 set(CMAKE_CXX_COMPILER "g++-4.0") |
121 if(minimum_macosx_version MATCHES "10.4") |
104 endif() |
122 set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.4u.sdk/") |
105 |
123 set(CMAKE_C_COMPILER "gcc-4.0") |
106 if(minimum_macosx_version MATCHES "10.4") |
124 set(CMAKE_CXX_COMPILER "g++-4.0") |
107 set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.4u.sdk/") |
125 else() |
108 #workaround for http://playcontrol.net/ewing/jibberjabber/big_behind-the-scenes_chang.html#SDL_mixer (Update 2) |
126 string(REGEX REPLACE "([0-9]+.[0-9]+).[0-9]+" "\\1" sdk_version ${minimum_macosx_version}) |
109 if(current_macosx_version MATCHES "10.4") |
127 set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX${sdk_version}.sdk/") |
110 find_package(SDL_mixer REQUIRED) |
|
111 set(DYLIB_SMPEG "-dylib_file @loader_path/Frameworks/smpeg.framework/Versions/A/smpeg:${SDLMIXER_LIBRARY}/Versions/A/Frameworks/smpeg.framework/Versions/A/smpeg") |
|
112 set(DYLIB_MIKMOD "-dylib_file @loader_path/Frameworks/mikmod.framework/Versions/A/mikmod:${SDLMIXER_LIBRARY}/Versions/A/Frameworks/mikmod.framework/Versions/A/mikmod") |
|
113 set(pascal_flags "-k${DYLIB_SMPEG}" "-k${DYLIB_MIKMOD}" ${pascal_flags}) |
|
114 set(CMAKE_C_FLAGS "${DYLIB_SMPEG}" "${DYLIB_MIKMOD}" ${CMAKE_C_FLAGS}) |
|
115 endif() |
128 endif() |
116 else() |
129 endif() |
117 STRING(REGEX REPLACE "([0-9]+.[0-9]+).[0-9]+" "\\1" sdk_version ${minimum_macosx_version}) |
130 |
118 set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX${sdk_version}.sdk/") |
131 #add user framework directory, other paths can be passed via FPFLAGS |
119 endif() |
|
120 |
|
121 #add user framework directory |
|
122 set(pascal_flags "-Ff~/Library/Frameworks" ${pascal_flags}) |
132 set(pascal_flags "-Ff~/Library/Frameworks" ${pascal_flags}) |
123 #set deployment target |
133 #set deployment target |
124 set(pascal_flags "-k-macosx_version_min" "-k${minimum_macosx_version}" "-XR${CMAKE_OSX_SYSROOT}" ${pascal_flags}) |
134 set(pascal_flags "-k-macosx_version_min" "-k${minimum_macosx_version}" "-XR${CMAKE_OSX_SYSROOT}" ${pascal_flags}) |
125 |
135 |
126 message(STATUS "Build system: Mac OS X ${current_macosx_version} with GCC:${CMAKE_C_COMPILER}") |
136 message(STATUS "Build system: Mac OS X ${current_macosx_version} with GCC:${CMAKE_C_COMPILER}") |