| 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 | # |
|---|
| 19 | # |
|---|
| 20 | # Author: |
|---|
| 21 | # Reto Grieder |
|---|
| 22 | # Description: |
|---|
| 23 | # Configures some basics and controls the configuration scripts |
|---|
| 24 | # |
|---|
| 25 | |
|---|
| 26 | # Defined LINUX |
|---|
| 27 | IF(UNIX AND NOT APPLE) |
|---|
| 28 | SET(LINUX TRUE) |
|---|
| 29 | ENDIF() |
|---|
| 30 | |
|---|
| 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 | # Uncomment to test compilation with clang on linux |
|---|
| 41 | # SET(C clang) |
|---|
| 42 | # SET(CXX clang) |
|---|
| 43 | # SET(CMAKE_CXX_COMPILER_ID "Clang") |
|---|
| 44 | |
|---|
| 45 | # Check AFTER the PROJECT command because MSVC10 gets defined there |
|---|
| 46 | IF(WIN32) |
|---|
| 47 | IF(MSVC10) |
|---|
| 48 | CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3 FATAL_ERROR) |
|---|
| 49 | ELSE() |
|---|
| 50 | CMAKE_MINIMUM_REQUIRED(VERSION 2.6.3 FATAL_ERROR) |
|---|
| 51 | ENDIF() |
|---|
| 52 | ELSE() |
|---|
| 53 | CMAKE_MINIMUM_REQUIRED(VERSION 2.6 FATAL_ERROR) |
|---|
| 54 | ENDIF() |
|---|
| 55 | |
|---|
| 56 | ################ General Config ################# |
|---|
| 57 | |
|---|
| 58 | # Version info |
|---|
| 59 | SET(ORXONOX_VERSION_MAJOR 0) |
|---|
| 60 | SET(ORXONOX_VERSION_MINOR 0) |
|---|
| 61 | SET(ORXONOX_VERSION_PATCH 5) |
|---|
| 62 | SET(ORXONOX_VERSION |
|---|
| 63 | ${ORXONOX_VERSION_MAJOR}.${ORXONOX_VERSION_MINOR}.${ORXONOX_VERSION_PATCH} |
|---|
| 64 | ) |
|---|
| 65 | SET(ORXONOX_VERSION_NAME "Arcturus") |
|---|
| 66 | |
|---|
| 67 | |
|---|
| 68 | # Standard path suffixes |
|---|
| 69 | SET(DEFAULT_RUNTIME_PATH bin) |
|---|
| 70 | SET(DEFAULT_LIBRARY_PATH lib) |
|---|
| 71 | SET(DEFAULT_ARCHIVE_PATH lib/static) |
|---|
| 72 | SET(DEFAULT_MODULE_PATH lib/modules) |
|---|
| 73 | SET(DEFAULT_PLUGIN_PATH lib/plugins) |
|---|
| 74 | SET(DEFAULT_DOC_PATH doc) |
|---|
| 75 | SET(DEFAULT_DATA_PATH data) |
|---|
| 76 | SET(DEFAULT_CONFIG_PATH config) |
|---|
| 77 | SET(DEFAULT_LOG_PATH log) |
|---|
| 78 | SET(DEFAULT_BUNDLE_PATH bundle) |
|---|
| 79 | |
|---|
| 80 | # Set output directories |
|---|
| 81 | SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_RUNTIME_PATH}) |
|---|
| 82 | SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_LIBRARY_PATH}) |
|---|
| 83 | SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_ARCHIVE_PATH}) |
|---|
| 84 | SET(CMAKE_MODULE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_MODULE_PATH}) |
|---|
| 85 | SET(CMAKE_PLUGIN_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_PLUGIN_PATH}) |
|---|
| 86 | SET(CMAKE_DOC_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_DOC_PATH}) |
|---|
| 87 | # Data directories are only inputs, no delclaration here |
|---|
| 88 | SET(CMAKE_CONFIG_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_CONFIG_PATH}) |
|---|
| 89 | SET(CMAKE_LOG_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_LOG_PATH}) |
|---|
| 90 | |
|---|
| 91 | # Set the extension of the helper-files for dynamic modules |
|---|
| 92 | SET(ORXONOX_MODULE_EXTENSION ".module") |
|---|
| 93 | SET(ORXONOX_PLUGIN_EXTENSION ".plugin") |
|---|
| 94 | |
|---|
| 95 | # Delete all existing helper-files for dynamic modules |
|---|
| 96 | # modules: |
|---|
| 97 | FILE(GLOB_RECURSE _helper_files ${CMAKE_MODULE_OUTPUT_DIRECTORY}/*${ORXONOX_MODULE_EXTENSION}) |
|---|
| 98 | IF(_helper_files) |
|---|
| 99 | FILE(REMOVE ${_helper_files}) |
|---|
| 100 | ENDIF() |
|---|
| 101 | # plugins: |
|---|
| 102 | FILE(GLOB_RECURSE _helper_files ${CMAKE_PLUGIN_OUTPUT_DIRECTORY}/*${ORXONOX_PLUGIN_EXTENSION}) |
|---|
| 103 | IF(_helper_files) |
|---|
| 104 | FILE(REMOVE ${_helper_files}) |
|---|
| 105 | ENDIF() |
|---|
| 106 | |
|---|
| 107 | # Sets where to find the external libraries like OgreMain.dll at runtime |
|---|
| 108 | # On Unix you should not have to change this at all. |
|---|
| 109 | # This only applies to development runs in the build tree |
|---|
| 110 | SET(RUNTIME_LIBRARY_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) |
|---|
| 111 | |
|---|
| 112 | # Take care of some CMake 2.6.0 leftovers |
|---|
| 113 | MARK_AS_ADVANCED(EXECUTABLE_OUTPUT_PATH LIBRARY_OUTPUT_PATH) |
|---|
| 114 | |
|---|
| 115 | # This sets where to look for CMake modules (e.g. "Find*.cmake" files) |
|---|
| 116 | SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_SOURCE_DIR}/cmake/tools) |
|---|
| 117 | |
|---|
| 118 | # Flag variables for extra configuration "RelForDevs" should be hidden |
|---|
| 119 | MARK_AS_ADVANCED( |
|---|
| 120 | CMAKE_CXX_FLAGS_RELFORDEVS |
|---|
| 121 | CMAKE_C_FLAGS_RELFORDEVS |
|---|
| 122 | CMAKE_EXE_LINKER_FLAGS_RELFORDEVS |
|---|
| 123 | CMAKE_MODULE_LINKER_FLAGS_RELFORDEVS |
|---|
| 124 | CMAKE_SHARED_LINKER_FLAGS_RELFORDEVS |
|---|
| 125 | ) |
|---|
| 126 | |
|---|
| 127 | IF(NOT CMAKE_CONFIGURATION_TYPES) |
|---|
| 128 | # Set Debug build to default when not having multi-config generator like MSVC or XCODE |
|---|
| 129 | IF(NOT CMAKE_BUILD_TYPE) |
|---|
| 130 | SET(CMAKE_BUILD_TYPE Debug CACHE STRING |
|---|
| 131 | "Build types are: Debug, RelForDevs, RelWithDebInfo, Release, MinSizeRel" FORCE) |
|---|
| 132 | ENDIF() |
|---|
| 133 | MARK_AS_ADVANCED(CLEAR CMAKE_BUILD_TYPE) |
|---|
| 134 | |
|---|
| 135 | MESSAGE(STATUS "*** Build type is ${CMAKE_BUILD_TYPE} ***") |
|---|
| 136 | ELSE() |
|---|
| 137 | # Make sure no build type is ever set |
|---|
| 138 | IF(CMAKE_BUILD_TYPE) |
|---|
| 139 | SET(CMAKE_BUILD_TYPE CACHE STRING FORCE) |
|---|
| 140 | ENDIF() |
|---|
| 141 | MARK_AS_ADVANCED(FORCE CMAKE_BUILD_TYPE) |
|---|
| 142 | # Add our extra configuration "RelForDevs" |
|---|
| 143 | SET(CMAKE_CONFIGURATION_TYPES "Debug;RelForDevs;RelWithDebInfo;Release;MinSizeRel" |
|---|
| 144 | CACHE STRING "Semicolon separated list of supported configuration types." FORCE) |
|---|
| 145 | ENDIF() |
|---|
| 146 | |
|---|
| 147 | # Debug builds can not be installed |
|---|
| 148 | INSTALL(SCRIPT cmake/InstallCheck.cmake) |
|---|
| 149 | |
|---|
| 150 | IF(APPLE) |
|---|
| 151 | # Use the latest SDK and a minimum deployment target of Mountain Lion |
|---|
| 152 | SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.8") |
|---|
| 153 | set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") |
|---|
| 154 | SET(CMAKE_OSX_ARCHITECTURES "x86_64") |
|---|
| 155 | ENDIF() |
|---|
| 156 | |
|---|
| 157 | ########### Subfolders and Subscripts ########### |
|---|
| 158 | |
|---|
| 159 | # General build and compiler options and configurations |
|---|
| 160 | INCLUDE(CompilerConfig) |
|---|
| 161 | |
|---|
| 162 | # Library finding |
|---|
| 163 | INCLUDE(LibraryConfig) |
|---|
| 164 | |
|---|
| 165 | # Configure installation paths and options |
|---|
| 166 | INCLUDE(InstallConfig) |
|---|
| 167 | |
|---|
| 168 | # Configure data directory location and installation |
|---|
| 169 | ADD_SUBDIRECTORY(data) |
|---|
| 170 | |
|---|
| 171 | # Create the actual project |
|---|
| 172 | ADD_SUBDIRECTORY(src) |
|---|
| 173 | |
|---|
| 174 | # Create the test suites |
|---|
| 175 | ADD_SUBDIRECTORY(test) |
|---|
| 176 | |
|---|
| 177 | # Configure the binary output directory. Do this after src! |
|---|
| 178 | ADD_SUBDIRECTORY(bin) |
|---|
| 179 | |
|---|
| 180 | # System specific files (mostly for installation) |
|---|
| 181 | ADD_SUBDIRECTORY(contrib) |
|---|
| 182 | |
|---|
| 183 | # Last but not least: Try to make a doc target with Doxygen |
|---|
| 184 | ADD_SUBDIRECTORY(doc) |
|---|
| 185 | |
|---|
| 186 | IF(APPLE) |
|---|
| 187 | INCLUDE(CopyLibPhase) |
|---|
| 188 | ENDIF(APPLE) |
|---|
| 189 | |
|---|
| 190 | ########### CPack Packaging ########### |
|---|
| 191 | |
|---|
| 192 | # Currently only testing on Apple |
|---|
| 193 | # IF(APPLE) |
|---|
| 194 | # INCLUDE(BundleConfig) |
|---|
| 195 | # ENDIF(APPLE) |
|---|