[1505] | 1 | PROJECT(Orxonox) |
---|
| 2 | |
---|
[2509] | 3 | CMAKE_MINIMUM_REQUIRED(VERSION 2.6 FATAL_ERROR) |
---|
[1505] | 4 | |
---|
[2582] | 5 | ############### Various Options ################# |
---|
| 6 | |
---|
| 7 | # Keep devs from using the root directory as binary directory (messes up the source tree) |
---|
[2574] | 8 | IF(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR}) |
---|
[2582] | 9 | MESSAGE(FATAL_ERROR "Do not use the root directory as CMake output directory! mkdir build; cd build; cmake ..") |
---|
[2574] | 10 | ENDIF(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR}) |
---|
| 11 | |
---|
[1776] | 12 | # This sets where to look for modules (e.g. "Find*.cmake" files) |
---|
[1505] | 13 | SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) |
---|
| 14 | |
---|
[2582] | 15 | # Set binary output directories |
---|
[2583] | 16 | SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) |
---|
| 17 | SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) |
---|
| 18 | SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) |
---|
[2582] | 19 | |
---|
| 20 | # Set Debug build to default when not having multi-config generator like msvc |
---|
| 21 | IF(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) |
---|
| 22 | SET(CMAKE_BUILD_TYPE "Debug") |
---|
| 23 | ENDIF(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) |
---|
| 24 | |
---|
| 25 | ############## Platform Config ################## |
---|
| 26 | |
---|
[2583] | 27 | # Configure platform specific options |
---|
[2579] | 28 | INCLUDE(ConfigPlatforms) |
---|
[1505] | 29 | |
---|
[2509] | 30 | ################ Test options ################### |
---|
[1505] | 31 | |
---|
[2509] | 32 | OPTION(ENABLE_TESTS "Enable build tests.") |
---|
| 33 | IF(ENABLE_TESTS) |
---|
[1505] | 34 | ENABLE_TESTING() |
---|
[2509] | 35 | ENDIF(ENABLE_TESTS) |
---|
[1505] | 36 | |
---|
[2509] | 37 | OPTION(NETWORK_TESTING_ENABLED "Build network testing tools: i.e. chatclient chatserver and alike.") |
---|
| 38 | OPTION(NETWORKTRAFFIC_TESTING_ENABLED "Build dummyserver4 and dummyclient4.") |
---|
[1505] | 39 | |
---|
| 40 | ############### Library finding ################# |
---|
| 41 | |
---|
[2583] | 42 | # Performs the search and sets the variables |
---|
[2579] | 43 | |
---|
[2583] | 44 | # Expand the next statement if newer boost versions than 1.36.1 are released |
---|
| 45 | SET(Boost_ADDITIONAL_VERSIONS 1.37 1.37.0 CACHE STRING "") |
---|
| 46 | FIND_PACKAGE(Boost 1.34 REQUIRED thread filesystem) |
---|
[2588] | 47 | # With MSVC, automatic linking is performed for boost. So wee need to tell |
---|
| 48 | # the linker where to find them. Also note that when running FindBoost for the |
---|
| 49 | # first time, it will set ${Boost_LIBRARIES} to "" but afterwards to the libs. |
---|
| 50 | IF (MSVC) |
---|
| 51 | LINK_DIRECTORIES(${Boost_LIBRARY_DIRS}) |
---|
| 52 | ENDIF (MSVC) |
---|
[2509] | 53 | FIND_PACKAGE(OGRE REQUIRED) |
---|
| 54 | FIND_PACKAGE(CEGUI REQUIRED) |
---|
| 55 | FIND_PACKAGE(ENet REQUIRED) |
---|
| 56 | FIND_PACKAGE(OpenAL REQUIRED) |
---|
| 57 | FIND_PACKAGE(ALUT REQUIRED) |
---|
| 58 | FIND_PACKAGE(OggVorbis REQUIRED) |
---|
| 59 | FIND_PACKAGE(ZLIB REQUIRED) |
---|
| 60 | FIND_PACKAGE(DirectX REQUIRED) |
---|
[1505] | 61 | |
---|
[2510] | 62 | # Require Lua 5.0 or 5.1 |
---|
| 63 | FIND_PACKAGE(Lua50 QUIET) |
---|
| 64 | IF(NOT LUA50_FOUND) |
---|
[2583] | 65 | # Remove variables set by Lua50 and try with Lua51 |
---|
| 66 | SET(LUA_INCLUDE_DIR) |
---|
| 67 | SET(LUA_LIBRARY_lua) |
---|
| 68 | SET(LUA_LIBRARY_lualib) |
---|
| 69 | SET(LUA_LIBRARIES) |
---|
| 70 | FIND_PACKAGE(Lua51 REQUIRED) |
---|
[2510] | 71 | ENDIF(NOT LUA50_FOUND) |
---|
| 72 | # Determine Lua version (Lua50 may also find Lua51) |
---|
| 73 | FILE(STRINGS "${LUA_INCLUDE_DIR}/lua.h" LUA_VERSION REGEX "LUA_VERSION") |
---|
| 74 | STRING(REGEX REPLACE "^.*\"Lua (.*)\".*$" "\\1" LUA_VERSION "${LUA_VERSION}") |
---|
| 75 | |
---|
[2579] | 76 | # QUIET: Don't require the whole tcl rat tail |
---|
[2509] | 77 | FIND_PACKAGE(TCL QUIET) |
---|
| 78 | IF(NOT TCL_FOUND) |
---|
[2583] | 79 | MESSAGE(FATAL_ERROR "Tcl was not found.") |
---|
[2509] | 80 | ENDIF(NOT TCL_FOUND) |
---|
[1505] | 81 | |
---|
[2579] | 82 | # Hide variables created by CMake FindXX scripts |
---|
| 83 | MARK_AS_ADVANCED( |
---|
[2583] | 84 | LUA_LIBRARY_lua |
---|
| 85 | LUA_LIBRARY_lualib |
---|
| 86 | OPENAL_INCLUDE_DIR |
---|
| 87 | OPENAL_LIBRARY |
---|
[2579] | 88 | ) |
---|
| 89 | |
---|
[2582] | 90 | ############### Orxonox Source ################## |
---|
| 91 | |
---|
[1505] | 92 | ADD_SUBDIRECTORY(src) |
---|
[2509] | 93 | ADD_SUBDIRECTORY(bin) |
---|