CMakeLists.txt
changeset 8611 90f445317e8a
parent 8597 00adaf34d2a3
child 8613 82c649dfc7c3
equal deleted inserted replaced
8610:6d6b5b529890 8611:90f445317e8a
     1 project(hedgewars)
     1 project(hedgewars)
     2 
     2 
     3 #initialise cmake environment
     3 #initialise cmake environment
     4 cmake_minimum_required(VERSION 2.6.0)
     4 cmake_minimum_required(VERSION 2.6.0)
       
     5 if(CMAKE_VERSION VERSION_LESS "2.8")
       
     6     set(WARNING "WARNING: ")
       
     7     set(allow_parse_args FALSE)
       
     8 else()
       
     9     set(WARNING WARNING)
       
    10     set(allow_parse_args TRUE)
       
    11 endif()
     5 foreach(hwpolicy CMP0003 CMP0012 CMP0017)
    12 foreach(hwpolicy CMP0003 CMP0012 CMP0017)
     6     if(POLICY ${hwpolicy})
    13     if(POLICY ${hwpolicy})
     7         cmake_policy(SET ${hwpolicy} NEW)
    14         cmake_policy(SET ${hwpolicy} NEW)
     8     endif()
    15     endif()
     9 endforeach()
    16 endforeach()
       
    17 
    10 #use available modules, fallback to ours if not present (CMP0017 helps)
    18 #use available modules, fallback to ours if not present (CMP0017 helps)
    11 set(CMAKE_MODULE_PATH "${CMAKE_ROOT}/Modules" "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules")
    19 set(CMAKE_MODULE_PATH "${CMAKE_ROOT}/Modules" "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules")
    12 
    20 
    13 
    21 
    14 #usually this is set at release time
    22 #usually this is set at release time
    51         string(REGEX REPLACE "[0-9a-zA-Z]+(.*) ([0-9]+)(.*)" "\\2" revision_number ${internal_version})
    59         string(REGEX REPLACE "[0-9a-zA-Z]+(.*) ([0-9]+)(.*)" "\\2" revision_number ${internal_version})
    52         string(REGEX REPLACE "([0-9a-zA-Z]+)(.*) [0-9]+(.*)" "\\1" revision_hash ${internal_version})
    60         string(REGEX REPLACE "([0-9a-zA-Z]+)(.*) [0-9]+(.*)" "\\1" revision_hash ${internal_version})
    53 
    61 
    54         message(STATUS "Building revision ${revision_number} from hash ${revision_hash} ${HGCHANGED}")
    62         message(STATUS "Building revision ${revision_number} from hash ${revision_hash} ${HGCHANGED}")
    55         if(HGCHANGED)
    63         if(HGCHANGED)
    56             MESSAGE(WARNING "Notice: you have uncommitted changes in your repository")
    64             MESSAGE(${WARNING} "Notice: you have uncommitted changes in your repository")
    57         endif()
    65         endif()
    58         set(version_suffix "-${revision_number}${HGCHANGED}")
    66         set(version_suffix "-${revision_number}${HGCHANGED}")
    59     endif()
    67     endif()
    60 else(NOT NOREVISION)
    68 else(NOT NOREVISION)
    61     set(default_build_type "RELEASE")
    69     set(default_build_type "RELEASE")
   112         string(REGEX REPLACE "([0-9]+.[0-9]+).[0-9]+" "\\1" current_macosx_version ${current_macosx_version})
   120         string(REGEX REPLACE "([0-9]+.[0-9]+).[0-9]+" "\\1" current_macosx_version ${current_macosx_version})
   113     else()
   121     else()
   114         if(NOT minimum_macosx_version)
   122         if(NOT minimum_macosx_version)
   115             message(FATAL_ERROR "sw_vers not found! Need explicit MACOSX_DEPLOYMENT_TARGET variable set")
   123             message(FATAL_ERROR "sw_vers not found! Need explicit MACOSX_DEPLOYMENT_TARGET variable set")
   116         else()
   124         else()
   117             message(WARNING "sw_vers not found! Fallback to MACOSX_DEPLOYMENT_TARGET variable")
   125             message(${WARNING} "sw_vers not found! Fallback to MACOSX_DEPLOYMENT_TARGET variable")
   118             set(current_macosx_version ${minimum_macosx_version})
   126             set(current_macosx_version ${minimum_macosx_version})
   119         endif()
   127         endif()
   120     endif()
   128     endif()
   121 
   129 
   122     #if nothing is set, we deploy only for the current system
   130     #if nothing is set, we deploy only for the current system
   169     #set deployment target
   177     #set deployment target
   170     list(APPEND pascal_flags "-k-macosx_version_min" "-k${minimum_macosx_version}" "-XR${CMAKE_OSX_SYSROOT}")
   178     list(APPEND pascal_flags "-k-macosx_version_min" "-k${minimum_macosx_version}" "-XR${CMAKE_OSX_SYSROOT}")
   171 
   179 
   172     #silly libav that always brings in VideoDecoderAcceleration, avaible only from 10.6.3
   180     #silly libav that always brings in VideoDecoderAcceleration, avaible only from 10.6.3
   173     if(NOT NOVIDEOREC AND ${minimum_macosx_version} VERSION_LESS "10.6")
   181     if(NOT NOVIDEOREC AND ${minimum_macosx_version} VERSION_LESS "10.6")
   174         set(WARNING "Video recording support before OS X 10.6 is experimental")
   182         set(${WARNING} "Video recording support before OS X 10.6 is experimental")
   175     endif()
   183     endif()
   176 endif(APPLE)
   184 endif(APPLE)
   177 
   185 
   178 
   186 
   179 #when build type is not specified, assume Debug/Release according to build version information
   187 #when build type is not specified, assume Debug/Release according to build version information
   203     set(CMAKE_CXX_FLAGS_DEBUG "-Wall -DDEBUG")
   211     set(CMAKE_CXX_FLAGS_DEBUG "-Wall -DDEBUG")
   204 endif()
   212 endif()
   205 
   213 
   206 #parse additional parameters
   214 #parse additional parameters
   207 if(FPFLAGS OR GHFLAGS)
   215 if(FPFLAGS OR GHFLAGS)
   208     set(cmake_version "${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}")
   216     if(${allow_parse_args})
   209     if(cmake_version VERSION_LESS "2.8")
   217         message(${WARNING} "FPFLAGS and GHFLAGS are available only when using CMake >= 2.8")
   210         message(WARNING "FPFLAGS and GHFLAGS are available only when using CMake >= 2.8")
       
   211     else()
   218     else()
   212         separate_arguments(fpflags_parsed UNIX_COMMAND ${FPFLAGS})
   219         separate_arguments(fpflags_parsed UNIX_COMMAND ${FPFLAGS})
   213         separate_arguments(ghflags_parsed UNIX_COMMAND ${GHFLAGS})
   220         separate_arguments(ghflags_parsed UNIX_COMMAND ${GHFLAGS})
   214     endif()
   221     endif()
   215 endif()
   222 endif()
   255     if(ghc_executable)
   262     if(ghc_executable)
   256         set(HAVE_NETSERVER true)
   263         set(HAVE_NETSERVER true)
   257         add_subdirectory(gameServer)
   264         add_subdirectory(gameServer)
   258         message(STATUS "Found GHC: ${ghc_executable}")
   265         message(STATUS "Found GHC: ${ghc_executable}")
   259     else()
   266     else()
   260         message(WARNING "Could NOT find GHC, server will not be built")
   267         message(${WARNING} "Could NOT find GHC, server will not be built")
   261         set(HAVE_NETSERVER false)
   268         set(HAVE_NETSERVER false)
   262     endif()
   269     endif()
   263 else()
   270 else()
   264     message(STATUS "Server will not be built per user request")
   271     message(STATUS "Server will not be built per user request")
   265     set(HAVE_NETSERVER false)
   272     set(HAVE_NETSERVER false)