[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 | |
---|
[2673] | 27 | ################# Misc Options ################## |
---|
[2582] | 28 | |
---|
[2612] | 29 | # Set binary output directories |
---|
| 30 | SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) |
---|
[2678] | 31 | SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) |
---|
[2612] | 32 | |
---|
[2673] | 33 | # Take care of some CMake 2.6.0 leftovers |
---|
| 34 | MARK_AS_ADVANCED(EXECUTABLE_OUTPUT_PATH LIBRARY_OUTPUT_PATH) |
---|
| 35 | |
---|
[2618] | 36 | # Sets where to find the external libraries like OgreMain.dll at runtime |
---|
| 37 | # On Unix you should not have to change this at all. |
---|
[2621] | 38 | IF(NOT ORXONOX_RUNTIME_LIBRARY_DIRECTORY) |
---|
| 39 | SET(ORXONOX_RUNTIME_LIBRARY_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) |
---|
[2624] | 40 | ENDIF() |
---|
[2618] | 41 | |
---|
[2612] | 42 | # Set Debug build to default when not having multi-config generator like msvc |
---|
[2618] | 43 | IF(NOT CMAKE_CONFIGURATION_TYPES) |
---|
| 44 | IF(NOT CMAKE_BUILD_TYPE) |
---|
| 45 | SET(CMAKE_BUILD_TYPE Debug CACHE STRING |
---|
| 46 | "Build types are: Debug, Release, MinSizeRel, RelWithDebInfo" FORCE) |
---|
[2624] | 47 | ENDIF() |
---|
[2618] | 48 | MARK_AS_ADVANCED(CLEAR CMAKE_BUILD_TYPE) |
---|
[2636] | 49 | |
---|
| 50 | MESSAGE(STATUS "*** Build type is ${CMAKE_BUILD_TYPE} ***") |
---|
[2624] | 51 | ELSE() |
---|
[2618] | 52 | IF(CMAKE_BUILD_TYPE) |
---|
| 53 | SET(CMAKE_BUILD_TYPE CACHE STRING FORCE) |
---|
[2624] | 54 | ENDIF() |
---|
[2618] | 55 | MARK_AS_ADVANCED(CMAKE_BUILD_TYPE) |
---|
[2624] | 56 | ENDIF() |
---|
[2612] | 57 | |
---|
[2673] | 58 | OPTION(EXTRA_COMPILER_WARNINGS "Enable some extra warnings (heavily pollutes the output)") |
---|
[2582] | 59 | |
---|
[2673] | 60 | |
---|
| 61 | ################# OGRE Plugins ################## |
---|
| 62 | |
---|
[2585] | 63 | # More plugins: Plugin_BSPSceneManager, Plugin_OctreeSceneManager |
---|
[2673] | 64 | SET(OGRE_PLUGINS_INT Plugin_ParticleFX) |
---|
[2592] | 65 | IF(WIN32) |
---|
| 66 | # CG program manager is probably DirectX related (not available under unix) |
---|
[2618] | 67 | LIST(APPEND OGRE_PLUGINS_INT Plugin_CgProgramManager) |
---|
[2592] | 68 | ENDIF(WIN32) |
---|
[2618] | 69 | SET(OGRE_PLUGINS ${OGRE_PLUGINS_INT} CACHE STRING |
---|
| 70 | "Specify which OGRE plugins to load. Existance check is performed.") |
---|
[2585] | 71 | |
---|
[2612] | 72 | # Check the plugins and determine the plugin folder |
---|
| 73 | # You can give a hint by setting the environment variable ENV{OGRE_PLUGIN_DIR} |
---|
| 74 | INCLUDE(CheckOGREPlugins) |
---|
[2618] | 75 | CHECK_OGRE_PLUGINS(${OGRE_PLUGINS}) |
---|
[2585] | 76 | |
---|
[2582] | 77 | |
---|
[2673] | 78 | ################ Compiler Config ################ |
---|
[2582] | 79 | |
---|
[2621] | 80 | INCLUDE(FlagUtilities) |
---|
[2582] | 81 | |
---|
[2621] | 82 | # Configure the compiler specific build options |
---|
| 83 | IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUC) |
---|
| 84 | INCLUDE(BuildConfigGCC) |
---|
| 85 | ELSEIF(MSVC) |
---|
| 86 | INCLUDE(BuildConfigMSVC) |
---|
[2624] | 87 | ELSE() |
---|
[2621] | 88 | MESSAGE(STATUS "Warning: Your compiler is not officially supported.") |
---|
[2624] | 89 | ENDIF() |
---|
[2621] | 90 | |
---|
[2673] | 91 | SET(USER_SCRIPT_BUILD_CONFIG "" CACHE FILEPATH |
---|
[2621] | 92 | "Specify a CMake script if you wish to write your own build config. |
---|
| 93 | See BuildConfigGCC.cmake or BuildConfigMSVC.cmake for examples.") |
---|
[2673] | 94 | IF(USER_SCRIPT_BUILD_CONFIG) |
---|
| 95 | IF(EXISTS ${CMAKE_MODULE_PATH}/${USER_SCRIPT_BUILD_CONFIG}.cmake) |
---|
| 96 | INCLUDE(${USER_SCRIPT_BUILD_CONFIG}) |
---|
| 97 | ELSEIF(EXISTS ${USER_SCRIPT_BUILD_CONFIG}) |
---|
| 98 | INCLUDE(${USER_SCRIPT_BUILD_CONFIG}) |
---|
| 99 | ELSEIF(EXISTS ${CMAKE_MODULE_PATH}/${USER_SCRIPT_BUILD_CONFIG}) |
---|
| 100 | INCLUDE(${CMAKE_MODULE_PATH}/${USER_SCRIPT_BUILD_CONFIG}) |
---|
[2624] | 101 | ENDIF() |
---|
[2673] | 102 | ENDIF(USER_SCRIPT_BUILD_CONFIG) |
---|
[2621] | 103 | |
---|
| 104 | |
---|
[2673] | 105 | ################# Test options ################## |
---|
[2612] | 106 | |
---|
[2673] | 107 | OPTION(TESTING_ENABLE "Enable build tests.") |
---|
| 108 | IF(TESTING_ENABLE) |
---|
[2612] | 109 | ENABLE_TESTING() |
---|
[2673] | 110 | ENDIF(TESTING_ENABLE) |
---|
[2612] | 111 | |
---|
[2678] | 112 | OPTION(NETWORK_TESTING_ENABLED "Build network testing tools: i.e. chatclient chatserver and alike.") |
---|
| 113 | OPTION(NETWORKTRAFFIC_TESTING_ENABLED "Build dummyserver4 and dummyclient4.") |
---|
[2673] | 114 | ############# Installation Settings ############# |
---|
[2612] | 115 | |
---|
[2657] | 116 | IF(UNIX) |
---|
| 117 | SET(ORXONOX_RUNTIME_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/bin/orxonox) |
---|
| 118 | SET(ORXONOX_LIBRARY_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/lib/orxonox) |
---|
| 119 | SET(ORXONOX_ARCHIVE_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/lib/orxonox/static) |
---|
| 120 | SET(ORXONOX_MEDIA_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/share/orxonox) |
---|
| 121 | SET(ORXONOX_DOC_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/share/doc/orxonox) |
---|
| 122 | # Not yet used |
---|
| 123 | SET(ORXONOX_LOG_INSTALL_PATH ~/.orxonox/log) |
---|
| 124 | SET(ORXONOX_CONFIG_INSTALL_PATH ~/.orxonox/config) |
---|
| 125 | ELSEIF(WIN32) |
---|
| 126 | SET(ORXONOX_RUNTIME_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/bin) |
---|
| 127 | SET(ORXONOX_LIBRARY_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/lib) |
---|
| 128 | SET(ORXONOX_ARCHIVE_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/lib/static) |
---|
| 129 | SET(ORXONOX_MEDIA_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/media) |
---|
| 130 | SET(ORXONOX_DOC_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/doc) |
---|
| 131 | # Not yet used |
---|
| 132 | SET(ORXONOX_LOG_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/log) |
---|
| 133 | SET(ORXONOX_CONFIG_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/config) |
---|
| 134 | ENDIF() |
---|
| 135 | |
---|
| 136 | |
---|
[2673] | 137 | ################## Unix rpath ################### |
---|
[2657] | 138 | |
---|
| 139 | # use, i.e. don't skip the full RPATH for the build tree |
---|
| 140 | SET(CMAKE_SKIP_BUILD_RPATH FALSE) |
---|
| 141 | |
---|
| 142 | # when building, don't use the install RPATH already |
---|
| 143 | # (but later on when installing) |
---|
| 144 | SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) |
---|
| 145 | |
---|
| 146 | # the RPATH to be used when installing |
---|
[2658] | 147 | SET(CMAKE_INSTALL_RPATH ${ORXONOX_LIBRARY_INSTALL_PATH}) |
---|
[2657] | 148 | |
---|
| 149 | # add the automatically determined parts of the RPATH |
---|
| 150 | # which point to directories outside the build tree to the install RPATH |
---|
| 151 | SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) |
---|
| 152 | |
---|
| 153 | |
---|
[2673] | 154 | ######## Static/Dynamic linking defines ######### |
---|
[2612] | 155 | |
---|
[2630] | 156 | # Disable Boost auto linking completely |
---|
| 157 | ADD_COMPILER_FLAGS("-DBOOST_ALL_NO_LIB") |
---|
| 158 | |
---|
[2621] | 159 | # If no defines are specified, these libs get linked statically |
---|
| 160 | ADD_COMPILER_FLAGS("-DBOOST_ALL_DYN_LINK" WIN32 LINK_BOOST_DYNAMIC) |
---|
| 161 | ADD_COMPILER_FLAGS("-DENET_DLL" WIN32 LINK_ENET_DYNAMIC) |
---|
| 162 | ADD_COMPILER_FLAGS("-DLUA_BUILD_AS_DLL" WIN32 LINK_LUA_DYNAMIC) |
---|
| 163 | ADD_COMPILER_FLAGS("-DZLIB_DLL" WIN32 LINK_ZLIB_DYNAMIC) |
---|
| 164 | |
---|
| 165 | # If no defines are specified, these libs get linked dynamically |
---|
| 166 | # You can change that optionally in the Cache. |
---|
| 167 | ADD_COMPILER_FLAGS("-DCEGUI_STATIC" WIN32 NOT LINK_CEGUI_DYNAMIC) |
---|
| 168 | ADD_COMPILER_FLAGS("-DOGRE_STATIC_LIB" WIN32 NOT LINK_OGRE_DYNAMIC) |
---|
| 169 | ADD_COMPILER_FLAGS("-DSTATIC_BUILD" WIN32 NOT LINK_TCL_DYNAMIC) |
---|