CMakeLists.txt
changeset 8279 c03d64969112
parent 8272 93d8c77a13e8
child 8283 af97cdbb7713
equal deleted inserted replaced
8277:cd2bae15a9a3 8279:c03d64969112
   103     if(NOT minimum_macosx_version)
   103     if(NOT minimum_macosx_version)
   104         set(minimum_macosx_version ${current_macosx_version})
   104         set(minimum_macosx_version ${current_macosx_version})
   105     endif()
   105     endif()
   106 
   106 
   107     #lower systems don't have enough processing power anyway
   107     #lower systems don't have enough processing power anyway
   108     if (minimum_macosx_version LESS "10.4")
   108     if (minimum_macosx_version VERSION_LESS "10.4")
   109         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")
   110     endif()
   110     endif()
   111 
   111 
   112     #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)
   113     if(current_macosx_version MATCHES "10.4")
   113     if(current_macosx_version VERSION_EQUAL "10.4")
   114         find_package(SDL_mixer REQUIRED)
   114         find_package(SDL_mixer REQUIRED)
   115         set(DYLIB_SMPEG "-dylib_file @loader_path/Frameworks/smpeg.framework/Versions/A/smpeg:${SDLMIXER_LIBRARY}/Versions/A/Frameworks/smpeg.framework/Versions/A/smpeg")
   115         set(DYLIB_SMPEG "-dylib_file @loader_path/Frameworks/smpeg.framework/Versions/A/smpeg:${SDLMIXER_LIBRARY}/Versions/A/Frameworks/smpeg.framework/Versions/A/smpeg")
   116         set(DYLIB_MIKMOD "-dylib_file @loader_path/Frameworks/mikmod.framework/Versions/A/mikmod:${SDLMIXER_LIBRARY}/Versions/A/Frameworks/mikmod.framework/Versions/A/mikmod")
   116         set(DYLIB_MIKMOD "-dylib_file @loader_path/Frameworks/mikmod.framework/Versions/A/mikmod:${SDLMIXER_LIBRARY}/Versions/A/Frameworks/mikmod.framework/Versions/A/mikmod")
   117         set(pascal_flags "-k${DYLIB_SMPEG}" "-k${DYLIB_MIKMOD}" ${pascal_flags})
   117         set(pascal_flags "-k${DYLIB_SMPEG}" "-k${DYLIB_MIKMOD}" ${pascal_flags})
   118         set(CMAKE_C_FLAGS "${DYLIB_SMPEG}" "${DYLIB_MIKMOD}" ${CMAKE_C_FLAGS})
   118         set(CMAKE_C_FLAGS "${DYLIB_SMPEG}" "${DYLIB_MIKMOD}" ${CMAKE_C_FLAGS})
   119     endif()
   119     endif()
   120 
   120 
   121     #CMAKE_OSX_ARCHITECTURES and CMAKE_OSX_SYSROOT need to be set for universal binary and correct linking
   121     #CMAKE_OSX_ARCHITECTURES and CMAKE_OSX_SYSROOT need to be set for universal binary and correct linking
   122     if(NOT CMAKE_OSX_ARCHITECTURES)
   122     if(NOT CMAKE_OSX_ARCHITECTURES)
   123         if(current_macosx_version LESS "10.6")
   123         if(current_macosx_version VERSION_LESS "10.6")
   124             if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "powerpc*")
   124             if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "powerpc*")
   125                 set(CMAKE_OSX_ARCHITECTURES "ppc7400")
   125                 set(CMAKE_OSX_ARCHITECTURES "ppc7400")
   126             else()
   126             else()
   127                 set(CMAKE_OSX_ARCHITECTURES "i386")
   127                 set(CMAKE_OSX_ARCHITECTURES "i386")
   128             endif()
   128             endif()
   131         endif()
   131         endif()
   132     endif()
   132     endif()
   133 
   133 
   134     #CMAKE_OSX_SYSROOT is set at the system version we are supposed to build on
   134     #CMAKE_OSX_SYSROOT is set at the system version we are supposed to build on
   135     #we need to provide the correct one when host and target differ
   135     #we need to provide the correct one when host and target differ
   136     if(NOT ${minimum_macosx_version} MATCHES ${current_macosx_version})
   136     if(NOT ${minimum_macosx_version} VERSION_EQUAL ${current_macosx_version})
   137         if(minimum_macosx_version MATCHES "10.4")
   137         if(minimum_macosx_version VERSION_EQUAL "10.4")
   138             set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.4u.sdk/")
   138             set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.4u.sdk/")
   139             set(CMAKE_C_COMPILER "gcc-4.0")
   139             set(CMAKE_C_COMPILER "gcc-4.0")
   140             set(CMAKE_CXX_COMPILER "g++-4.0")
   140             set(CMAKE_CXX_COMPILER "g++-4.0")
   141         else()
   141         else()
   142             string(REGEX REPLACE "([0-9]+.[0-9]+).[0-9]+" "\\1" sdk_version ${minimum_macosx_version})
   142             string(REGEX REPLACE "([0-9]+.[0-9]+).[0-9]+" "\\1" sdk_version ${minimum_macosx_version})
   147     #add user framework directory, other paths can be passed via FPFLAGS
   147     #add user framework directory, other paths can be passed via FPFLAGS
   148     set(pascal_flags "-Ff~/Library/Frameworks" ${pascal_flags})
   148     set(pascal_flags "-Ff~/Library/Frameworks" ${pascal_flags})
   149     #set deployment target
   149     #set deployment target
   150     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})
   151 
   151 
   152     message(STATUS "Build system: Mac OS X ${current_macosx_version} with C compiler: ${CMAKE_C_COMPILER}")
   152     #silly libav that always brings in VideoDecoderAcceleration, avaible only from 10.6.3
   153     message(STATUS "Target system: Mac OS X ${minimum_macosx_version} for architecture(s): ${CMAKE_OSX_ARCHITECTURES}")
   153     if(NOT NOVIDEOREC AND ${minimum_macosx_version} VERSION_LESS "10.6")
       
   154         set(WARNING "Video recording support before OS X 10.6 is experimental")
       
   155     endif()
   154 endif(APPLE)
   156 endif(APPLE)
   155 
   157 
   156 
   158 
   157 #when build type is not specified, assume Debug/Release according to build version information
   159 #when build type is not specified, assume Debug/Release according to build version information
   158 if (CMAKE_BUILD_TYPE)
   160 if (CMAKE_BUILD_TYPE)
   159     string (TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE)
   161     string (TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE)
   160     if ( NOT( (CMAKE_BUILD_TYPE MATCHES "RELEASE") OR (CMAKE_BUILD_TYPE MATCHES "DEBUG") ) )
   162     if ( NOT( (CMAKE_BUILD_TYPE MATCHES "RELEASE") OR (CMAKE_BUILD_TYPE MATCHES "DEBUG") ) )
   161         set (CMAKE_BUILD_TYPE ${default_build_type} CACHE STRING "Only 'Debug' or 'Release' options are allowed." FORCE)
   163         set (CMAKE_BUILD_TYPE ${default_build_type} CACHE STRING "Choose the build type, options are: Debug Release." FORCE)
   162         message (STATUS "Unknown build type, using default (${default_build_type})")
   164         message (STATUS "Unknown build type, using default (${default_build_type})")
   163     endif ()
   165     endif ()
   164 else (CMAKE_BUILD_TYPE)
   166 else (CMAKE_BUILD_TYPE)
   165     set (CMAKE_BUILD_TYPE ${default_build_type} CACHE STRING "Choose the build type, options are: Debug Release." FORCE)
   167     set (CMAKE_BUILD_TYPE ${default_build_type} CACHE STRING "Choose the build type, options are: Debug Release." FORCE)
   166 endif (CMAKE_BUILD_TYPE)
   168 endif (CMAKE_BUILD_TYPE)
   181     set(CMAKE_CXX_FLAGS_DEBUG "-Wall -DDEBUG")
   183     set(CMAKE_CXX_FLAGS_DEBUG "-Wall -DDEBUG")
   182 endif()
   184 endif()
   183 
   185 
   184 #parse additional parameters
   186 #parse additional parameters
   185 if(FPFLAGS OR GHFLAGS)
   187 if(FPFLAGS OR GHFLAGS)
   186     math(EXPR cmake_version "${CMAKE_MAJOR_VERSION}*10000 + ${CMAKE_MINOR_VERSION}*100 + ${CMAKE_PATCH_VERSION}")
   188     set(cmake_version "${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}")
   187     if(cmake_version LESS "020800")
   189     if(cmake_version VERSION_LESS "2.8")
   188         message(STATUS "FPFLAGS and GHFLAGS are available only when using CMake >= 2.8")
   190         message(WARNING "FPFLAGS and GHFLAGS are available only when using CMake >= 2.8")
   189     else()
   191     else()
   190         separate_arguments(fpflags_parsed UNIX_COMMAND ${FPFLAGS})
   192         separate_arguments(fpflags_parsed UNIX_COMMAND ${FPFLAGS})
   191         separate_arguments(ghflags_parsed UNIX_COMMAND ${GHFLAGS})
   193         separate_arguments(ghflags_parsed UNIX_COMMAND ${GHFLAGS})
   192     endif()
   194     endif()
   193 endif()
   195 endif()
   194 
   196 
   195 set(pascal_flags ${fpflags_parsed} "-vm4079,4080,4081" "-B" "-FE../bin" "-Cs2000000" "-vewnq" "-dDEBUGFILE" ${pascal_flags})
   197 set(pascal_flags ${fpflags_parsed} "-vm4079,4080,4081" "-B" "-FE${PROJECT_BINARY_DIR}/bin" "-Cs2000000" "-vewnq" "-dDEBUGFILE" ${pascal_flags})
   196 set(haskell_flags "-O2" ${ghflags_parsed} ${haskell_flags})
   198 set(haskell_flags "-O2" ${ghflags_parsed} ${haskell_flags})
   197 
   199 
   198 #get BUILD_TYPE and enable/disable optimisation
   200 #get BUILD_TYPE and enable/disable optimisation
       
   201 message(STATUS "Using ${CMAKE_BUILD_TYPE} configuration")
   199 if(CMAKE_BUILD_TYPE MATCHES "DEBUG")
   202 if(CMAKE_BUILD_TYPE MATCHES "DEBUG")
   200     message(STATUS "Building Debug flavour")
       
   201     set(pascal_flags "-O-" "-g" "-gl" "-gv" ${pascal_flags})
   203     set(pascal_flags "-O-" "-g" "-gl" "-gv" ${pascal_flags})
   202     set(haskell_flags "-Wall" "-debug" "-dcore-lint" "-fno-warn-unused-do-bind" ${haskell_flags})
   204     set(haskell_flags "-Wall" "-debug" "-dcore-lint" "-fno-warn-unused-do-bind" ${haskell_flags})
   203 else()
   205 else()
   204     message(STATUS "Building Release flavour")
       
   205 #    set(pascal_flags "-O3" "-OpPENTIUM4" "-CfSSE3" "-Xs" "-Si" ${pascal_flags})
   206 #    set(pascal_flags "-O3" "-OpPENTIUM4" "-CfSSE3" "-Xs" "-Si" ${pascal_flags})
   206     set(pascal_flags "-Os" "-Xs" "-Si" ${pascal_flags})
   207     set(pascal_flags "-Os" "-Xs" "-Si" ${pascal_flags})
   207     set(haskell_flags "-w" "-fno-warn-unused-do-bind" ${haskell_flags})
   208     set(haskell_flags "-w" "-fno-warn-unused-do-bind" ${haskell_flags})
   208 endif()
   209 endif()
   209 
   210 
   213     set(SHAREPATH ${DATA_INSTALL_DIR}/hedgewars/)
   214     set(SHAREPATH ${DATA_INSTALL_DIR}/hedgewars/)
   214 else()
   215 else()
   215     set(SHAREPATH share/hedgewars/)
   216     set(SHAREPATH share/hedgewars/)
   216 endif()
   217 endif()
   217 set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
   218 set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
   218 set(LIBRARY_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH})
   219 set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
   219 if(WIN32)
   220 if(WIN32)
   220     set(CMAKE_PREFIX_PATH "${CMAKE_SOURCE_DIR}/misc/winutils/")
   221     set(CMAKE_PREFIX_PATH "${CMAKE_SOURCE_DIR}/misc/winutils/")
   221     link_directories("${EXECUTABLE_OUTPUT_PATH}" "${CMAKE_SOURCE_DIR}/misc/winutils/bin")
   222     link_directories("${EXECUTABLE_OUTPUT_PATH}" "${CMAKE_SOURCE_DIR}/misc/winutils/bin")
   222 endif(WIN32)
   223 endif(WIN32)
       
   224 
   223 
   225 
   224 #server discovery
   226 #server discovery
   225 if(NOT NOSERVER)
   227 if(NOT NOSERVER)
   226     if(GHC)
   228     if(GHC)
   227         set(ghc_executable ${GHC})
   229         set(ghc_executable ${GHC})