CMakeLists.txt
branchflibqtfrontend
changeset 8126 5bfa1b2025d6
parent 8104 09c38cdf380d
child 8146 1fba650c2aa4
equal deleted inserted replaced
8106:861d145b270e 8126:5bfa1b2025d6
     1 project(hedgewars)
     1 project(hedgewars)
     2 
     2 
     3 #initialise cmake environment
     3 #initialise cmake environment
     4 cmake_minimum_required(VERSION 2.6.0 FATAL_ERROR)
     4 cmake_minimum_required(VERSION 2.6.0)
     5 cmake_policy(VERSION 2.6)
       
     6 FOREACH(hwpolicy CMP0003 CMP0012 CMP0017)
     5 FOREACH(hwpolicy CMP0003 CMP0012 CMP0017)
     7     IF(POLICY ${hwpolicy})
     6     IF(POLICY ${hwpolicy})
     8         CMAKE_POLICY(SET ${hwpolicy} NEW)
     7         CMAKE_POLICY(SET ${hwpolicy} NEW)
     9     ENDIF()
     8     ENDIF()
    10 ENDFOREACH()
     9 ENDFOREACH()
    11 #use available modules, fallback to ours if not present (CMP0017 helps)
    10 #use available modules, fallback to ours if not present (CMP0017 helps)
    12 set(CMAKE_MODULE_PATH "${CMAKE_ROOT}/Modules" "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules")
    11 set(CMAKE_MODULE_PATH "${CMAKE_ROOT}/Modules" "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules")
    13 
    12 
    14 #set some default values
    13 
    15 option(NOREVISION "Build Hedgewars without revision information" OFF)
    14 #usually this is set at release time
    16 
    15 option(NOREVISION "Build Hedgewars without revision information [default: off]" OFF)
       
    16 
       
    17 #set other default values
    17 option(NOSERVER "Disable gameServer build [default: auto]" OFF)
    18 option(NOSERVER "Disable gameServer build [default: auto]" OFF)
    18 option(NOPNG "Disable screenshoot compression [default: auto]" OFF)
    19 option(NOPNG "Disable screenshoot compression [default: auto]" OFF)
    19 option(NOVIDEOREC "Disable video recording [default: auto]" OFF)
    20 option(NOVIDEOREC "Disable video recording [default: auto]" OFF)
    20 
    21 
    21 option(BUILD_ENGINE_LIBRARY "Enable hwengine library [default: off]" OFF)
    22 option(BUILD_ENGINE_LIBRARY "Enable hwengine library [default: off]" OFF)
    22 option(ANDROID "Enable Android build [default: off]" OFF)
    23 option(ANDROID "Enable Android build [default: off]" OFF)
    23 option(NOAUTOUPDATE "Disable OS X Sparkle update checking" OFF)
    24 option(NOAUTOUPDATE "Disable OS X Sparkle update checking" OFF)
    24 option(CROSSAPPLE "Enable OSX when not on OSX [default: off]" OFF)
    25 option(CROSSAPPLE "Enable OSX when not on OSX [default: off]" OFF)
    25 option(MINIMAL_FLAGS "Respect system flags as much as possible [default: off]" OFF)
    26 option(MINIMAL_FLAGS "Respect system flags as much as possible [default: off]" OFF)
       
    27 
    26 
    28 
    27 #detect Mercurial revision (if present)
    29 #detect Mercurial revision (if present)
    28 IF(NOT NOREVISION)
    30 IF(NOT NOREVISION)
    29     set(default_build_type "DEBUG")
    31     set(default_build_type "DEBUG")
    30     set(version_suffix "-development_version")
    32     set(version_suffix "-development_version")
    42         STRING(REGEX REPLACE "[0-9a-zA-Z]+(.*) ([0-9]+)(.*)" "\\2" revision_number ${internal_version})
    44         STRING(REGEX REPLACE "[0-9a-zA-Z]+(.*) ([0-9]+)(.*)" "\\2" revision_number ${internal_version})
    43         STRING(REGEX REPLACE "([0-9a-zA-Z]+)(.*) [0-9]+(.*)" "\\1" revision_hash ${internal_version})
    45         STRING(REGEX REPLACE "([0-9a-zA-Z]+)(.*) [0-9]+(.*)" "\\1" revision_hash ${internal_version})
    44 
    46 
    45         MESSAGE(STATUS "Building revision ${revision_number} from hash ${revision_hash} ${HGCHANGED}")
    47         MESSAGE(STATUS "Building revision ${revision_number} from hash ${revision_hash} ${HGCHANGED}")
    46         IF(HGCHANGED)
    48         IF(HGCHANGED)
    47             MESSAGE(WARNING "You have uncommitted changes")
    49             MESSAGE(WARNING "Notice: you have uncommitted changes in your repository")
    48         ENDIF()
    50         ENDIF()
    49         set(version_suffix "-${revision_number}${HGCHANGED}")
    51         set(version_suffix "-${revision_number}${HGCHANGED}")
    50     ENDIF()
    52     ENDIF()
    51 ELSE(NOT NOREVISION)
    53 ELSE(NOT NOREVISION)
    52     set(default_build_type "RELEASE")
    54     set(default_build_type "RELEASE")
    69     set(bundle_name Hedgewars.app)
    71     set(bundle_name Hedgewars.app)
    70     set(frameworks_dir ${bundle_name}/Contents/Frameworks/)
    72     set(frameworks_dir ${bundle_name}/Contents/Frameworks/)
    71     set(CMAKE_INSTALL_PREFIX ${bundle_name}/Contents/MacOS/)
    73     set(CMAKE_INSTALL_PREFIX ${bundle_name}/Contents/MacOS/)
    72     set(DATA_INSTALL_DIR "../Resources/")
    74     set(DATA_INSTALL_DIR "../Resources/")
    73     set(target_dir ".")
    75     set(target_dir ".")
    74     set(minimum_macosx_version "10.6")
       
    75 else()
    76 else()
    76     set(target_dir "bin")
    77     set(target_dir "bin")
    77 endif()
    78 endif()
    78 
    79 
    79 if(APPLE)
    80 if(APPLE)
    83     set(minimum_macosx_version $ENV{MACOSX_DEPLOYMENT_TARGET})
    84     set(minimum_macosx_version $ENV{MACOSX_DEPLOYMENT_TARGET})
    84 
    85 
    85     #detect on which system we are: if sw_vers cannot be found for any reason (re)use minimum_macosx_version
    86     #detect on which system we are: if sw_vers cannot be found for any reason (re)use minimum_macosx_version
    86     find_program(sw_vers sw_vers)
    87     find_program(sw_vers sw_vers)
    87     if(sw_vers)
    88     if(sw_vers)
    88         execute_process(COMMAND ${sw_vers} "-productVersion" OUTPUT_VARIABLE current_macosx_version)
    89         execute_process(COMMAND ${sw_vers} "-productVersion"
       
    90                         OUTPUT_VARIABLE current_macosx_version
       
    91                         OUTPUT_STRIP_TRAILING_WHITESPACE)
    89         string(REGEX REPLACE "([0-9]+.[0-9]+).[0-9]+" "\\1" current_macosx_version ${current_macosx_version})
    92         string(REGEX REPLACE "([0-9]+.[0-9]+).[0-9]+" "\\1" current_macosx_version ${current_macosx_version})
    90         else()
    93     else()
    91         if(NOT minimum_macosx_version)
    94         if(NOT minimum_macosx_version)
    92             message(FATAL_ERROR "sw_vers not found! Need explicit MACOSX_DEPLOYMENT_TARGET variable set")
    95             message(FATAL_ERROR "sw_vers not found! Need explicit MACOSX_DEPLOYMENT_TARGET variable set")
    93         else()
    96         else()
       
    97             message(WARNING "sw_vers not found! Fallback to MACOSX_DEPLOYMENT_TARGET variable")
    94             set(current_macosx_version ${minimum_macosx_version})
    98             set(current_macosx_version ${minimum_macosx_version})
    95         endif()
    99         endif()
    96     endif()
   100     endif()
    97 
   101 
    98     #if nothing is set, we deploy only for the current system
   102     #if nothing is set, we deploy only for the current system
    99     if(NOT minimum_macosx_version)
   103     if(NOT minimum_macosx_version)
   100         set(minimum_macosx_version ${current_macosx_version})
   104         set(minimum_macosx_version ${current_macosx_version})
   101     endif()
   105     endif()
   102 
   106 
   103     #lower systems don't have enough processing power anyways
   107     #lower systems don't have enough processing power anyway
   104     if (minimum_macosx_version LESS "10.4")
   108     if (minimum_macosx_version LESS "10.4")
   105         message(FATAL_ERROR "Hedgewars is not supported on Mac OS X pre-10.4")
   109         message(FATAL_ERROR "Hedgewars is not supported on Mac OS X pre-10.4")
   106     endif()
   110     endif()
   107 
   111 
   108     #workaround for http://playcontrol.net/ewing/jibberjabber/big_behind-the-scenes_chang.html#SDL_mixer (Update 2)
   112     #workaround for http://playcontrol.net/ewing/jibberjabber/big_behind-the-scenes_chang.html#SDL_mixer (Update 2)
   143     #add user framework directory, other paths can be passed via FPFLAGS
   147     #add user framework directory, other paths can be passed via FPFLAGS
   144     set(pascal_flags "-Ff~/Library/Frameworks" ${pascal_flags})
   148     set(pascal_flags "-Ff~/Library/Frameworks" ${pascal_flags})
   145     #set deployment target
   149     #set deployment target
   146     set(pascal_flags "-k-macosx_version_min" "-k${minimum_macosx_version}" "-XR${CMAKE_OSX_SYSROOT}" ${pascal_flags})
   150     set(pascal_flags "-k-macosx_version_min" "-k${minimum_macosx_version}" "-XR${CMAKE_OSX_SYSROOT}" ${pascal_flags})
   147 
   151 
   148     message(STATUS "Build system: Mac OS X ${current_macosx_version} with GCC:${CMAKE_C_COMPILER}")
   152     message(STATUS "Build system: Mac OS X ${current_macosx_version} with C compiler: ${CMAKE_C_COMPILER}")
   149     message(STATUS "Target system: Mac OS X ${minimum_macosx_version} for architecture(s):${CMAKE_OSX_ARCHITECTURES}")
   153     message(STATUS "Target system: Mac OS X ${minimum_macosx_version} for architecture(s): ${CMAKE_OSX_ARCHITECTURES}")
   150 endif(APPLE)
   154 endif(APPLE)
   151 
   155 
   152 
   156 
   153 #when build type is not specified, assume Debug/Release according to build version information
   157 #when build type is not specified, assume Debug/Release according to build version information
   154 if (CMAKE_BUILD_TYPE)
   158 if (CMAKE_BUILD_TYPE)
   228     if(ghc_executable)
   232     if(ghc_executable)
   229         set(HAVE_NETSERVER true)
   233         set(HAVE_NETSERVER true)
   230         add_subdirectory(gameServer)
   234         add_subdirectory(gameServer)
   231         message(STATUS "Found GHC: ${ghc_executable}")
   235         message(STATUS "Found GHC: ${ghc_executable}")
   232     else()
   236     else()
   233         message(STATUS "Could NOT find GHC, server will not be built")
   237         message(WARNING "Could NOT find GHC, server will not be built")
   234         set(HAVE_NETSERVER false)
   238         set(HAVE_NETSERVER false)
   235     endif()
   239     endif()
   236 else()
   240 else()
   237     message(STATUS "Server will not be built per user request")
   241     message(STATUS "Server will not be built per user request")
   238     set(HAVE_NETSERVER false)
   242     set(HAVE_NETSERVER false)
   244 if(LUA_FOUND)
   248 if(LUA_FOUND)
   245     message(STATUS "Found LUA: ${LUA_DEFAULT}")
   249     message(STATUS "Found LUA: ${LUA_DEFAULT}")
   246 else()
   250 else()
   247     message(STATUS "LUA will be provided by the bundled sources")
   251     message(STATUS "LUA will be provided by the bundled sources")
   248     add_subdirectory(misc/liblua)
   252     add_subdirectory(misc/liblua)
   249     #linking with liblua.a requires system readline -- this works everywhere, right?
   253     #linking with liblua.a requires system readline
   250     set(pascal_flags "-k${EXECUTABLE_OUTPUT_PATH}/lib${LUA_LIBRARY}.a" "-k-lreadline" ${pascal_flags})
   254     set(pascal_flags "-k${EXECUTABLE_OUTPUT_PATH}/lib${LUA_LIBRARY}.a" "-k-lreadline" ${pascal_flags})
   251 endif()
   255 endif()
   252 
   256 
   253 
   257 
   254 #main engine
   258 #main engine
   255 add_subdirectory(hedgewars)
   259 add_subdirectory(hedgewars)
   256 
   260 
   257 # physfs library
   261 #physfs library
   258 add_subdirectory(misc/physfs)
   262 add_subdirectory(misc/physfs)
   259 
   263 
   260 # frontend library
   264 #frontend library
   261 add_subdirectory(project_files/frontlib)
   265 add_subdirectory(project_files/frontlib)
   262 
   266 
   263 #Android related build scripts
   267 #Android related build scripts
   264 if(ANDROID)
   268 if(ANDROID)
   265     #run cmake -DANDROID=1 to enable this
   269     #run cmake -DANDROID=1 to enable this