[2710] | 1 | # |
---|
| 2 | # ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | # > www.orxonox.net < |
---|
| 4 | # |
---|
| 5 | # This program is free software; you can redistribute it and/or |
---|
| 6 | # modify it under the terms of the GNU General Public License |
---|
| 7 | # as published by the Free Software Foundation; either version 2 |
---|
| 8 | # of the License, or (at your option) any later version. |
---|
| 9 | # |
---|
| 10 | # This program is distributed in the hope that it will be useful, |
---|
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 13 | # GNU General Public License for more details. |
---|
| 14 | # |
---|
| 15 | # You should have received a copy of the GNU General Public License along |
---|
| 16 | # with this program; if not, write to the Free Software Foundation, |
---|
| 17 | # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 18 | # |
---|
[5695] | 19 | # |
---|
| 20 | # Author: |
---|
| 21 | # Reto Grieder |
---|
| 22 | # Description: |
---|
| 23 | # Configures some basics and controls the configuration scripts |
---|
| 24 | # |
---|
| 25 | |
---|
[8351] | 26 | # Defined LINUX |
---|
| 27 | IF(UNIX AND NOT APPLE) |
---|
| 28 | SET(LINUX TRUE) |
---|
| 29 | ENDIF() |
---|
| 30 | |
---|
[8858] | 31 | # Keep devs from using the root directory as binary directory (messes up the source tree) |
---|
| 32 | IF(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR}) |
---|
| 33 | MESSAGE(FATAL_ERROR "Please do not use the root directory as CMake output directory! |
---|
| 34 | mkdir build; cd build; cmake .. |
---|
| 35 | And you will have to clean the source directory by deleting CMakeCache.txt and the folder CMakeFiles") |
---|
| 36 | ENDIF() |
---|
| 37 | |
---|
| 38 | PROJECT(Orxonox C CXX) |
---|
| 39 | |
---|
| 40 | # Check AFTER the PROJECT command because MSVC10 gets defined there |
---|
[7383] | 41 | IF(WIN32) |
---|
[8351] | 42 | IF(MSVC10) |
---|
| 43 | CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3 FATAL_ERROR) |
---|
| 44 | ELSE() |
---|
| 45 | CMAKE_MINIMUM_REQUIRED(VERSION 2.6.3 FATAL_ERROR) |
---|
| 46 | ENDIF() |
---|
[7383] | 47 | ELSE() |
---|
[8351] | 48 | CMAKE_MINIMUM_REQUIRED(VERSION 2.6 FATAL_ERROR) |
---|
[7383] | 49 | ENDIF() |
---|
[1505] | 50 | |
---|
[5695] | 51 | ################ General Config ################# |
---|
| 52 | |
---|
| 53 | # Version info |
---|
[2710] | 54 | SET(ORXONOX_VERSION_MAJOR 0) |
---|
| 55 | SET(ORXONOX_VERSION_MINOR 0) |
---|
[8474] | 56 | SET(ORXONOX_VERSION_PATCH 5) |
---|
| 57 | SET(ORXONOX_VERSION |
---|
| 58 | ${ORXONOX_VERSION_MAJOR}.${ORXONOX_VERSION_MINOR}.${ORXONOX_VERSION_PATCH} |
---|
| 59 | ) |
---|
[2718] | 60 | SET(ORXONOX_VERSION_NAME "Arcturus") |
---|
[1505] | 61 | |
---|
[5695] | 62 | # Standard path suffixes |
---|
| 63 | SET(DEFAULT_RUNTIME_PATH bin) |
---|
| 64 | SET(DEFAULT_LIBRARY_PATH lib) |
---|
| 65 | SET(DEFAULT_ARCHIVE_PATH lib/static) |
---|
| 66 | SET(DEFAULT_MODULE_PATH lib/modules) |
---|
[10624] | 67 | SET(DEFAULT_PLUGIN_PATH lib/plugins) |
---|
[5695] | 68 | SET(DEFAULT_DOC_PATH doc) |
---|
| 69 | SET(DEFAULT_DATA_PATH data) |
---|
| 70 | SET(DEFAULT_CONFIG_PATH config) |
---|
| 71 | SET(DEFAULT_LOG_PATH log) |
---|
[8351] | 72 | SET(DEFAULT_BUNDLE_PATH bundle) |
---|
[1505] | 73 | |
---|
[5695] | 74 | # Set output directories |
---|
| 75 | SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_RUNTIME_PATH}) |
---|
| 76 | SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_LIBRARY_PATH}) |
---|
| 77 | SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_ARCHIVE_PATH}) |
---|
| 78 | SET(CMAKE_MODULE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_MODULE_PATH}) |
---|
[10624] | 79 | SET(CMAKE_PLUGIN_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_PLUGIN_PATH}) |
---|
[5695] | 80 | SET(CMAKE_DOC_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_DOC_PATH}) |
---|
| 81 | # Data directories are only inputs, no delclaration here |
---|
| 82 | SET(CMAKE_CONFIG_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_CONFIG_PATH}) |
---|
| 83 | SET(CMAKE_LOG_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_LOG_PATH}) |
---|
| 84 | |
---|
[10624] | 85 | # Set the extension of the helper-files for dynamic modules |
---|
[5695] | 86 | SET(ORXONOX_MODULE_EXTENSION ".module") |
---|
[10624] | 87 | SET(ORXONOX_PLUGIN_EXTENSION ".plugin") |
---|
[5695] | 88 | |
---|
[10624] | 89 | # Delete all existing helper-files for dynamic modules |
---|
| 90 | # modules: |
---|
| 91 | FILE(GLOB_RECURSE _helper_files ${CMAKE_MODULE_OUTPUT_DIRECTORY}/*${ORXONOX_MODULE_EXTENSION}) |
---|
| 92 | IF(_helper_files) |
---|
| 93 | FILE(REMOVE ${_helper_files}) |
---|
| 94 | ENDIF() |
---|
| 95 | # plugins: |
---|
| 96 | FILE(GLOB_RECURSE _helper_files ${CMAKE_PLUGIN_OUTPUT_DIRECTORY}/*${ORXONOX_PLUGIN_EXTENSION}) |
---|
| 97 | IF(_helper_files) |
---|
| 98 | FILE(REMOVE ${_helper_files}) |
---|
| 99 | ENDIF() |
---|
| 100 | |
---|
[5695] | 101 | # Sets where to find the external libraries like OgreMain.dll at runtime |
---|
| 102 | # On Unix you should not have to change this at all. |
---|
| 103 | # This only applies to development runs in the build tree |
---|
| 104 | SET(RUNTIME_LIBRARY_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) |
---|
| 105 | |
---|
| 106 | # Take care of some CMake 2.6.0 leftovers |
---|
| 107 | MARK_AS_ADVANCED(EXECUTABLE_OUTPUT_PATH LIBRARY_OUTPUT_PATH) |
---|
| 108 | |
---|
| 109 | # This sets where to look for CMake modules (e.g. "Find*.cmake" files) |
---|
[7163] | 110 | SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_SOURCE_DIR}/cmake/tools) |
---|
[1505] | 111 | |
---|
[8368] | 112 | # Flag variables for extra configuration "RelForDevs" should be hidden |
---|
| 113 | MARK_AS_ADVANCED( |
---|
| 114 | CMAKE_CXX_FLAGS_RELFORDEVS |
---|
| 115 | CMAKE_C_FLAGS_RELFORDEVS |
---|
| 116 | CMAKE_EXE_LINKER_FLAGS_RELFORDEVS |
---|
| 117 | CMAKE_MODULE_LINKER_FLAGS_RELFORDEVS |
---|
| 118 | CMAKE_SHARED_LINKER_FLAGS_RELFORDEVS |
---|
| 119 | ) |
---|
| 120 | |
---|
[5695] | 121 | IF(NOT CMAKE_CONFIGURATION_TYPES) |
---|
[8368] | 122 | # Set Debug build to default when not having multi-config generator like MSVC or XCODE |
---|
[5695] | 123 | IF(NOT CMAKE_BUILD_TYPE) |
---|
| 124 | SET(CMAKE_BUILD_TYPE Debug CACHE STRING |
---|
[8368] | 125 | "Build types are: Debug, RelForDevs, RelWithDebInfo, Release, MinSizeRel" FORCE) |
---|
[5695] | 126 | ENDIF() |
---|
| 127 | MARK_AS_ADVANCED(CLEAR CMAKE_BUILD_TYPE) |
---|
| 128 | |
---|
| 129 | MESSAGE(STATUS "*** Build type is ${CMAKE_BUILD_TYPE} ***") |
---|
| 130 | ELSE() |
---|
[8368] | 131 | # Make sure no build type is ever set |
---|
[5695] | 132 | IF(CMAKE_BUILD_TYPE) |
---|
| 133 | SET(CMAKE_BUILD_TYPE CACHE STRING FORCE) |
---|
| 134 | ENDIF() |
---|
[8368] | 135 | MARK_AS_ADVANCED(FORCE CMAKE_BUILD_TYPE) |
---|
| 136 | # Add our extra configuration "RelForDevs" |
---|
| 137 | SET(CMAKE_CONFIGURATION_TYPES "Debug;RelForDevs;RelWithDebInfo;Release;MinSizeRel" |
---|
| 138 | CACHE STRING "Semicolon separated list of supported configuration types." FORCE) |
---|
[5695] | 139 | ENDIF() |
---|
| 140 | |
---|
[8351] | 141 | # Debug builds can not be installed |
---|
| 142 | INSTALL(SCRIPT cmake/InstallCheck.cmake) |
---|
| 143 | |
---|
| 144 | IF(APPLE) |
---|
| 145 | # Set 10.5 as the base SDK by default |
---|
| 146 | SET(XCODE_ATTRIBUTE_SDKROOT macosx10.5) |
---|
| 147 | |
---|
| 148 | # 10.6 sets x86_64 as the default architecture. |
---|
| 149 | # Because Carbon isn't supported on 64-bit and we still need it, force the architectures to ppc and i386 |
---|
| 150 | IF(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64") |
---|
| 151 | SET(CMAKE_OSX_ARCHITECTURES "i386") |
---|
| 152 | ENDIF() |
---|
| 153 | IF(CMAKE_OSX_ARCHITECTURES MATCHES "ppc64") |
---|
| 154 | SET(CMAKE_OSX_ARCHITECTURES "ppc") |
---|
| 155 | ENDIF() |
---|
| 156 | IF(NOT CMAKE_OSX_ARCHITECTURES) |
---|
| 157 | SET(CMAKE_OSX_ARCHITECTURES "i386") |
---|
| 158 | ENDIF() |
---|
| 159 | ENDIF() |
---|
| 160 | |
---|
[5695] | 161 | ########### Subfolders and Subscripts ########### |
---|
| 162 | |
---|
[8351] | 163 | # General build and compiler options and configurations |
---|
| 164 | INCLUDE(CompilerConfig) |
---|
| 165 | |
---|
[2710] | 166 | # Library finding |
---|
| 167 | INCLUDE(LibraryConfig) |
---|
[1505] | 168 | |
---|
[5695] | 169 | # Configure installation paths and options |
---|
| 170 | INCLUDE(InstallConfig) |
---|
[1505] | 171 | |
---|
[5695] | 172 | # Configure data directory location and installation |
---|
| 173 | ADD_SUBDIRECTORY(data) |
---|
| 174 | |
---|
[2710] | 175 | # Create the actual project |
---|
| 176 | ADD_SUBDIRECTORY(src) |
---|
[1505] | 177 | |
---|
[9550] | 178 | # Create the test suites |
---|
| 179 | ADD_SUBDIRECTORY(test) |
---|
| 180 | |
---|
[2710] | 181 | # Configure the binary output directory. Do this after src! |
---|
| 182 | ADD_SUBDIRECTORY(bin) |
---|
[1505] | 183 | |
---|
[8351] | 184 | # System specific files (mostly for installation) |
---|
| 185 | ADD_SUBDIRECTORY(contrib) |
---|
| 186 | |
---|
[5695] | 187 | # Last but not least: Try to make a doc target with Doxygen |
---|
[2710] | 188 | ADD_SUBDIRECTORY(doc) |
---|
[8351] | 189 | |
---|
| 190 | ########### CPack Packaging ########### |
---|
| 191 | |
---|
| 192 | # Currently only testing on Apple |
---|
| 193 | #IF(APPLE) |
---|
| 194 | # INCLUDE(BundleConfig) |
---|
| 195 | #ENDIF(APPLE) |
---|