author | Wuzzy <almikes@aol.com> |
Wed, 20 Apr 2016 18:42:40 +0200 | |
changeset 12031 | 0b0578c25470 |
parent 11362 | ed5a6478e710 |
child 15333 | 5b2dec63f4cf |
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) |
9517
217eacb69395
fail early when an incompatible cmake version is found
koda
parents:
9339
diff
changeset
|
3 |
if(${CMAKE_VERSION} VERSION_GREATER "2.8.10.2" AND |
217eacb69395
fail early when an incompatible cmake version is found
koda
parents:
9339
diff
changeset
|
4 |
${CMAKE_VERSION} VERSION_LESS "2.8.12.1") |
217eacb69395
fail early when an incompatible cmake version is found
koda
parents:
9339
diff
changeset
|
5 |
message(FATAL_ERROR "This version of CMake is known *not* to work, please update or use a lower version") |
217eacb69395
fail early when an incompatible cmake version is found
koda
parents:
9339
diff
changeset
|
6 |
endif() |
217eacb69395
fail early when an incompatible cmake version is found
koda
parents:
9339
diff
changeset
|
7 |
|
9150
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
8 |
set(CMAKE_FIND_FRAMEWORK "FIRST") |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
9 |
|
9268 | 10 |
#what system are we building for |
9150
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
11 |
set(minimum_macosx_version $ENV{MACOSX_DEPLOYMENT_TARGET}) |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
12 |
|
9268 | 13 |
#detect on which system we are: if sw_vers cannot be found for any reason (re)use minimum_macosx_version |
9150
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
14 |
find_program(sw_vers sw_vers) |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
15 |
if(sw_vers) |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
16 |
execute_process(COMMAND ${sw_vers} "-productVersion" |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
17 |
OUTPUT_VARIABLE current_macosx_version |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
18 |
OUTPUT_STRIP_TRAILING_WHITESPACE) |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
19 |
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
|
20 |
else() |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
21 |
if(NOT minimum_macosx_version) |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
22 |
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
|
23 |
else() |
9151 | 24 |
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
|
25 |
set(current_macosx_version ${minimum_macosx_version}) |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
26 |
endif() |
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 |
|
9268 | 29 |
#if nothing is set, we deploy only for the current system |
9150
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
30 |
if(NOT minimum_macosx_version) |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
31 |
set(minimum_macosx_version ${current_macosx_version}) |
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 |
|
9858
343d12172070
drop 10.4 support, needed after introduction of @rpath
koda
parents:
9673
diff
changeset
|
34 |
#10.3 systems don't have enough processing power anyway |
343d12172070
drop 10.4 support, needed after introduction of @rpath
koda
parents:
9673
diff
changeset
|
35 |
#10.4 does not have @rpath support (which SDL uses) |
343d12172070
drop 10.4 support, needed after introduction of @rpath
koda
parents:
9673
diff
changeset
|
36 |
if(minimum_macosx_version VERSION_LESS "10.5") |
343d12172070
drop 10.4 support, needed after introduction of @rpath
koda
parents:
9673
diff
changeset
|
37 |
message(FATAL_ERROR "Hedgewars is not supported on your version of Mac OS X") |
9150
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
38 |
endif() |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
39 |
|
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
40 |
if(NOT CMAKE_OSX_ARCHITECTURES) |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
41 |
if(current_macosx_version VERSION_LESS "10.6") |
9858
343d12172070
drop 10.4 support, needed after introduction of @rpath
koda
parents:
9673
diff
changeset
|
42 |
#SDL is only 32 bit on older OS version |
9150
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
43 |
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "powerpc*") |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
44 |
set(CMAKE_OSX_ARCHITECTURES "ppc7400") |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
45 |
else() |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
46 |
set(CMAKE_OSX_ARCHITECTURES "i386") |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
47 |
endif() |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
48 |
endif() |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
49 |
endif() |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
50 |
|
9271 | 51 |
#parse this system variable and adjust only the powerpc syntax to be compatible with -P |
52 |
if(CMAKE_OSX_ARCHITECTURES) |
|
53 |
string(REGEX MATCH "[pP][pP][cC]+" powerpc_build "${CMAKE_OSX_ARCHITECTURES}") |
|
54 |
string(REGEX MATCH "[iI]386+" i386_build "${CMAKE_OSX_ARCHITECTURES}") |
|
55 |
string(REGEX MATCH "[xX]86_64+" x86_64_build "${CMAKE_OSX_ARCHITECTURES}") |
|
56 |
if(x86_64_build) |
|
57 |
add_flag_prepend(CMAKE_Pascal_FLAGS -Px86_64) |
|
58 |
elseif(i386_build) |
|
59 |
add_flag_prepend(CMAKE_Pascal_FLAGS -Pi386) |
|
60 |
elseif(powerpc_build) |
|
61 |
add_flag_prepend(CMAKE_Pascal_FLAGS -Ppowerpc) |
|
62 |
else() |
|
63 |
message(FATAL_ERROR "Unknown architecture present in CMAKE_OSX_ARCHITECTURES (${CMAKE_OSX_ARCHITECTURES})") |
|
64 |
endif() |
|
65 |
list(LENGTH CMAKE_OSX_ARCHITECTURES num_of_archs) |
|
66 |
if(num_of_archs GREATER 1) |
|
9889 | 67 |
message("*** Only one architecture in CMAKE_OSX_ARCHITECTURES is supported, picking the first one ***") |
9271 | 68 |
endif() |
69 |
elseif(CMAKE_SIZEOF_VOID_P MATCHES "8") |
|
70 |
#if that variable is not set check if we are on x86_64 and if so force it, else use default |
|
71 |
add_flag_prepend(CMAKE_Pascal_FLAGS -Px86_64) |
|
72 |
endif() |
|
73 |
||
9268 | 74 |
#CMAKE_OSX_SYSROOT is set at the system version we are supposed to build on |
75 |
#we need to provide the correct one when host and target differ |
|
9940 | 76 |
if(NOT CMAKE_OSX_SYSROOT AND |
77 |
NOT ${minimum_macosx_version} VERSION_EQUAL ${current_macosx_version}) |
|
9887
6add6157b58e
improve OSX SDK selection when build and deploy target don't match
koda
parents:
9860
diff
changeset
|
78 |
find_program(xcrun xcrun) |
6add6157b58e
improve OSX SDK selection when build and deploy target don't match
koda
parents:
9860
diff
changeset
|
79 |
if(xcrun) |
6add6157b58e
improve OSX SDK selection when build and deploy target don't match
koda
parents:
9860
diff
changeset
|
80 |
execute_process(COMMAND ${xcrun} "--show-sdk-path" |
6add6157b58e
improve OSX SDK selection when build and deploy target don't match
koda
parents:
9860
diff
changeset
|
81 |
OUTPUT_VARIABLE current_sdk_path |
6add6157b58e
improve OSX SDK selection when build and deploy target don't match
koda
parents:
9860
diff
changeset
|
82 |
OUTPUT_STRIP_TRAILING_WHITESPACE) |
6add6157b58e
improve OSX SDK selection when build and deploy target don't match
koda
parents:
9860
diff
changeset
|
83 |
string(REPLACE "${current_macosx_version}" |
6add6157b58e
improve OSX SDK selection when build and deploy target don't match
koda
parents:
9860
diff
changeset
|
84 |
"${minimum_macosx_version}" |
6add6157b58e
improve OSX SDK selection when build and deploy target don't match
koda
parents:
9860
diff
changeset
|
85 |
CMAKE_OSX_SYSROOT |
6add6157b58e
improve OSX SDK selection when build and deploy target don't match
koda
parents:
9860
diff
changeset
|
86 |
"${current_sdk_path}") |
9150
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
87 |
else() |
9887
6add6157b58e
improve OSX SDK selection when build and deploy target don't match
koda
parents:
9860
diff
changeset
|
88 |
message("*** xcrun not found! Build will work on ${current_macosx_version} only ***") |
9150
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
89 |
endif() |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
90 |
endif() |
9940 | 91 |
if(CMAKE_OSX_SYSROOT) |
9268 | 92 |
add_flag_append(CMAKE_Pascal_FLAGS "-XR${CMAKE_OSX_SYSROOT}") |
93 |
add_flag_append(CMAKE_Pascal_FLAGS "-k-macosx_version_min -k${minimum_macosx_version}") |
|
9941
d33d4727b39e
explicitly set linker library path for pascal when deploying an older version
koda
parents:
9940
diff
changeset
|
94 |
add_flag_append(CMAKE_Pascal_FLAGS "-k-L${LIBRARY_OUTPUT_PATH} -Fl${LIBRARY_OUTPUT_PATH}") |
9150
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
95 |
endif() |
9339
14f5f3a1e2f7
some work on cmake_pascal files to better support flags we use, make engine compile as library again
koda
parents:
9297
diff
changeset
|
96 |
|
14f5f3a1e2f7
some work on cmake_pascal files to better support flags we use, make engine compile as library again
koda
parents:
9297
diff
changeset
|
97 |
#add user framework directory |
14f5f3a1e2f7
some work on cmake_pascal files to better support flags we use, make engine compile as library again
koda
parents:
9297
diff
changeset
|
98 |
add_flag_append(CMAKE_Pascal_FLAGS "-Ff~/Library/Frameworks") |
9705
322fe1736347
fix linking on osx by hardcoding the default library output path
koda
parents:
9673
diff
changeset
|
99 |
|
9860
d419ff107e15
include paths before platform, move config code around
koda
parents:
9858
diff
changeset
|
100 |
#workaround older cmake versions |
d419ff107e15
include paths before platform, move config code around
koda
parents:
9858
diff
changeset
|
101 |
if(${CMAKE_VERSION} VERSION_LESS "2.8.12") |
d419ff107e15
include paths before platform, move config code around
koda
parents:
9858
diff
changeset
|
102 |
add_flag_append(CMAKE_C_LINK_FLAGS "-Wl,-rpath -Wl,${CMAKE_INSTALL_RPATH}") |
d419ff107e15
include paths before platform, move config code around
koda
parents:
9858
diff
changeset
|
103 |
add_flag_append(CMAKE_CXX_LINK_FLAGS "-Wl,-rpath -Wl,${CMAKE_INSTALL_RPATH}") |
d419ff107e15
include paths before platform, move config code around
koda
parents:
9858
diff
changeset
|
104 |
add_flag_append(CMAKE_Pascal_LINK_FLAGS "-k-rpath -k${CMAKE_INSTALL_RPATH}") |
d419ff107e15
include paths before platform, move config code around
koda
parents:
9858
diff
changeset
|
105 |
endif() |
9150
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
106 |
endif(APPLE) |
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
107 |
|
9210 | 108 |
if(MINGW) |
9150
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
109 |
#this flags prevents a few dll hell problems |
9268 | 110 |
add_flag_append(CMAKE_C_FLAGS "-static-libgcc") |
111 |
add_flag_append(CMAKE_CXX_FLAGS "-static-libgcc") |
|
9210 | 112 |
endif(MINGW) |
9150
79c58ff0d4b1
move platform specific and revision info code into separate cmake modules
koda
parents:
diff
changeset
|
113 |
|
9210 | 114 |
if(WIN32) |
9218 | 115 |
if(NOT ${BUILD_SHARED_LIB}) |
9210 | 116 |
message(FATAL_ERROR "Static linking is not supported on Windows") |
117 |
endif() |
|
118 |
endif(WIN32) |
|
9673 | 119 |
|
120 |
if(UNIX) |
|
121 |
add_flag_append(CMAKE_C_FLAGS "-fPIC") |
|
122 |
add_flag_append(CMAKE_CXX_FLAGS "-fPIC") |
|
123 |
endif(UNIX) |