22 option(NOSERVER "Disable gameServer build (off)]" OFF) |
22 option(NOSERVER "Disable gameServer build (off)]" OFF) |
23 option(NOPNG "Disable screenshoot compression (off)" OFF) |
23 option(NOPNG "Disable screenshoot compression (off)" OFF) |
24 option(NOVIDEOREC "Disable video recording (off)" OFF) |
24 option(NOVIDEOREC "Disable video recording (off)" OFF) |
25 |
25 |
26 #set this to ON when 2.1.0 becomes more widespread (and only for linux) |
26 #set this to ON when 2.1.0 becomes more widespread (and only for linux) |
27 option(SYSTEM_PHYSFS "Use system physfs (off)" OFF) |
27 option(PHYSFS_SYSTEM "Use system physfs (off)" OFF) |
28 |
28 |
29 option(LIBENGINE "Enable hwengine library (off)" OFF) |
29 option(LIBENGINE "Enable hwengine library (off)" OFF) |
30 option(ANDROID "Enable Android build (off)" OFF) |
30 option(ANDROID "Enable Android build (off)" OFF) |
31 |
31 |
32 if(UNIX AND NOT APPLE) |
32 if(UNIX AND NOT APPLE) |
86 |
86 |
87 #versioning |
87 #versioning |
88 set(CPACK_PACKAGE_VERSION_MAJOR 0) |
88 set(CPACK_PACKAGE_VERSION_MAJOR 0) |
89 set(CPACK_PACKAGE_VERSION_MINOR 9) |
89 set(CPACK_PACKAGE_VERSION_MINOR 9) |
90 set(CPACK_PACKAGE_VERSION_PATCH 19) |
90 set(CPACK_PACKAGE_VERSION_PATCH 19) |
91 set(HEDGEWARS_PROTO_VER 44) |
91 set(HEDGEWARS_PROTO_VER 45) |
92 set(HEDGEWARS_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") |
92 set(HEDGEWARS_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") |
93 set(required_clang_version 3.0) |
93 set(required_clang_version 3.0) |
94 |
94 |
95 message(STATUS "Building ${HEDGEWARS_VERSION}-r${HEDGEWARS_REVISION} (${HEDGEWARS_HASH})") |
95 message(STATUS "Building ${HEDGEWARS_VERSION}-r${HEDGEWARS_REVISION} (${HEDGEWARS_HASH})") |
96 |
96 |
196 #CMAKE_OSX_SYSROOT is set at the system version we are supposed to build on |
196 #CMAKE_OSX_SYSROOT is set at the system version we are supposed to build on |
197 #we need to provide the correct one when host and target differ |
197 #we need to provide the correct one when host and target differ |
198 if(NOT ${minimum_macosx_version} VERSION_EQUAL ${current_macosx_version}) |
198 if(NOT ${minimum_macosx_version} VERSION_EQUAL ${current_macosx_version}) |
199 if(minimum_macosx_version VERSION_EQUAL "10.4") |
199 if(minimum_macosx_version VERSION_EQUAL "10.4") |
200 set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.4u.sdk/") |
200 set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.4u.sdk/") |
201 set(CMAKE_C_COMPILER "gcc-4.0") |
201 set(CMAKE_C_COMPILER "/Developer/usr/bin/gcc-4.0") |
202 set(CMAKE_CXX_COMPILER "g++-4.0") |
202 set(CMAKE_CXX_COMPILER "/Developer/usr/bin/g++-4.0") |
203 else() |
203 else() |
204 string(REGEX REPLACE "([0-9]+.[0-9]+).[0-9]+" "\\1" sdk_version ${minimum_macosx_version}) |
204 string(REGEX REPLACE "([0-9]+.[0-9]+).[0-9]+" "\\1" sdk_version ${minimum_macosx_version}) |
205 set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX${sdk_version}.sdk/") |
205 set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX${sdk_version}.sdk/") |
206 endif() |
206 endif() |
207 endif() |
207 endif() |
225 endif (CMAKE_BUILD_TYPE) |
225 endif (CMAKE_BUILD_TYPE) |
226 |
226 |
227 |
227 |
228 #set default flags values for all projects (unless MINIMAL_FLAGS is true) |
228 #set default flags values for all projects (unless MINIMAL_FLAGS is true) |
229 if(NOT ${MINIMAL_FLAGS}) |
229 if(NOT ${MINIMAL_FLAGS}) |
|
230 if(WINDOWS) |
|
231 #this flags prevents a few dll hell problems |
|
232 set(CMAKE_C_FLAGS "-static-libgcc ${CMAKE_C_FLAGS}") |
|
233 endif(WINDOWS) |
230 set(CMAKE_C_FLAGS "-pipe ${CMAKE_C_FLAGS}") |
234 set(CMAKE_C_FLAGS "-pipe ${CMAKE_C_FLAGS}") |
231 set(CMAKE_C_FLAGS_RELEASE "-w -Os -fomit-frame-pointer ${CMAKE_C_FLAGS_RELEASE}") |
235 set(CMAKE_C_FLAGS_RELEASE "-w -Os -fomit-frame-pointer ${CMAKE_C_FLAGS_RELEASE}") |
232 set(CMAKE_C_FLAGS_DEBUG "-Wall -O0 -g -DDEBUG ${CMAKE_C_FLAGS_DEBUG}") |
236 set(CMAKE_C_FLAGS_DEBUG "-Wall -O0 -g -DDEBUG ${CMAKE_C_FLAGS_DEBUG}") |
233 set(CMAKE_CXX_FLAGS ${CMAKE_C_FLAGS}) |
237 set(CMAKE_CXX_FLAGS ${CMAKE_C_FLAGS}) |
234 set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE}) |
238 set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE}) |
239 set(CMAKE_C_FLAGS_DEBUG "-Wall -DDEBUG") |
243 set(CMAKE_C_FLAGS_DEBUG "-Wall -DDEBUG") |
240 set(CMAKE_CXX_FLAGS_RELEASE "") |
244 set(CMAKE_CXX_FLAGS_RELEASE "") |
241 set(CMAKE_CXX_FLAGS_DEBUG "-Wall -DDEBUG") |
245 set(CMAKE_CXX_FLAGS_DEBUG "-Wall -DDEBUG") |
242 endif() |
246 endif() |
243 |
247 |
244 #TODO: find out why we need this... |
248 |
|
249 #TESTING TIME |
245 include(CheckCCompilerFlag) |
250 include(CheckCCompilerFlag) |
|
251 |
|
252 #check for noexecstack on ELF, should be set on Gentoo and similar |
246 set(CMAKE_REQUIRED_FLAGS "-Wl,-z -Wl,noexecstack") |
253 set(CMAKE_REQUIRED_FLAGS "-Wl,-z -Wl,noexecstack") |
247 check_c_compiler_flag("" HAVE_NOEXECSTACK) #empty because we are testing a linker flag |
254 check_c_compiler_flag("" HAVE_NOEXECSTACK) #empty because we are testing a linker flag |
248 if(HAVE_NOEXECSTACK) |
255 if(HAVE_NOEXECSTACK) |
249 list(APPEND pascal_flags "-k-z" "-knoexecstack") |
256 list(APPEND pascal_flags "-k-z" "-knoexecstack") |
250 if(NOT ${MINIMAL_FLAGS}) |
257 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}") |
251 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}") |
258 endif() |
252 endif() |
259 unset(CMAKE_REQUIRED_FLAGS) |
|
260 |
|
261 #check for ASLR and DEP security features on Windows |
|
262 #both supported in binutils >= 2.20, available since Vista and XP SP2 respectively |
|
263 set(CMAKE_REQUIRED_FLAGS "-Wl,--nxcompat -Wl,--dynamicbase") |
|
264 check_c_compiler_flag("" HAVE_WINASLRDEP) #empty because we are testing a linker flag |
|
265 if(HAVE_WINASLRDEP) |
|
266 list(APPEND pascal_flags "-k--nxcompat" "-k--dynamicbase") |
|
267 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}") |
253 endif() |
268 endif() |
254 unset(CMAKE_REQUIRED_FLAGS) |
269 unset(CMAKE_REQUIRED_FLAGS) |
255 |
270 |
256 #parse additional parameters |
271 #parse additional parameters |
257 if(FPFLAGS OR GHFLAGS) |
272 if(FPFLAGS OR GHFLAGS) |
258 if(${allow_parse_args}) |
273 if(${allow_parse_args}) |
259 message(${WARNING} "FPFLAGS and GHFLAGS are available only when using CMake >= 2.8") |
|
260 else() |
|
261 separate_arguments(fpflags_parsed UNIX_COMMAND ${FPFLAGS}) |
274 separate_arguments(fpflags_parsed UNIX_COMMAND ${FPFLAGS}) |
262 separate_arguments(ghflags_parsed UNIX_COMMAND ${GHFLAGS}) |
275 separate_arguments(ghflags_parsed UNIX_COMMAND ${GHFLAGS}) |
|
276 else() |
|
277 message(${WARNING} "FPFLAGS and GHFLAGS are available only when using CMake >= 2.8") |
263 endif() |
278 endif() |
264 endif() |
279 endif() |
265 |
280 |
266 list(APPEND pascal_flags ${fpflags_parsed} # user flags |
281 list(APPEND pascal_flags ${fpflags_parsed} # user flags |
267 "-B" # compile all units |
282 "-B" # compile all units |