14 cmake_policy(SET ${hwpolicy} NEW) |
14 cmake_policy(SET ${hwpolicy} NEW) |
15 endif() |
15 endif() |
16 endforeach() |
16 endforeach() |
17 |
17 |
18 set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules") |
18 set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules") |
19 |
19 include(${CMAKE_MODULE_PATH}/utils.cmake) |
20 |
20 |
21 #possible cmake configuration |
21 #possible cmake configuration |
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) |
159 if(current_macosx_version VERSION_EQUAL "10.4") |
159 if(current_macosx_version VERSION_EQUAL "10.4") |
160 find_package(SDL_mixer REQUIRED) |
160 find_package(SDL_mixer REQUIRED) |
161 set(DYLIB_SMPEG "-dylib_file @loader_path/Frameworks/smpeg.framework/Versions/A/smpeg:${SDLMIXER_LIBRARY}/Versions/A/Frameworks/smpeg.framework/Versions/A/smpeg") |
161 set(DYLIB_SMPEG "-dylib_file @loader_path/Frameworks/smpeg.framework/Versions/A/smpeg:${SDLMIXER_LIBRARY}/Versions/A/Frameworks/smpeg.framework/Versions/A/smpeg") |
162 set(DYLIB_MIKMOD "-dylib_file @loader_path/Frameworks/mikmod.framework/Versions/A/mikmod:${SDLMIXER_LIBRARY}/Versions/A/Frameworks/mikmod.framework/Versions/A/mikmod") |
162 set(DYLIB_MIKMOD "-dylib_file @loader_path/Frameworks/mikmod.framework/Versions/A/mikmod:${SDLMIXER_LIBRARY}/Versions/A/Frameworks/mikmod.framework/Versions/A/mikmod") |
163 set(CMAKE_C_FLAGS "${DYLIB_SMPEG} ${DYLIB_MIKMOD}") |
163 set(CMAKE_C_FLAGS "${DYLIB_SMPEG} ${DYLIB_MIKMOD}") |
164 list(APPEND pascal_flags "-k${DYLIB_SMPEG}" "-k${DYLIB_MIKMOD}") |
164 add_flag_append(CMAKE_Pascal_FLAGS "-k${DYLIB_SMPEG}" "-k${DYLIB_MIKMOD}") |
165 endif() |
165 endif() |
166 |
166 |
167 #CMAKE_OSX_ARCHITECTURES and CMAKE_OSX_SYSROOT need to be set for universal binary and correct linking |
167 #CMAKE_OSX_ARCHITECTURES and CMAKE_OSX_SYSROOT need to be set for universal binary and correct linking |
168 if(NOT CMAKE_OSX_ARCHITECTURES) |
168 if(NOT CMAKE_OSX_ARCHITECTURES) |
169 if(current_macosx_version VERSION_LESS "10.6") |
169 if(current_macosx_version VERSION_LESS "10.6") |
188 string(REGEX REPLACE "([0-9]+.[0-9]+).[0-9]+" "\\1" sdk_version ${minimum_macosx_version}) |
188 string(REGEX REPLACE "([0-9]+.[0-9]+).[0-9]+" "\\1" sdk_version ${minimum_macosx_version}) |
189 set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX${sdk_version}.sdk/") |
189 set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX${sdk_version}.sdk/") |
190 endif() |
190 endif() |
191 endif() |
191 endif() |
192 |
192 |
193 #add user framework directory, other paths can be passed via FPFLAGS |
|
194 list(APPEND pascal_flags "-Ff~/Library/Frameworks") |
|
195 #set deployment target |
193 #set deployment target |
196 list(APPEND pascal_flags "-k-macosx_version_min" "-k${minimum_macosx_version}" "-XR${CMAKE_OSX_SYSROOT}") |
194 add_flag_append(CMAKE_Pascal_FLAGS "-k-macosx_version_min -k${minimum_macosx_version} ") |
197 endif(APPLE) |
195 endif(APPLE) |
198 |
196 |
199 |
197 |
200 #when build type is not specified, assume Debug/Release according to build version information |
198 #when build type is not specified, assume Debug/Release according to build version information |
201 if (CMAKE_BUILD_TYPE) |
199 if (CMAKE_BUILD_TYPE) |
228 #TODO: find out why we need this... |
226 #TODO: find out why we need this... |
229 include(CheckCCompilerFlag) |
227 include(CheckCCompilerFlag) |
230 set(CMAKE_REQUIRED_FLAGS "-Wl,-z -Wl,noexecstack") |
228 set(CMAKE_REQUIRED_FLAGS "-Wl,-z -Wl,noexecstack") |
231 check_c_compiler_flag("" HAVE_NOEXECSTACK) #empty because we are testing a linker flag |
229 check_c_compiler_flag("" HAVE_NOEXECSTACK) #empty because we are testing a linker flag |
232 if(HAVE_NOEXECSTACK) |
230 if(HAVE_NOEXECSTACK) |
233 list(APPEND pascal_flags "-k-z" "-knoexecstack") |
231 add_flag_append(CMAKE_Pascal_FLAGS "-k-z -knoexecstack") |
234 if(NOT ${MINIMAL_FLAGS}) |
232 if(NOT ${MINIMAL_FLAGS}) |
235 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}") |
233 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}") |
236 endif() |
234 endif() |
237 endif() |
235 endif() |
238 unset(CMAKE_REQUIRED_FLAGS) |
236 unset(CMAKE_REQUIRED_FLAGS) |
245 separate_arguments(fpflags_parsed UNIX_COMMAND ${FPFLAGS}) |
243 separate_arguments(fpflags_parsed UNIX_COMMAND ${FPFLAGS}) |
246 separate_arguments(ghflags_parsed UNIX_COMMAND ${GHFLAGS}) |
244 separate_arguments(ghflags_parsed UNIX_COMMAND ${GHFLAGS}) |
247 endif() |
245 endif() |
248 endif() |
246 endif() |
249 |
247 |
250 list(APPEND pascal_flags ${fpflags_parsed} # user flags |
248 |
251 "-B" # compile all units |
|
252 "-vm4079,4080,4081" # fpc verbosity output format |
|
253 "-FE${PROJECT_BINARY_DIR}/bin" # fpc binaries output directory |
|
254 "-FU${PROJECT_BINARY_DIR}/hedgewars" # fpc units output directory |
|
255 "-Fl${PROJECT_BINARY_DIR}/bin" # fpc linking directory (win/unix) |
|
256 "-Fi${PROJECT_BINARY_DIR}/hedgewars" # fpc .inc path (for out of source builds) |
|
257 "-k-L${PROJECT_BINARY_DIR}/bin" # ld linking directory (unix/osx) |
|
258 "-Cs2000000" # stack size |
|
259 "-vewnq" # fpc output verbosity |
|
260 "-dDEBUGFILE" # macro for engine output |
|
261 ) |
|
262 list(APPEND haskell_flags ${ghflags_parsed} # user flags |
249 list(APPEND haskell_flags ${ghflags_parsed} # user flags |
263 "-O2" # optimise for faster code |
250 "-O2" # optimise for faster code |
264 ) |
251 ) |
265 |
252 |
|
253 add_flag_append(CMAKE_Pascal_FLAGS "-vm4079,4080,4081 -Cs2000000 -vewnq") |
|
254 add_flag_append(CMAKE_Pascal_FLAGS_DEBUG "-O- -g -gl -gv") |
|
255 add_flag_append(CMAKE_Pascal_FLAGS_RELEASE "-Os -Xs -Si") |
266 |
256 |
267 #get BUILD_TYPE and enable/disable optimisation |
257 #get BUILD_TYPE and enable/disable optimisation |
268 message(STATUS "Using ${CMAKE_BUILD_TYPE} configuration") |
258 message(STATUS "Using ${CMAKE_BUILD_TYPE} configuration") |
269 if(CMAKE_BUILD_TYPE MATCHES "DEBUG") |
259 if(CMAKE_BUILD_TYPE MATCHES "DEBUG") |
270 list(APPEND pascal_flags "-O-" # disable all optimisations |
260 |
271 "-g" # enable debug symbols |
|
272 "-gl" # add line info to bt |
|
273 "-gv" # allow valgrind |
|
274 ) |
|
275 list(APPEND haskell_flags "-Wall" # all warnings |
261 list(APPEND haskell_flags "-Wall" # all warnings |
276 "-debug" # debug mode |
262 "-debug" # debug mode |
277 "-dcore-lint" # internal sanity check |
263 "-dcore-lint" # internal sanity check |
278 ) |
264 ) |
279 else() |
265 else() |
280 list(APPEND pascal_flags "-Os" # optimise for size |
|
281 "-Xs" # strip binary |
|
282 "-Si" # turn on inlining |
|
283 ) |
|
284 list(APPEND haskell_flags "-w" # no warnings |
266 list(APPEND haskell_flags "-w" # no warnings |
285 ) |
267 ) |
286 endif() |
268 endif() |
287 |
269 |
288 include(${CMAKE_MODULE_PATH}/utils.cmake) |
270 include(${CMAKE_MODULE_PATH}/utils.cmake) |
293 message(STATUS "Found LUA: ${LUA_DEFAULT}") |
275 message(STATUS "Found LUA: ${LUA_DEFAULT}") |
294 else() |
276 else() |
295 message(STATUS "LUA will be provided by the bundled sources") |
277 message(STATUS "LUA will be provided by the bundled sources") |
296 add_subdirectory(misc/liblua) |
278 add_subdirectory(misc/liblua) |
297 #linking with liblua.a requires system readline |
279 #linking with liblua.a requires system readline |
298 list(APPEND pascal_flags "-k${EXECUTABLE_OUTPUT_PATH}/lib${LUA_LIBRARY}.a" "-k-lreadline") |
280 add_flag_append(CMAKE_Pascal_FLAGS "-k${EXECUTABLE_OUTPUT_PATH}/lib${LUA_LIBRARY}.a -k-lreadline") |
299 endif() |
281 endif() |
300 |
282 |
301 |
283 |
302 #physfs discovery |
284 #physfs discovery |
303 if (${SYSTEM_PHYSFS}) |
285 if (${SYSTEM_PHYSFS}) |
326 endif() |
308 endif() |
327 else() |
309 else() |
328 message(STATUS "PhysFS will be provided by the bundled sources") |
310 message(STATUS "PhysFS will be provided by the bundled sources") |
329 set(physfs_output_name "hw_physfs") |
311 set(physfs_output_name "hw_physfs") |
330 add_subdirectory(misc/libphysfs) |
312 add_subdirectory(misc/libphysfs) |
331 #-XLA is a beta fpc flag that renames libraries before passing them to the linker |
|
332 #we also have to pass PHYSFS_INTERNAL to satisfy windows runtime requirements |
|
333 #(should be harmless on other platforms) |
|
334 set(CMAKE_Pascal_FLAGS "-XLAphysfs=${physfs_output_name} -dPHYSFS_INTERNAL ${CMAKE_Pascal_FLAGS}") |
|
335 endif() |
313 endif() |
336 |
314 |
337 find_package_or_disable_msg(FFMPEG NOVIDEOREC "Video recording will not be built") |
315 find_package_or_disable_msg(FFMPEG NOVIDEOREC "Video recording will not be built") |
338 |
316 |
339 #physfs helper library |
317 #physfs helper library |