17 #set other default values |
17 #set other default values |
18 option(NOSERVER "Disable gameServer build [default: auto]" OFF) |
18 option(NOSERVER "Disable gameServer build [default: auto]" OFF) |
19 option(NOPNG "Disable screenshoot compression [default: auto]" OFF) |
19 option(NOPNG "Disable screenshoot compression [default: auto]" OFF) |
20 option(NOVIDEOREC "Disable video recording [default: auto]" OFF) |
20 option(NOVIDEOREC "Disable video recording [default: auto]" OFF) |
21 |
21 |
|
22 #set this to ON when 2.1.0 becomes more widespread (and only for linux) |
|
23 option(SYSTEM_PHYSFS "Use system physfs [default:off]" OFF) |
|
24 |
22 option(BUILD_ENGINE_LIBRARY "Enable hwengine library [default: off]" OFF) |
25 option(BUILD_ENGINE_LIBRARY "Enable hwengine library [default: off]" OFF) |
23 option(ANDROID "Enable Android build [default: off]" OFF) |
26 option(ANDROID "Enable Android build [default: off]" OFF) |
24 option(NOAUTOUPDATE "Disable OS X Sparkle update checking" OFF) |
27 option(NOAUTOUPDATE "Disable OS X Sparkle update checking" OFF) |
25 option(MINIMAL_FLAGS "Respect system flags as much as possible [default: off]" OFF) |
28 option(MINIMAL_FLAGS "Respect system flags as much as possible [default: off]" OFF) |
|
29 |
26 set(FPFLAGS "" CACHE STRING "Additional Freepascal flags") |
30 set(FPFLAGS "" CACHE STRING "Additional Freepascal flags") |
27 set(GHFLAGS "" CACHE STRING "Additional Haskell flags") |
31 set(GHFLAGS "" CACHE STRING "Additional Haskell flags") |
28 if(UNIX AND NOT APPLE) |
32 if(UNIX AND NOT APPLE) |
29 set(DATA_INSTALL_DIR "share/hedgewars" CACHE STRING "Resource folder path") |
33 set(DATA_INSTALL_DIR "share/hedgewars" CACHE STRING "Resource folder path") |
30 endif() |
34 endif() |
208 separate_arguments(fpflags_parsed UNIX_COMMAND ${FPFLAGS}) |
212 separate_arguments(fpflags_parsed UNIX_COMMAND ${FPFLAGS}) |
209 separate_arguments(ghflags_parsed UNIX_COMMAND ${GHFLAGS}) |
213 separate_arguments(ghflags_parsed UNIX_COMMAND ${GHFLAGS}) |
210 endif() |
214 endif() |
211 endif() |
215 endif() |
212 |
216 |
213 list(APPEND pascal_flags ${fpflags_parsed} # user flags |
217 list(APPEND pascal_flags ${fpflags_parsed} # user flags |
214 "-vm4079,4080,4081" # fpc output format |
218 "-vm4079,4080,4081" # fpc output format |
215 "-B" # compile all units |
219 "-B" # compile all units |
216 "-FE${PROJECT_BINARY_DIR}/bin" # fpc output directory |
220 "-FE${PROJECT_BINARY_DIR}/bin" # fpc output directory |
217 "-Fl${PROJECT_BINARY_DIR}/bin" # fpc linking directory |
221 "-Fl${PROJECT_BINARY_DIR}/bin" # fpc linking directory (win/unix) |
218 "-Cs2000000" # stack size |
222 "-k-L${PROJECT_BINARY_DIR}/bin" # ld linking directory (unix/osx) |
219 "-vewnq" # fpc output verbosity |
223 "-Cs2000000" # stack size |
220 "-dDEBUGFILE" # macro for engine output |
224 "-vewnq" # fpc output verbosity |
|
225 "-dDEBUGFILE" # macro for engine output |
221 ) |
226 ) |
222 list(APPEND haskell_flags "-O2" ${ghflags_parsed}) |
227 list(APPEND haskell_flags "-O2" ${ghflags_parsed}) |
223 |
228 |
224 #get BUILD_TYPE and enable/disable optimisation |
229 #get BUILD_TYPE and enable/disable optimisation |
225 message(STATUS "Using ${CMAKE_BUILD_TYPE} configuration") |
230 message(STATUS "Using ${CMAKE_BUILD_TYPE} configuration") |
226 if(CMAKE_BUILD_TYPE MATCHES "DEBUG") |
231 if(CMAKE_BUILD_TYPE MATCHES "DEBUG") |
227 list(APPEND pascal_flags "-O-" "-g" "-gl" "-gv") |
232 list(APPEND pascal_flags "-O-" # disable all optimisations |
|
233 "-g" # enable debug symbols |
|
234 "-gl" # add line info to bt |
|
235 "-gv" # allow valgrind |
|
236 ) |
228 list(APPEND haskell_flags "-Wall" "-debug" "-dcore-lint" "-fno-warn-unused-do-bind") |
237 list(APPEND haskell_flags "-Wall" "-debug" "-dcore-lint" "-fno-warn-unused-do-bind") |
229 else() |
238 else() |
230 # set(pascal_flags "-O3" "-OpPENTIUM4" "-CfSSE3" "-Xs" "-Si" ${pascal_flags}) |
239 list(APPEND pascal_flags "-Os" # optimise for size |
231 list(APPEND pascal_flags "-Os" "-Xs" "-Si") |
240 "-Xs" # strip binary |
|
241 "-Si" # turn on inlining |
|
242 ) |
232 list(APPEND haskell_flags "-w" "-fno-warn-unused-do-bind") |
243 list(APPEND haskell_flags "-w" "-fno-warn-unused-do-bind") |
233 endif() |
244 endif() |
234 |
245 |
235 |
246 |
236 #server discovery |
247 #server discovery |
265 #linking with liblua.a requires system readline |
276 #linking with liblua.a requires system readline |
266 list(APPEND pascal_flags "-k${EXECUTABLE_OUTPUT_PATH}/lib${LUA_LIBRARY}.a" "-k-lreadline") |
277 list(APPEND pascal_flags "-k${EXECUTABLE_OUTPUT_PATH}/lib${LUA_LIBRARY}.a" "-k-lreadline") |
267 endif() |
278 endif() |
268 |
279 |
269 |
280 |
270 #physfs library (static on unix, dll on win32) |
281 #physfs discovery |
271 add_subdirectory(misc/physfs) |
282 if (${SYSTEM_PHYSFS}) |
272 if(NOT WIN32) |
283 if (NOT PHYSFS_LIBRARY OR NOT PHYSFS_INCLUDE_DIR) |
273 list(APPEND pascal_flags "-k${LIBRARY_OUTPUT_PATH}/libphysfs.a") |
284 find_package(PhysFS) |
274 endif() |
285 endif() |
275 |
286 |
|
287 find_file(physfs_h physfs.h ${PHYSFS_INCLUDE_DIR}) |
|
288 if(physfs_h) |
|
289 file(STRINGS ${physfs_h} physfs_majorversion REGEX "PHYSFS_VER_MAJOR[\t' ']+[0-9]+") |
|
290 file(STRINGS ${physfs_h} physfs_minorversion REGEX "PHYSFS_VER_MINOR[\t' ']+[0-9]+") |
|
291 file(STRINGS ${physfs_h} physfs_patchversion REGEX "PHYSFS_VER_PATCH[\t' ']+[0-9]+") |
|
292 string(REGEX MATCH "([0-9]+)" physfs_majorversion "${physfs_majorversion}") |
|
293 string(REGEX MATCH "([0-9]+)" physfs_minorversion "${physfs_minorversion}") |
|
294 string(REGEX MATCH "([0-9]+)" physfs_patchversion "${physfs_patchversion}") |
|
295 set(physfs_detected_ver "${physfs_majorversion}.${physfs_minorversion}.${physfs_patchversion}") |
|
296 |
|
297 if (physfs_detected_ver VERSION_LESS "2.1.0") |
|
298 message(FATAL_ERROR "PhysFS version is too old (dected ${physfs_detected_ver}, required 2.1.0)") |
|
299 set(physfs_too_old true) |
|
300 endif() |
|
301 endif() |
|
302 |
|
303 if (NOT PHYSFS_LIBRARY OR NOT PHYSFS_INCLUDE_DIR) |
|
304 message(FATAL_ERROR "Missing PhysFS! Rerun cmake with -DPHYSFS_SYSTEM=off to build the internal version") |
|
305 endif() |
|
306 else() |
|
307 message(STATUS "PhysFS will be provided by the bundled sources") |
|
308 set(physfs_output_name "hw_physfs") |
|
309 add_subdirectory(misc/libphysfs) |
|
310 #-XLA is a beta fpc flag that renames libraries before passing them to the linker |
|
311 #we also have to pass PHYSFS_INTERNAL to satisfy windows runtime requirements |
|
312 #(should be harmless on other platforms) |
|
313 list(APPEND pascal_flags "-XLAphysfs=${physfs_output_name}" "-dPHYSFS_INTERNAL") |
|
314 endif() |
|
315 |
|
316 # |
|
317 add_subdirectory(misc/libphyslayer) |
276 |
318 |
277 #main engine |
319 #main engine |
278 add_subdirectory(hedgewars) |
320 add_subdirectory(hedgewars) |
279 |
321 |
280 #Android related build scripts |
322 #Android related build scripts |