CMakeLists.txt
changeset 7705 15f5d3cd35c6
parent 7704 b25add2fdfa6
child 7709 631852904cee
equal deleted inserted replaced
7704:b25add2fdfa6 7705:15f5d3cd35c6
   135     message(STATUS "Build system: Mac OS X ${current_macosx_version} with GCC:${CMAKE_C_COMPILER}")
   135     message(STATUS "Build system: Mac OS X ${current_macosx_version} with GCC:${CMAKE_C_COMPILER}")
   136     message(STATUS "Target system: Mac OS X ${minimum_macosx_version} for architecture(s):${CMAKE_OSX_ARCHITECTURES}")
   136     message(STATUS "Target system: Mac OS X ${minimum_macosx_version} for architecture(s):${CMAKE_OSX_ARCHITECTURES}")
   137 endif(APPLE)
   137 endif(APPLE)
   138 
   138 
   139 
   139 
   140 #build Debug only when explicitally set
   140 #when build type is not specified, assume Debug/Release according to build version information
   141 if (NOT CMAKE_BUILD_TYPE)
   141 if (NOT CMAKE_BUILD_TYPE)
   142     set (CMAKE_BUILD_TYPE RELEASE CACHE STRING "Choose the type of build, options are: Debug Release." FORCE)
   142     if(HW_DEV)
       
   143         set (build_type "DEBUG")
       
   144     else()
       
   145         set (build_type "RELEASE")
       
   146     endif()
       
   147     set (CMAKE_BUILD_TYPE ${build_type} CACHE STRING "Choose the type of build, options are: Debug Release." FORCE)
   143 endif (NOT CMAKE_BUILD_TYPE)
   148 endif (NOT CMAKE_BUILD_TYPE)
   144 
       
   145 if(CMAKE_BUILD_TYPE MATCHES DEBUG OR CMAKE_BUILD_TYPE MATCHES "Debug" OR CMAKE_BUILD_TYPE MATCHES "debug")
       
   146     message(STATUS "Building Debug")
       
   147     set(Optz false)
       
   148 else()
       
   149     message(STATUS "Building Release")
       
   150     set(Optz true)
       
   151 endif()
       
   152 
   149 
   153 
   150 
   154 #set default flags values for all projects
   151 #set default flags values for all projects
   155 set(CMAKE_C_FLAGS "-pipe ${CMAKE_C_FLAGS}")
   152 set(CMAKE_C_FLAGS "-pipe ${CMAKE_C_FLAGS}")
   156 set(CMAKE_C_FLAGS_RELEASE "-w -Os -fomit-frame-pointer ${CMAKE_C_FLAGS_RELEASE}")
   153 set(CMAKE_C_FLAGS_RELEASE "-w -Os -fomit-frame-pointer ${CMAKE_C_FLAGS_RELEASE}")
   161 
   158 
   162 #parse additional parameters
   159 #parse additional parameters
   163 if(FPFLAGS OR GHFLAGS)
   160 if(FPFLAGS OR GHFLAGS)
   164     math(EXPR cmake_version "${CMAKE_MAJOR_VERSION}*10000 + ${CMAKE_MINOR_VERSION}*100 + ${CMAKE_PATCH_VERSION}")
   161     math(EXPR cmake_version "${CMAKE_MAJOR_VERSION}*10000 + ${CMAKE_MINOR_VERSION}*100 + ${CMAKE_PATCH_VERSION}")
   165     if(cmake_version LESS "020800")
   162     if(cmake_version LESS "020800")
   166         message(STATUS "FPFLAGS and GHFLAGS are available only from Cmake 2.8, ignoring...")
   163         message(STATUS "FPFLAGS and GHFLAGS are available only when using CMake >= 2.8")
   167     else()
   164     else()
   168         separate_arguments(fpflags_full UNIX_COMMAND ${FPFLAGS})
   165         separate_arguments(fpflags_parsed UNIX_COMMAND ${FPFLAGS})
   169         separate_arguments(ghflags_full UNIX_COMMAND ${GHFLAGS})
   166         separate_arguments(ghflags_parsed UNIX_COMMAND ${GHFLAGS})
   170     endif()
   167     endif()
   171 endif()
   168 endif()
   172 
   169 
   173 set(pascal_flags ${fpflags_full} "-B" "-FE../bin" "-Cs2000000" "-vewn" "-dDEBUGFILE" ${pascal_flags})
   170 set(pascal_flags ${fpflags_parsed} "-B" "-FE../bin" "-Cs2000000" "-vewn" "-dDEBUGFILE" ${pascal_flags})
   174 set(haskell_flags "-O2" ${ghflags_full} ${haskell_flags})
   171 set(haskell_flags "-O2" ${ghflags_parsed} ${haskell_flags})
   175 
   172 
   176 if(Optz)
   173 #get BUILD_TYPE and enable/disable optimisation
       
   174 if(CMAKE_BUILD_TYPE MATCHES "DEBUG" OR CMAKE_BUILD_TYPE MATCHES "Debug" OR CMAKE_BUILD_TYPE MATCHES "debug")
       
   175     message(STATUS "Building Debug")
       
   176     set(pascal_flags "-O-" "-g" "-gl" "-gv" "-Ct" ${pascal_flags})
       
   177     set(haskell_flags "-Wall" "-debug" "-dcore-lint" "-fno-warn-unused-do-bind" ${haskell_flags})
       
   178 else()
       
   179     message(STATUS "Building Release")
   177 #    set(pascal_flags "-O3" "-OpPENTIUM4" "-CfSSE3" "-Xs" "-Si" ${pascal_flags})
   180 #    set(pascal_flags "-O3" "-OpPENTIUM4" "-CfSSE3" "-Xs" "-Si" ${pascal_flags})
   178     set(pascal_flags "-Os" "-Ooregvar" "-Xs" "-Si" ${pascal_flags})
   181     set(pascal_flags "-Os" "-Ooregvar" "-Xs" "-Si" ${pascal_flags})
   179     set(haskell_flags "-w" "-fno-warn-unused-do-bind" ${haskell_flags})
   182     set(haskell_flags "-w" "-fno-warn-unused-do-bind" ${haskell_flags})
   180 else(Optz)
   183 endif()
   181     set(pascal_flags "-O-" "-g" "-gl" "-gv" "-Ct" ${pascal_flags})
   184 
   182     set(haskell_flags "-Wall" "-debug" "-dcore-lint" "-fno-warn-unused-do-bind" ${haskell_flags})
   185 
   183 endif(Optz)
   186 #finish setting paths
   184 
       
   185 
       
   186 if(DEFINED DATA_INSTALL_DIR)
   187 if(DEFINED DATA_INSTALL_DIR)
   187     set(SHAREPATH ${DATA_INSTALL_DIR}/hedgewars/)
   188     set(SHAREPATH ${DATA_INSTALL_DIR}/hedgewars/)
   188 else()
   189 else()
   189     set(SHAREPATH share/hedgewars/)
   190     set(SHAREPATH share/hedgewars/)
   190 endif()
   191 endif()
   191 set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
   192 set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
   192 
   193 
   193 
   194 
       
   195 #server discovery
   194 if(NOT NOSERVER)
   196 if(NOT NOSERVER)
   195     if(GHC)
   197     if(GHC)
   196         set(ghc_executable ${GHC})
   198         set(ghc_executable ${GHC})
   197     else()
   199     else()
   198         find_program(ghc_executable ghc)
   200         find_program(ghc_executable ghc)
   208 else()
   210 else()
   209     message(STATUS "Server will not be built per user request")
   211     message(STATUS "Server will not be built per user request")
   210     set(HAVE_NETSERVER false)
   212     set(HAVE_NETSERVER false)
   211 endif()
   213 endif()
   212 
   214 
       
   215 
       
   216 #lua discovery
   213 find_package(Lua)
   217 find_package(Lua)
   214 if(LUA_FOUND)
   218 if(LUA_FOUND)
   215     message(STATUS "Lua library is present on your system (${LUA_DEFAULT})")
   219     message(STATUS "Lua library is present on your system (${LUA_DEFAULT})")
   216 else()
   220 else()
   217     message(STATUS "Lua library not found, building bundled dependency")
   221     message(STATUS "Lua library not found, building bundled dependency")
   218     add_subdirectory(misc/liblua)
   222     add_subdirectory(misc/liblua)
   219     #linking with liblua.a requires system readline -- this works everywhere, right?
   223     #linking with liblua.a requires system readline -- this works everywhere, right?
   220     set(pascal_flags "-k${EXECUTABLE_OUTPUT_PATH}/lib${LUA_LIBRARY}.a" "-k-lreadline" ${pascal_flags})
   224     set(pascal_flags "-k${EXECUTABLE_OUTPUT_PATH}/lib${LUA_LIBRARY}.a" "-k-lreadline" ${pascal_flags})
   221 endif()
   225 endif()
   222 
   226 
       
   227 
       
   228 #main engine
   223 add_subdirectory(hedgewars)
   229 add_subdirectory(hedgewars)
   224 
   230 
   225 
   231 #Android related build scripts
   226 #run cmake -DANDROID=1 to enable this
       
   227 if(ANDROID)
   232 if(ANDROID)
       
   233     #run cmake -DANDROID=1 to enable this
   228     add_subdirectory(project_files/Android-build)
   234     add_subdirectory(project_files/Android-build)
   229 endif()
   235 endif()
   230 
   236 
   231 
   237 #TODO: when ANDROID, BUILD_ENGINE_LIBRARY should be set
   232 if(NOT (BUILD_ENGINE_LIBRARY OR ANDROID))
   238 if(NOT (BUILD_ENGINE_LIBRARY OR ANDROID))
   233     add_subdirectory(bin)
   239     add_subdirectory(bin)
   234     add_subdirectory(misc/quazip)
   240     add_subdirectory(misc/quazip)
   235     add_subdirectory(QTfrontend)
   241     add_subdirectory(QTfrontend)
   236     add_subdirectory(share)
   242     add_subdirectory(share)