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