[2579] | 1 | # |
---|
[2626] | 2 | # ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | # > www.orxonox.net < |
---|
[2579] | 4 | # |
---|
[2626] | 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. |
---|
[2579] | 9 | # |
---|
[2626] | 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. |
---|
[2579] | 14 | # |
---|
[2626] | 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. |
---|
[2579] | 18 | # |
---|
| 19 | # |
---|
[2626] | 20 | # Author: |
---|
| 21 | # Reto Grieder |
---|
| 22 | # Description: |
---|
| 23 | # Configures the compilers and sets build options. |
---|
| 24 | # This also includes handling the OGRE plugins and the media directory. |
---|
[2579] | 25 | # |
---|
| 26 | |
---|
[3330] | 27 | ################# Misc Settings ################# |
---|
[2582] | 28 | |
---|
[2702] | 29 | # Standard path suffixes, might not hold everywhere though |
---|
| 30 | SET(DEFAULT_RUNTIME_PATH bin) |
---|
| 31 | SET(DEFAULT_LIBRARY_PATH lib) |
---|
| 32 | SET(DEFAULT_ARCHIVE_PATH lib/static) |
---|
[5625] | 33 | SET(DEFAULT_PLUGIN_PATH lib/plugins) |
---|
[2702] | 34 | SET(DEFAULT_DOC_PATH doc) |
---|
| 35 | SET(DEFAULT_MEDIA_PATH media) |
---|
| 36 | SET(DEFAULT_CONFIG_PATH config) |
---|
| 37 | SET(DEFAULT_LOG_PATH log) |
---|
[2612] | 38 | |
---|
[2702] | 39 | # Set output directories |
---|
| 40 | SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_RUNTIME_PATH}) |
---|
| 41 | SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_LIBRARY_PATH}) |
---|
| 42 | SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_ARCHIVE_PATH}) |
---|
[5625] | 43 | SET(CMAKE_PLUGIN_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_PLUGIN_PATH}) |
---|
[2702] | 44 | # Do not set doc and media, rather check in the two subdirectories |
---|
| 45 | # whether they concur with the DEFAULT_..._PATH |
---|
| 46 | SET(CMAKE_CONFIG_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_CONFIG_PATH}) |
---|
| 47 | SET(CMAKE_LOG_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_LOG_PATH}) |
---|
| 48 | |
---|
[2673] | 49 | # Take care of some CMake 2.6.0 leftovers |
---|
| 50 | MARK_AS_ADVANCED(EXECUTABLE_OUTPUT_PATH LIBRARY_OUTPUT_PATH) |
---|
| 51 | |
---|
[2618] | 52 | # Sets where to find the external libraries like OgreMain.dll at runtime |
---|
| 53 | # On Unix you should not have to change this at all. |
---|
[2621] | 54 | IF(NOT ORXONOX_RUNTIME_LIBRARY_DIRECTORY) |
---|
| 55 | SET(ORXONOX_RUNTIME_LIBRARY_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) |
---|
[2624] | 56 | ENDIF() |
---|
[2618] | 57 | |
---|
[2612] | 58 | # Set Debug build to default when not having multi-config generator like msvc |
---|
[2618] | 59 | IF(NOT CMAKE_CONFIGURATION_TYPES) |
---|
| 60 | IF(NOT CMAKE_BUILD_TYPE) |
---|
| 61 | SET(CMAKE_BUILD_TYPE Debug CACHE STRING |
---|
| 62 | "Build types are: Debug, Release, MinSizeRel, RelWithDebInfo" FORCE) |
---|
[2624] | 63 | ENDIF() |
---|
[2618] | 64 | MARK_AS_ADVANCED(CLEAR CMAKE_BUILD_TYPE) |
---|
[2636] | 65 | |
---|
| 66 | MESSAGE(STATUS "*** Build type is ${CMAKE_BUILD_TYPE} ***") |
---|
[2624] | 67 | ELSE() |
---|
[2618] | 68 | IF(CMAKE_BUILD_TYPE) |
---|
| 69 | SET(CMAKE_BUILD_TYPE CACHE STRING FORCE) |
---|
[2624] | 70 | ENDIF() |
---|
[2618] | 71 | MARK_AS_ADVANCED(CMAKE_BUILD_TYPE) |
---|
[2624] | 72 | ENDIF() |
---|
[2612] | 73 | |
---|
[2582] | 74 | |
---|
[2673] | 75 | ################# OGRE Plugins ################## |
---|
| 76 | |
---|
[2585] | 77 | # More plugins: Plugin_BSPSceneManager, Plugin_OctreeSceneManager |
---|
[2673] | 78 | SET(OGRE_PLUGINS_INT Plugin_ParticleFX) |
---|
[2592] | 79 | IF(WIN32) |
---|
| 80 | # CG program manager is probably DirectX related (not available under unix) |
---|
[2618] | 81 | LIST(APPEND OGRE_PLUGINS_INT Plugin_CgProgramManager) |
---|
[2592] | 82 | ENDIF(WIN32) |
---|
[2618] | 83 | SET(OGRE_PLUGINS ${OGRE_PLUGINS_INT} CACHE STRING |
---|
| 84 | "Specify which OGRE plugins to load. Existance check is performed.") |
---|
[2585] | 85 | |
---|
[2612] | 86 | # Check the plugins and determine the plugin folder |
---|
| 87 | # You can give a hint by setting the environment variable ENV{OGRE_PLUGIN_DIR} |
---|
| 88 | INCLUDE(CheckOGREPlugins) |
---|
[2618] | 89 | CHECK_OGRE_PLUGINS(${OGRE_PLUGINS}) |
---|
[2585] | 90 | |
---|
[2582] | 91 | |
---|
[2673] | 92 | ################ Compiler Config ################ |
---|
[2582] | 93 | |
---|
[2896] | 94 | OPTION(EXTRA_COMPILER_WARNINGS "Enable some extra warnings (heavily pollutes the output)" FALSE) |
---|
[2719] | 95 | |
---|
[2621] | 96 | INCLUDE(FlagUtilities) |
---|
[2582] | 97 | |
---|
[2621] | 98 | # Configure the compiler specific build options |
---|
| 99 | IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUC) |
---|
| 100 | INCLUDE(BuildConfigGCC) |
---|
| 101 | ELSEIF(MSVC) |
---|
| 102 | INCLUDE(BuildConfigMSVC) |
---|
[2624] | 103 | ELSE() |
---|
[2621] | 104 | MESSAGE(STATUS "Warning: Your compiler is not officially supported.") |
---|
[2624] | 105 | ENDIF() |
---|
[2621] | 106 | |
---|
[2673] | 107 | SET(USER_SCRIPT_BUILD_CONFIG "" CACHE FILEPATH |
---|
[2621] | 108 | "Specify a CMake script if you wish to write your own build config. |
---|
| 109 | See BuildConfigGCC.cmake or BuildConfigMSVC.cmake for examples.") |
---|
[2673] | 110 | IF(USER_SCRIPT_BUILD_CONFIG) |
---|
| 111 | IF(EXISTS ${CMAKE_MODULE_PATH}/${USER_SCRIPT_BUILD_CONFIG}.cmake) |
---|
| 112 | INCLUDE(${USER_SCRIPT_BUILD_CONFIG}) |
---|
| 113 | ELSEIF(EXISTS ${USER_SCRIPT_BUILD_CONFIG}) |
---|
| 114 | INCLUDE(${USER_SCRIPT_BUILD_CONFIG}) |
---|
| 115 | ELSEIF(EXISTS ${CMAKE_MODULE_PATH}/${USER_SCRIPT_BUILD_CONFIG}) |
---|
| 116 | INCLUDE(${CMAKE_MODULE_PATH}/${USER_SCRIPT_BUILD_CONFIG}) |
---|
[2624] | 117 | ENDIF() |
---|
[2673] | 118 | ENDIF(USER_SCRIPT_BUILD_CONFIG) |
---|
[2621] | 119 | |
---|
| 120 | |
---|
[2673] | 121 | ############# Installation Settings ############# |
---|
[2612] | 122 | |
---|
[2702] | 123 | SET(_info_text "Puts all installed files in subfolders of the install prefix path. That root folder can then be moved, copied and renamed as you wish. The executable will not write to folders like ~/.orxonox or \"Applictation Data\"") |
---|
[2657] | 124 | IF(UNIX) |
---|
[2702] | 125 | OPTION(INSTALL_COPYABLE "${_info_text}" FALSE) |
---|
| 126 | ELSE() |
---|
| 127 | OPTION(INSTALL_COPYABLE "${_info_text}" TRUE) |
---|
| 128 | ENDIF() |
---|
| 129 | |
---|
| 130 | IF(INSTALL_COPYABLE) |
---|
| 131 | # Note the relative paths. They will be resolved at runtime. |
---|
| 132 | # For CMake operations CMAKE_INSTALL_PREFIX is always appended. |
---|
| 133 | SET(ORXONOX_RUNTIME_INSTALL_PATH ${DEFAULT_RUNTIME_PATH}) |
---|
[2723] | 134 | SET(ORXONOX_LIBRARY_INSTALL_PATH ${DEFAULT_LIBRARY_PATH}) |
---|
[2702] | 135 | SET(ORXONOX_ARCHIVE_INSTALL_PATH ${DEFAULT_ARCHIVE_PATH}) |
---|
[5625] | 136 | SET(ORXONOX_PLUGIN_INSTALL_PATH ${DEFAULT_PLUGIN_PATH}) |
---|
[2702] | 137 | SET(ORXONOX_DOC_INSTALL_PATH ${DEFAULT_DOC_PATH}) |
---|
| 138 | SET(ORXONOX_MEDIA_INSTALL_PATH ${DEFAULT_MEDIA_PATH}) |
---|
| 139 | SET(ORXONOX_CONFIG_INSTALL_PATH ${DEFAULT_CONFIG_PATH}) |
---|
| 140 | SET(ORXONOX_LOG_INSTALL_PATH ${DEFAULT_LOG_PATH}) |
---|
| 141 | |
---|
| 142 | ELSEIF(UNIX) # Apple too? |
---|
| 143 | # Using absolute paths |
---|
[2689] | 144 | SET(ORXONOX_RUNTIME_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/bin) |
---|
[2657] | 145 | SET(ORXONOX_LIBRARY_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/lib/orxonox) |
---|
| 146 | SET(ORXONOX_ARCHIVE_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/lib/orxonox/static) |
---|
[5625] | 147 | SET(ORXONOX_PLUGIN_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/lib/orxonox/plugins) |
---|
[2702] | 148 | SET(ORXONOX_DOC_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/share/doc/orxonox) |
---|
[2657] | 149 | SET(ORXONOX_MEDIA_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/share/orxonox) |
---|
[2702] | 150 | # These two paths are user and therefore runtime dependent --> only set relatively |
---|
| 151 | SET(ORXONOX_CONFIG_INSTALL_PATH ${DEFAULT_CONFIG_PATH}) |
---|
| 152 | SET(ORXONOX_LOG_INSTALL_PATH ${DEFAULT_LOG_PATH}) |
---|
[2687] | 153 | |
---|
[2657] | 154 | ELSEIF(WIN32) |
---|
[2702] | 155 | SET(ORXONOX_RUNTIME_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/${DEFAULT_RUNTIME_PATH}) |
---|
| 156 | SET(ORXONOX_LIBRARY_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/${DEFAULT_LIBRARY_PATH}) |
---|
| 157 | SET(ORXONOX_ARCHIVE_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/${DEFAULT_ARCHIVE_PATH}) |
---|
[5625] | 158 | SET(ORXONOX_PLUGIN_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/${DEFAULT_PLUGIN_PATH}) |
---|
[2702] | 159 | SET(ORXONOX_DOC_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/${DEFAULT_DOC_PATH}) |
---|
| 160 | SET(ORXONOX_MEDIA_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/${DEFAULT_MEDIA_PATH}) |
---|
| 161 | # Leave empty because it is user and therefore runtime dependent |
---|
| 162 | SET(ORXONOX_CONFIG_INSTALL_PATH ${DEFAULT_CONFIG_PATH}) |
---|
| 163 | SET(ORXONOX_LOG_INSTALL_PATH ${DEFAULT_LOG_PATH}) |
---|
[2657] | 164 | ENDIF() |
---|
| 165 | |
---|
| 166 | |
---|
[2673] | 167 | ################## Unix rpath ################### |
---|
[2657] | 168 | |
---|
| 169 | # use, i.e. don't skip the full RPATH for the build tree |
---|
| 170 | SET(CMAKE_SKIP_BUILD_RPATH FALSE) |
---|
| 171 | |
---|
| 172 | # when building, don't use the install RPATH already |
---|
| 173 | # (but later on when installing) |
---|
[5626] | 174 | SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) |
---|
[2657] | 175 | |
---|
| 176 | # the RPATH to be used when installing |
---|
[2658] | 177 | SET(CMAKE_INSTALL_RPATH ${ORXONOX_LIBRARY_INSTALL_PATH}) |
---|
[2657] | 178 | |
---|
| 179 | # add the automatically determined parts of the RPATH |
---|
| 180 | # which point to directories outside the build tree to the install RPATH |
---|
| 181 | SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) |
---|
| 182 | |
---|
| 183 | |
---|
[3330] | 184 | ################ Various options ################ |
---|
[2612] | 185 | |
---|
[3330] | 186 | # Enable expensive optimisations: Use this for a binary release build |
---|
| 187 | OPTION(ORXONOX_RELEASE "Enable when building restributable releases" FALSE) |
---|
| 188 | |
---|
| 189 | # Use WinMain() or main()? |
---|
| 190 | IF(WIN32) |
---|
| 191 | OPTION(ORXONOX_USE_WINMAIN "Use WinMain (doesn't show console) or main" FALSE) |
---|
| 192 | ENDIF() |
---|
| 193 | |
---|
| 194 | # Global switch to disable Precompiled Header Files |
---|
| 195 | IF(PCH_COMPILER_SUPPORT) |
---|
| 196 | OPTION(PCH_ENABLE "Global PCH switch" TRUE) |
---|
| 197 | ENDIF() |
---|
| 198 | |
---|
| 199 | |
---|
| 200 | ############ Static/Dynamic linking ############# |
---|
| 201 | |
---|
| 202 | # Default linking is SHARED |
---|
| 203 | SET(ORXONOX_DEFAULT_LINK SHARED) |
---|
| 204 | |
---|
[2630] | 205 | # Disable Boost auto linking completely |
---|
| 206 | ADD_COMPILER_FLAGS("-DBOOST_ALL_NO_LIB") |
---|
| 207 | |
---|
[2621] | 208 | # If no defines are specified, these libs get linked statically |
---|
| 209 | ADD_COMPILER_FLAGS("-DBOOST_ALL_DYN_LINK" WIN32 LINK_BOOST_DYNAMIC) |
---|
| 210 | ADD_COMPILER_FLAGS("-DENET_DLL" WIN32 LINK_ENET_DYNAMIC) |
---|
| 211 | ADD_COMPILER_FLAGS("-DLUA_BUILD_AS_DLL" WIN32 LINK_LUA_DYNAMIC) |
---|
| 212 | ADD_COMPILER_FLAGS("-DZLIB_DLL" WIN32 LINK_ZLIB_DYNAMIC) |
---|
| 213 | |
---|
| 214 | # If no defines are specified, these libs get linked dynamically |
---|
| 215 | # You can change that optionally in the Cache. |
---|
| 216 | ADD_COMPILER_FLAGS("-DCEGUI_STATIC" WIN32 NOT LINK_CEGUI_DYNAMIC) |
---|
| 217 | ADD_COMPILER_FLAGS("-DOGRE_STATIC_LIB" WIN32 NOT LINK_OGRE_DYNAMIC) |
---|
| 218 | ADD_COMPILER_FLAGS("-DSTATIC_BUILD" WIN32 NOT LINK_TCL_DYNAMIC) |
---|