CMakeLists.txt
changeset 8593 9d1d0fa8db02
parent 8558 e96bf10216ef
child 8597 00adaf34d2a3
equal deleted inserted replaced
8591:9afb44f030b6 8593:9d1d0fa8db02
    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
   218                  "-Cs2000000"                   # stack size
   222                  "-Cs2000000"                   # stack size
   222 list(APPEND haskell_flags "-O2" ${ghflags_parsed})
   226 list(APPEND haskell_flags "-O2" ${ghflags_parsed})
   223 
   227 
   224 #get BUILD_TYPE and enable/disable optimisation
   228 #get BUILD_TYPE and enable/disable optimisation
   225 message(STATUS "Using ${CMAKE_BUILD_TYPE} configuration")
   229 message(STATUS "Using ${CMAKE_BUILD_TYPE} configuration")
   226 if(CMAKE_BUILD_TYPE MATCHES "DEBUG")
   230 if(CMAKE_BUILD_TYPE MATCHES "DEBUG")
   227     list(APPEND pascal_flags "-O-" "-g" "-gl" "-gv")
   231     list(APPEND pascal_flags "-O-"              # disable all optimisations
       
   232                              "-g"               # enable debug symbols
       
   233                              "-gl"              # add line info to bt
       
   234                              "-gv"              # allow valgrind
       
   235                              )
   228     list(APPEND haskell_flags "-Wall" "-debug" "-dcore-lint" "-fno-warn-unused-do-bind")
   236     list(APPEND haskell_flags "-Wall" "-debug" "-dcore-lint" "-fno-warn-unused-do-bind")
   229 else()
   237 else()
   230 #    set(pascal_flags "-O3" "-OpPENTIUM4" "-CfSSE3" "-Xs" "-Si" ${pascal_flags})
   238     list(APPEND pascal_flags "-Os"              # optimise for size
   231     list(APPEND pascal_flags "-Os" "-Xs" "-Si")
   239                              "-Xs"              # strip binary
       
   240                              "-Si"              # turn on inlining
       
   241                              )
   232     list(APPEND haskell_flags "-w" "-fno-warn-unused-do-bind")
   242     list(APPEND haskell_flags "-w" "-fno-warn-unused-do-bind")
   233 endif()
   243 endif()
   234 
   244 
   235 
   245 
   236 #server discovery
   246 #server discovery
   265     #linking with liblua.a requires system readline
   275     #linking with liblua.a requires system readline
   266     list(APPEND pascal_flags "-k${EXECUTABLE_OUTPUT_PATH}/lib${LUA_LIBRARY}.a" "-k-lreadline")
   276     list(APPEND pascal_flags "-k${EXECUTABLE_OUTPUT_PATH}/lib${LUA_LIBRARY}.a" "-k-lreadline")
   267 endif()
   277 endif()
   268 
   278 
   269 
   279 
   270 #physfs library (static on unix, dll on win32)
   280 #physfs discovery
   271 add_subdirectory(misc/physfs)
   281 if (${SYSTEM_PHYSFS})
   272 if(NOT WIN32)
   282     if (NOT PHYSFS_LIBRARY OR NOT PHYSFS_INCLUDE_DIR)
   273     list(APPEND pascal_flags "-k${LIBRARY_OUTPUT_PATH}/libphysfs.a")
   283         find_package(PhysFS)
   274 endif()
   284     endif()
   275 
   285 
       
   286     find_file(physfs_h physfs.h ${PHYSFS_INCLUDE_DIR})
       
   287     if(physfs_h)
       
   288         file(STRINGS ${physfs_h} physfs_majorversion REGEX "PHYSFS_VER_MAJOR[\t' ']+[0-9]+")
       
   289         file(STRINGS ${physfs_h} physfs_minorversion REGEX "PHYSFS_VER_MINOR[\t' ']+[0-9]+")
       
   290         file(STRINGS ${physfs_h} physfs_patchversion REGEX "PHYSFS_VER_PATCH[\t' ']+[0-9]+")
       
   291         string(REGEX MATCH "([0-9]+)" physfs_majorversion "${physfs_majorversion}")
       
   292         string(REGEX MATCH "([0-9]+)" physfs_minorversion "${physfs_minorversion}")
       
   293         string(REGEX MATCH "([0-9]+)" physfs_patchversion "${physfs_patchversion}")
       
   294         set(physfs_detected_ver "${physfs_majorversion}.${physfs_minorversion}.${physfs_patchversion}")
       
   295 
       
   296         if (physfs_detected_ver VERSION_LESS "2.1.0")
       
   297             message(FATAL_ERROR "PhysFS version is too old (dected ${physfs_detected_ver}, required 2.1.0)")
       
   298             set(physfs_too_old true)
       
   299         endif()
       
   300     endif()
       
   301 
       
   302     if (NOT PHYSFS_LIBRARY OR NOT PHYSFS_INCLUDE_DIR)
       
   303         message(FATAL_ERROR "Missing PhysFS! Rerun cmake with -DPHYSFS_SYSTEM=off to build the internal version")
       
   304     endif()
       
   305 else()
       
   306     message(STATUS "PhysFS will be provided by the bundled sources")
       
   307     set(physfs_output_name "hw_physfs")
       
   308     add_subdirectory(misc/libphysfs)
       
   309     #-XLA is a beta fpc flag that renames libraries before passing them to the linker
       
   310     #we also have to pass PHYSFS_INTERNAL to satisfy windows runtime requirements
       
   311     #(should be harmless on other platforms)
       
   312     list(APPEND pascal_flags "-XLAphysfs=${physfs_output_name}" "-dPHYSFS_INTERNAL")
       
   313 endif()
       
   314 
       
   315 #
       
   316 add_subdirectory(misc/libphyslayer)
   276 
   317 
   277 #main engine
   318 #main engine
   278 add_subdirectory(hedgewars)
   319 add_subdirectory(hedgewars)
   279 
   320 
   280 #Android related build scripts
   321 #Android related build scripts