CMakeLists.txt
branchflibqtfrontend
changeset 8363 0b4ac686fc44
parent 8304 620560c89284
parent 8348 c039ac6f33e0
equal deleted inserted replaced
8306:50fe80adbfcb 8363:0b4ac686fc44
    20 option(NOVIDEOREC "Disable video recording [default: auto]" OFF)
    20 option(NOVIDEOREC "Disable video recording [default: auto]" OFF)
    21 
    21 
    22 option(BUILD_ENGINE_LIBRARY "Enable hwengine library [default: off]" OFF)
    22 option(BUILD_ENGINE_LIBRARY "Enable hwengine library [default: off]" OFF)
    23 option(ANDROID "Enable Android build [default: off]" OFF)
    23 option(ANDROID "Enable Android build [default: off]" OFF)
    24 option(NOAUTOUPDATE "Disable OS X Sparkle update checking" OFF)
    24 option(NOAUTOUPDATE "Disable OS X Sparkle update checking" OFF)
    25 option(CROSSAPPLE "Enable OSX when not on OSX [default: off]" OFF)
       
    26 option(MINIMAL_FLAGS "Respect system flags as much as possible [default: off]" OFF)
    25 option(MINIMAL_FLAGS "Respect system flags as much as possible [default: off]" OFF)
    27 
    26 set(FPFLAGS "" CACHE STRING "Additional Freepascal flags")
       
    27 set(GHFLAGS "" CACHE STRING "Additional Haskell flags")
       
    28 if(UNIX AND NOT APPLE)
       
    29     set(DATA_INSTALL_DIR "share/hedgewars" CACHE STRING "Resource folder path")
       
    30 endif()
    28 
    31 
    29 #detect Mercurial revision (if present)
    32 #detect Mercurial revision (if present)
    30 if(NOT NOREVISION)
    33 if(NOT NOREVISION)
    31     set(default_build_type "DEBUG")
    34     set(default_build_type "DEBUG")
    32     set(version_suffix "-development_version")
    35     set(version_suffix "-development_version")
    63 set(CPACK_PACKAGE_VERSION_PATCH 19${version_suffix})
    66 set(CPACK_PACKAGE_VERSION_PATCH 19${version_suffix})
    64 set(HEDGEWARS_PROTO_VER 44)
    67 set(HEDGEWARS_PROTO_VER 44)
    65 set(HEDGEWARS_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
    68 set(HEDGEWARS_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
    66 
    69 
    67 
    70 
    68 #bundle .app setup
    71 set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
    69 if(APPLE OR CROSSAPPLE)
    72 set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
    70     #paths for creating the bundle
    73 
    71     set(bundle_name Hedgewars.app)
    74 if(UNIX AND NOT APPLE)
    72     set(frameworks_dir ${bundle_name}/Contents/Frameworks/)
    75     set(target_binary_install_dir "bin")
    73     set(CMAKE_INSTALL_PREFIX ${bundle_name}/Contents/MacOS/)
    76     set(target_library_install_dir "lib")
    74     set(DATA_INSTALL_DIR "../Resources/")
    77     set(SHAREPATH "${DATA_INSTALL_DIR}/")
    75     set(target_dir ".")
    78 else()
    76 else()
    79     set(target_binary_install_dir "./")
    77     set(target_dir "bin")
    80 
    78 endif()
    81     if(APPLE)
       
    82         set(CMAKE_INSTALL_PREFIX "Hedgewars.app/Contents/MacOS/")
       
    83         set(SHAREPATH "../Resources/")
       
    84         set(target_library_install_dir "../Frameworks/")
       
    85     else()
       
    86         if(WIN32)
       
    87             set(target_library_install_dir "./")
       
    88             set(SHAREPATH "./")
       
    89             set(CMAKE_PREFIX_PATH "${CMAKE_SOURCE_DIR}/misc/winutils/")
       
    90             link_directories("${EXECUTABLE_OUTPUT_PATH}" "${CMAKE_SOURCE_DIR}/misc/winutils/bin")
       
    91         endif(WIN32)
       
    92     endif()
       
    93 endif()
       
    94 
    79 
    95 
    80 if(APPLE)
    96 if(APPLE)
    81     set(CMAKE_FIND_FRAMEWORK "FIRST")
    97     set(CMAKE_FIND_FRAMEWORK "FIRST")
    82 
    98 
    83     #what system are we building for
    99     #what system are we building for
   112     #workaround for http://playcontrol.net/ewing/jibberjabber/big_behind-the-scenes_chang.html#SDL_mixer (Update 2)
   128     #workaround for http://playcontrol.net/ewing/jibberjabber/big_behind-the-scenes_chang.html#SDL_mixer (Update 2)
   113     if(current_macosx_version VERSION_EQUAL "10.4")
   129     if(current_macosx_version VERSION_EQUAL "10.4")
   114         find_package(SDL_mixer REQUIRED)
   130         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")
   131         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")
   132         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})
   133         set(CMAKE_C_FLAGS "${DYLIB_SMPEG} ${DYLIB_MIKMOD}")
   118         set(CMAKE_C_FLAGS "${DYLIB_SMPEG}" "${DYLIB_MIKMOD}" ${CMAKE_C_FLAGS})
   134         list(APPEND pascal_flags "-k${DYLIB_SMPEG}" "-k${DYLIB_MIKMOD}")
   119     endif()
   135     endif()
   120 
   136 
   121     #CMAKE_OSX_ARCHITECTURES and CMAKE_OSX_SYSROOT need to be set for universal binary and correct linking
   137     #CMAKE_OSX_ARCHITECTURES and CMAKE_OSX_SYSROOT need to be set for universal binary and correct linking
   122     if(NOT CMAKE_OSX_ARCHITECTURES)
   138     if(NOT CMAKE_OSX_ARCHITECTURES)
   123         if(current_macosx_version VERSION_LESS "10.6")
   139         if(current_macosx_version VERSION_LESS "10.6")
   143             set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX${sdk_version}.sdk/")
   159             set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX${sdk_version}.sdk/")
   144         endif()
   160         endif()
   145     endif()
   161     endif()
   146 
   162 
   147     #add user framework directory, other paths can be passed via FPFLAGS
   163     #add user framework directory, other paths can be passed via FPFLAGS
   148     set(pascal_flags "-Ff~/Library/Frameworks" ${pascal_flags})
   164     list(APPEND pascal_flags "-Ff~/Library/Frameworks")
   149     #set deployment target
   165     #set deployment target
   150     set(pascal_flags "-k-macosx_version_min" "-k${minimum_macosx_version}" "-XR${CMAKE_OSX_SYSROOT}" ${pascal_flags})
   166     list(APPEND pascal_flags "-k-macosx_version_min" "-k${minimum_macosx_version}" "-XR${CMAKE_OSX_SYSROOT}")
   151 
   167 
   152     #silly libav that always brings in VideoDecoderAcceleration, avaible only from 10.6.3
   168     #silly libav that always brings in VideoDecoderAcceleration, avaible only from 10.6.3
   153     if(NOT NOVIDEOREC AND ${minimum_macosx_version} VERSION_LESS "10.6")
   169     if(NOT NOVIDEOREC AND ${minimum_macosx_version} VERSION_LESS "10.6")
   154         set(WARNING "Video recording support before OS X 10.6 is experimental")
   170         set(WARNING "Video recording support before OS X 10.6 is experimental")
   155     endif()
   171     endif()
   166 else (CMAKE_BUILD_TYPE)
   182 else (CMAKE_BUILD_TYPE)
   167     set (CMAKE_BUILD_TYPE ${default_build_type} CACHE STRING "Choose the build type, options are: Debug Release." FORCE)
   183     set (CMAKE_BUILD_TYPE ${default_build_type} CACHE STRING "Choose the build type, options are: Debug Release." FORCE)
   168 endif (CMAKE_BUILD_TYPE)
   184 endif (CMAKE_BUILD_TYPE)
   169 
   185 
   170 #set default flags values for all projects (unless MINIMAL_FLAGS is true)
   186 #set default flags values for all projects (unless MINIMAL_FLAGS is true)
   171 if(NOT MINIMAL_FLAGS)
   187 if(NOT ${MINIMAL_FLAGS})
   172     set(CMAKE_C_FLAGS "-pipe")
   188     set(CMAKE_C_FLAGS "-pipe ${CMAKE_C_FLAGS}")
   173     set(CMAKE_C_FLAGS_RELEASE "-w -Os -fomit-frame-pointer")
   189     set(CMAKE_C_FLAGS_RELEASE "-w -Os -fomit-frame-pointer ${CMAKE_C_FLAGS_RELEASE}")
   174     set(CMAKE_C_FLAGS_DEBUG "-Wall -O0 -g -DDEBUG")
   190     set(CMAKE_C_FLAGS_DEBUG "-Wall -O0 -g -DDEBUG ${CMAKE_C_FLAGS_DEBUG}")
   175     set(CMAKE_CXX_FLAGS ${CMAKE_C_FLAGS})
   191     set(CMAKE_CXX_FLAGS ${CMAKE_C_FLAGS})
   176     set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
   192     set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
   177     set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
   193     set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
   178 else()
   194 else()
   179     #CMake adds a lot of additional configuration flags, so let's clear them up
   195     #CMake adds a lot of additional configuration flags, so let's clear them up
   192         separate_arguments(fpflags_parsed UNIX_COMMAND ${FPFLAGS})
   208         separate_arguments(fpflags_parsed UNIX_COMMAND ${FPFLAGS})
   193         separate_arguments(ghflags_parsed UNIX_COMMAND ${GHFLAGS})
   209         separate_arguments(ghflags_parsed UNIX_COMMAND ${GHFLAGS})
   194     endif()
   210     endif()
   195 endif()
   211 endif()
   196 
   212 
   197 set(pascal_flags ${fpflags_parsed}              # user flags
   213 list(APPEND pascal_flags ${fpflags_parsed}              # user flags
   198                  "-vm4079,4080,4081"            # fpc output format
   214                  "-vm4079,4080,4081"            # fpc output format
   199                  "-B"                           # compile all units
   215                  "-B"                           # compile all units
   200                  "-FE${PROJECT_BINARY_DIR}/bin" # fpc output directory
   216                  "-FE${PROJECT_BINARY_DIR}/bin" # fpc output directory
   201                  "-Fl${PROJECT_BINARY_DIR}/bin" # fpc linking directory
   217                  "-Fl${PROJECT_BINARY_DIR}/bin" # fpc linking directory
   202                  "-Cs2000000"                   # stack size
   218                  "-Cs2000000"                   # stack size
   203                  "-vewnq"                       # fpc output verbosity
   219                  "-vewnq"                       # fpc output verbosity
   204                  "-dDEBUGFILE"                  # macro for engine output
   220                  "-dDEBUGFILE"                  # macro for engine output
   205                  ${pascal_flags}                # adding to list
       
   206                  )
   221                  )
   207 set(haskell_flags "-O2" ${ghflags_parsed} ${haskell_flags})
   222 list(APPEND haskell_flags "-O2" ${ghflags_parsed})
   208 
   223 
   209 #get BUILD_TYPE and enable/disable optimisation
   224 #get BUILD_TYPE and enable/disable optimisation
   210 message(STATUS "Using ${CMAKE_BUILD_TYPE} configuration")
   225 message(STATUS "Using ${CMAKE_BUILD_TYPE} configuration")
   211 if(CMAKE_BUILD_TYPE MATCHES "DEBUG")
   226 if(CMAKE_BUILD_TYPE MATCHES "DEBUG")
   212     set(pascal_flags "-O-" "-g" "-gl" "-gv" ${pascal_flags})
   227     list(APPEND pascal_flags "-O-" "-g" "-gl" "-gv")
   213     set(haskell_flags "-Wall" "-debug" "-dcore-lint" "-fno-warn-unused-do-bind" ${haskell_flags})
   228     list(APPEND haskell_flags "-Wall" "-debug" "-dcore-lint" "-fno-warn-unused-do-bind")
   214 else()
   229 else()
   215 #    set(pascal_flags "-O3" "-OpPENTIUM4" "-CfSSE3" "-Xs" "-Si" ${pascal_flags})
   230 #    set(pascal_flags "-O3" "-OpPENTIUM4" "-CfSSE3" "-Xs" "-Si" ${pascal_flags})
   216     set(pascal_flags "-Os" "-Xs" "-Si" ${pascal_flags})
   231     list(APPEND pascal_flags "-Os" "-Xs" "-Si")
   217     set(haskell_flags "-w" "-fno-warn-unused-do-bind" ${haskell_flags})
   232     list(APPEND haskell_flags "-w" "-fno-warn-unused-do-bind")
   218 endif()
   233 endif()
   219 
       
   220 
       
   221 #finish setting paths
       
   222 if(DEFINED DATA_INSTALL_DIR)
       
   223     set(SHAREPATH ${DATA_INSTALL_DIR}/hedgewars/)
       
   224 else()
       
   225     set(SHAREPATH share/hedgewars/)
       
   226 endif()
       
   227 set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
       
   228 set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
       
   229 if(WIN32)
       
   230     set(CMAKE_PREFIX_PATH "${CMAKE_SOURCE_DIR}/misc/winutils/")
       
   231     link_directories("${EXECUTABLE_OUTPUT_PATH}" "${CMAKE_SOURCE_DIR}/misc/winutils/bin")
       
   232 endif(WIN32)
       
   233 
   234 
   234 
   235 
   235 #server discovery
   236 #server discovery
   236 if(NOT NOSERVER)
   237 if(NOT NOSERVER)
   237     if(GHC)
   238     if(GHC)
   260     message(STATUS "Found LUA: ${LUA_DEFAULT}")
   261     message(STATUS "Found LUA: ${LUA_DEFAULT}")
   261 else()
   262 else()
   262     message(STATUS "LUA will be provided by the bundled sources")
   263     message(STATUS "LUA will be provided by the bundled sources")
   263     add_subdirectory(misc/liblua)
   264     add_subdirectory(misc/liblua)
   264     #linking with liblua.a requires system readline
   265     #linking with liblua.a requires system readline
   265     set(pascal_flags "-k${EXECUTABLE_OUTPUT_PATH}/lib${LUA_LIBRARY}.a" "-k-lreadline" ${pascal_flags})
   266     list(APPEND pascal_flags "-k${EXECUTABLE_OUTPUT_PATH}/lib${LUA_LIBRARY}.a" "-k-lreadline")
   266 endif()
   267 endif()
   267 
   268 
   268 
   269 
   269 #physfs library (static on unix, dll on win32)
   270 #physfs library (static on unix, dll on win32)
   270 add_subdirectory(misc/physfs)
   271 add_subdirectory(misc/physfs)
   271 if(NOT WIN32)
   272 if(NOT WIN32)
   272     set(pascal_flags "-k${LIBRARY_OUTPUT_PATH}/libphysfs.a" ${pascal_flags})
   273     list(APPEND pascal_flags "-k${LIBRARY_OUTPUT_PATH}/libphysfs.a")
   273 endif()
   274 endif()
   274 
   275 
   275 
   276 
   276 #main engine
   277 #main engine
   277 add_subdirectory(hedgewars)
   278 add_subdirectory(hedgewars)
   308     set(CPACK_NSIS_DISPLAY_NAME "Hedgewars")
   309     set(CPACK_NSIS_DISPLAY_NAME "Hedgewars")
   309     set(CPACK_NSIS_HELP_LINK "http://www.hedgewars.org/")
   310     set(CPACK_NSIS_HELP_LINK "http://www.hedgewars.org/")
   310     set(CPACK_NSIS_URL_INFO_ABOUT "http://www.hedgewars.org/")
   311     set(CPACK_NSIS_URL_INFO_ABOUT "http://www.hedgewars.org/")
   311     set(CPACK_NSIS_CONTACT "unC0Rr@gmail.com")
   312     set(CPACK_NSIS_CONTACT "unC0Rr@gmail.com")
   312     set(CPACK_NSIS_MODIFY_PATH OFF)
   313     set(CPACK_NSIS_MODIFY_PATH OFF)
       
   314     set(CPACK_NSIS_EXECUTABLES_DIRECTORY "${target_binary_install_dir}")
   313     set(CPACK_GENERATOR "ZIP;NSIS")
   315     set(CPACK_GENERATOR "ZIP;NSIS")
   314     set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "hedgewars")
   316     set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "hedgewars")
   315 else(WIN32 AND NOT UNIX)
   317 else(WIN32 AND NOT UNIX)
   316     set(CPACK_STRIP_FILES "bin/hedgewars;bin/hwengine")
   318     set(CPACK_STRIP_FILES "bin/hedgewars;bin/hwengine")
   317 endif(WIN32 AND NOT UNIX)
   319 endif(WIN32 AND NOT UNIX)