CMakeLists.txt
branchspacecampaign
changeset 9308 4bddcc1a1450
parent 9265 a0e7e7a1c3f8
child 9349 8ec5cf11e85a
equal deleted inserted replaced
9296:5cc010e79431 9308:4bddcc1a1450
    28 endif()
    28 endif()
    29 
    29 
    30 option(BUILD_ENGINE_LIBRARY "Enable hwengine library (off)" OFF)
    30 option(BUILD_ENGINE_LIBRARY "Enable hwengine library (off)" OFF)
    31 option(ANDROID "Enable Android build (off)" OFF)
    31 option(ANDROID "Enable Android build (off)" OFF)
    32 
    32 
    33 if(UNIX AND NOT APPLE)
    33 option(MINIMAL_FLAGS "Respect system flags as much as possible (off)" OFF)
    34     option(MINIMAL_FLAGS "Respect system flags as much as possible (off)" OFF)
    34 option(NOAUTOUPDATE "Disable OS X Sparkle update checking (off)" OFF)
    35 else()
       
    36     option(NOAUTOUPDATE "Disable OS X Sparkle update checking" OFF)
       
    37 endif()
       
    38 
    35 
    39 set(FPFLAGS "" CACHE STRING "Additional Freepascal flags")
    36 set(FPFLAGS "" CACHE STRING "Additional Freepascal flags")
    40 set(GHFLAGS "" CACHE STRING "Additional Haskell flags")
    37 set(GHFLAGS "" CACHE STRING "Additional Haskell flags")
    41 if(UNIX AND NOT APPLE)
    38 if(UNIX AND NOT APPLE)
    42     set(DATA_INSTALL_DIR "share/hedgewars" CACHE STRING "Resource folder path")
    39     set(DATA_INSTALL_DIR "share/hedgewars" CACHE STRING "Resource folder path")
    73 
    70 
    74 
    71 
    75 #perform safe check that enable/disable compilation features
    72 #perform safe check that enable/disable compilation features
    76 include(${CMAKE_MODULE_PATH}/compilerchecks.cmake)
    73 include(${CMAKE_MODULE_PATH}/compilerchecks.cmake)
    77 
    74 
    78 #set default flags values for all projects (unless MINIMAL_FLAGS is true)
    75 #set default compiler flags
    79 if(NOT ${MINIMAL_FLAGS})
    76 add_flag_append(CMAKE_C_FLAGS "-Wall -pipe")
    80     set(CMAKE_C_FLAGS "-pipe ${CMAKE_C_FLAGS}")
    77 add_flag_append(CMAKE_C_FLAGS_RELEASE "-Os")
    81     set(CMAKE_C_FLAGS_RELEASE "-w -Os -fomit-frame-pointer ${CMAKE_C_FLAGS_RELEASE}")
    78 add_flag_append(CMAKE_C_FLAGS_DEBUG "-Wextra -O0")
    82     set(CMAKE_C_FLAGS_DEBUG "-Wall -O0 -g ${CMAKE_C_FLAGS_DEBUG}")
    79 add_flag_append(CMAKE_CXX_FLAGS "-Wall -pipe")
    83     set(CMAKE_CXX_FLAGS "-pipe ${CMAKE_CXX_FLAGS}")
    80 add_flag_append(CMAKE_CXX_FLAGS_RELEASE "-Os")
    84     set(CMAKE_CXX_FLAGS_RELEASE "-w -Os -fomit-frame-pointer ${CMAKE_CXX_FLAGS_RELEASE}")
    81 add_flag_append(CMAKE_CXX_FLAGS_DEBUG "-Wextra -O0")
    85     set(CMAKE_CXX_FLAGS_DEBUG "-Wall -O0 -g ${CMAKE_CXX_FLAGS_DEBUG}")
    82 add_flag_append(CMAKE_Pascal_FLAGS "-Cs2000000")
    86 else()
    83 add_flag_append(CMAKE_Pascal_FLAGS_DEBUG "-O- -gv")
    87     #CMake adds a lot of additional configuration flags, so let's clear them up
    84 add_flag_append(CMAKE_Pascal_FLAGS_RELEASE "-Os -Xs")
    88     set(CMAKE_C_FLAGS_RELEASE "")
    85 
    89     set(CMAKE_C_FLAGS_DEBUG "-Wall")
    86 #CMake adds a lot of additional configuration flags, so let's clear them up
    90     set(CMAKE_CXX_FLAGS_RELEASE "")
    87 if(${MINIMAL_FLAGS})
    91     set(CMAKE_CXX_FLAGS_DEBUG "-Wall")
    88     unset(CMAKE_C_FLAGS_RELEASE)
    92 endif()
    89     unset(CMAKE_C_FLAGS_DEBUG)
       
    90     unset(CMAKE_CXX_FLAGS_RELEASE)
       
    91     unset(CMAKE_CXX_FLAGS_DEBUG)
       
    92 endif()
       
    93 
    93 
    94 
    94 #parse additional parameters
    95 #parse additional parameters
    95 if(FPFLAGS)
    96 if(FPFLAGS)
    96     add_flag_prepend(CMAKE_Pascal_FLAGS ${FPFLAGS})
    97     add_flag_prepend(CMAKE_Pascal_FLAGS ${FPFLAGS})
    97 endif()
    98 endif()
    98 if(GHFLAGS)
    99 if(GHFLAGS)
    99     if(${allow_parse_args})
   100     if(${CMAKE_VERSION} VERSION_GREATER 2.6)
   100         separate_arguments(ghflags_parsed UNIX_COMMAND ${GHFLAGS})
   101         separate_arguments(ghflags_parsed UNIX_COMMAND ${GHFLAGS})
   101     else()
   102     else()
   102         message(${WARNING} "FPFLAGS and GHFLAGS are available only when using CMake >= 2.8")
   103         message(${WARNING} "FPFLAGS and GHFLAGS are available only when using CMake >= 2.8")
   103     endif()
   104     endif()
   104 endif()
   105 endif()
   105 
   106 
   106 
   107 list(APPEND haskell_flags ${ghflags_parsed} "-O2")
   107 list(APPEND haskell_flags ${ghflags_parsed} # user flags
       
   108                  "-O2"                      # optimise for faster code
       
   109                  )
       
   110 
       
   111 #-vm4079,4080,4081
       
   112 add_flag_append(CMAKE_Pascal_FLAGS "-Cs2000000")
       
   113 add_flag_append(CMAKE_Pascal_FLAGS_DEBUG "-O- -gv")
       
   114 add_flag_append(CMAKE_Pascal_FLAGS_RELEASE "-Os -Xs")
       
   115 
   108 
   116 #get BUILD_TYPE and enable/disable optimisation
   109 #get BUILD_TYPE and enable/disable optimisation
   117 message(STATUS "Using ${CMAKE_BUILD_TYPE} configuration")
   110 message(STATUS "Using ${CMAKE_BUILD_TYPE} configuration")
   118 if(CMAKE_BUILD_TYPE MATCHES "DEBUG")
   111 if(CMAKE_BUILD_TYPE MATCHES "DEBUG")
   119     list(APPEND haskell_flags "-Wall"       # all warnings
   112     list(APPEND haskell_flags "-Wall"       # all warnings