[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 | |
---|
[2612] | 27 | ################ Misc Options ################### |
---|
[2582] | 28 | |
---|
[2612] | 29 | # Set binary output directories |
---|
| 30 | SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) |
---|
| 31 | SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) |
---|
| 32 | SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) |
---|
| 33 | |
---|
[2618] | 34 | # Sets where to find the external libraries like OgreMain.dll at runtime |
---|
| 35 | # On Unix you should not have to change this at all. |
---|
[2621] | 36 | IF(NOT ORXONOX_RUNTIME_LIBRARY_DIRECTORY) |
---|
| 37 | SET(ORXONOX_RUNTIME_LIBRARY_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) |
---|
[2624] | 38 | ENDIF() |
---|
[2618] | 39 | |
---|
[2612] | 40 | # Set Debug build to default when not having multi-config generator like msvc |
---|
[2618] | 41 | IF(NOT CMAKE_CONFIGURATION_TYPES) |
---|
| 42 | IF(NOT CMAKE_BUILD_TYPE) |
---|
| 43 | SET(CMAKE_BUILD_TYPE Debug CACHE STRING |
---|
| 44 | "Build types are: Debug, Release, MinSizeRel, RelWithDebInfo" FORCE) |
---|
[2624] | 45 | ENDIF() |
---|
[2618] | 46 | MARK_AS_ADVANCED(CLEAR CMAKE_BUILD_TYPE) |
---|
[2636] | 47 | |
---|
| 48 | MESSAGE(STATUS "*** Build type is ${CMAKE_BUILD_TYPE} ***") |
---|
[2624] | 49 | ELSE() |
---|
[2618] | 50 | IF(CMAKE_BUILD_TYPE) |
---|
| 51 | SET(CMAKE_BUILD_TYPE CACHE STRING FORCE) |
---|
[2624] | 52 | ENDIF() |
---|
[2618] | 53 | MARK_AS_ADVANCED(CMAKE_BUILD_TYPE) |
---|
[2624] | 54 | ENDIF() |
---|
[2612] | 55 | |
---|
[2583] | 56 | OPTION(EXTRA_WARNINGS "Enable some extra warnings (heavily pollutes the output)") |
---|
[2582] | 57 | |
---|
[2621] | 58 | # Specify media directory |
---|
| 59 | GET_FILENAME_COMPONENT(_media_path "${CMAKE_SOURCE_DIR}/../media" ABSOLUTE) |
---|
| 60 | SET(ORXONOX_MEDIA_DIRECTORY ${_media_path} CACHE PATH |
---|
| 61 | "Location of the media directory.") |
---|
| 62 | IF(NOT EXISTS ${ORXONOX_MEDIA_DIRECTORY}) |
---|
| 63 | MESSAGE(STATUS "Warning: The media directory does not exist ${ORXONOX_MEDIA_DIRECTORY}") |
---|
[2624] | 64 | ENDIF() |
---|
[2621] | 65 | |
---|
[2585] | 66 | # More plugins: Plugin_BSPSceneManager, Plugin_OctreeSceneManager |
---|
| 67 | # Render systems may be optional, but at least one has to be found in FindOgre |
---|
[2618] | 68 | SET(OGRE_PLUGINS_INT RenderSystem_GL RenderSystem_Direct3D9 Plugin_ParticleFX) |
---|
[2592] | 69 | IF(WIN32) |
---|
| 70 | # CG program manager is probably DirectX related (not available under unix) |
---|
[2618] | 71 | LIST(APPEND OGRE_PLUGINS_INT Plugin_CgProgramManager) |
---|
[2592] | 72 | ENDIF(WIN32) |
---|
[2618] | 73 | SET(OGRE_PLUGINS ${OGRE_PLUGINS_INT} CACHE STRING |
---|
| 74 | "Specify which OGRE plugins to load. Existance check is performed.") |
---|
[2585] | 75 | |
---|
[2612] | 76 | # Check the plugins and determine the plugin folder |
---|
| 77 | # You can give a hint by setting the environment variable ENV{OGRE_PLUGIN_DIR} |
---|
| 78 | INCLUDE(CheckOGREPlugins) |
---|
[2618] | 79 | CHECK_OGRE_PLUGINS(${OGRE_PLUGINS}) |
---|
[2585] | 80 | |
---|
[2582] | 81 | |
---|
[2612] | 82 | ############## Compiler Config ################## |
---|
[2582] | 83 | |
---|
[2621] | 84 | INCLUDE(FlagUtilities) |
---|
[2582] | 85 | |
---|
[2621] | 86 | # Configure the compiler specific build options |
---|
| 87 | IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUC) |
---|
| 88 | INCLUDE(BuildConfigGCC) |
---|
| 89 | ELSEIF(MSVC) |
---|
| 90 | INCLUDE(BuildConfigMSVC) |
---|
[2624] | 91 | ELSE() |
---|
[2621] | 92 | MESSAGE(STATUS "Warning: Your compiler is not officially supported.") |
---|
[2624] | 93 | ENDIF() |
---|
[2621] | 94 | |
---|
| 95 | SET(BUILD_CONFIG_USER_SCRIPT "" CACHE FILEPATH |
---|
| 96 | "Specify a CMake script if you wish to write your own build config. |
---|
| 97 | See BuildConfigGCC.cmake or BuildConfigMSVC.cmake for examples.") |
---|
| 98 | IF(BUILD_CONFIG_USER_SCRIPT) |
---|
| 99 | IF(EXISTS ${CMAKE_MODULE_PATH}/${BUILD_CONFIG_USER_SCRIPT}.cmake) |
---|
| 100 | INCLUDE(${BUILD_CONFIG_USER_SCRIPT}) |
---|
| 101 | ELSEIF(EXISTS ${BUILD_CONFIG_USER_SCRIPT}) |
---|
| 102 | INCLUDE(${BUILD_CONFIG_USER_SCRIPT}) |
---|
| 103 | ELSEIF(EXISTS ${CMAKE_MODULE_PATH}/${BUILD_CONFIG_USER_SCRIPT}) |
---|
| 104 | INCLUDE(${CMAKE_MODULE_PATH}/${BUILD_CONFIG_USER_SCRIPT}) |
---|
[2624] | 105 | ENDIF() |
---|
[2621] | 106 | ENDIF(BUILD_CONFIG_USER_SCRIPT) |
---|
| 107 | |
---|
| 108 | |
---|
[2612] | 109 | ################ Test options ################### |
---|
| 110 | |
---|
| 111 | OPTION(ENABLE_TESTS "Enable build tests.") |
---|
| 112 | IF(ENABLE_TESTS) |
---|
| 113 | ENABLE_TESTING() |
---|
| 114 | ENDIF(ENABLE_TESTS) |
---|
| 115 | |
---|
| 116 | OPTION(NETWORK_TESTING_ENABLED "Build network testing tools: i.e. chatclient chatserver and alike.") |
---|
| 117 | OPTION(NETWORKTRAFFIC_TESTING_ENABLED "Build dummyserver4 and dummyclient4.") |
---|
| 118 | |
---|
| 119 | |
---|
[2621] | 120 | ####### Static/Dynamic linking defines ########## |
---|
[2612] | 121 | |
---|
[2630] | 122 | # Disable Boost auto linking completely |
---|
| 123 | ADD_COMPILER_FLAGS("-DBOOST_ALL_NO_LIB") |
---|
| 124 | |
---|
[2621] | 125 | # If no defines are specified, these libs get linked statically |
---|
| 126 | ADD_COMPILER_FLAGS("-DBOOST_ALL_DYN_LINK" WIN32 LINK_BOOST_DYNAMIC) |
---|
| 127 | ADD_COMPILER_FLAGS("-DENET_DLL" WIN32 LINK_ENET_DYNAMIC) |
---|
| 128 | ADD_COMPILER_FLAGS("-DLUA_BUILD_AS_DLL" WIN32 LINK_LUA_DYNAMIC) |
---|
| 129 | ADD_COMPILER_FLAGS("-DZLIB_DLL" WIN32 LINK_ZLIB_DYNAMIC) |
---|
| 130 | |
---|
| 131 | # If no defines are specified, these libs get linked dynamically |
---|
| 132 | # You can change that optionally in the Cache. |
---|
| 133 | ADD_COMPILER_FLAGS("-DCEGUI_STATIC" WIN32 NOT LINK_CEGUI_DYNAMIC) |
---|
| 134 | ADD_COMPILER_FLAGS("-DOGRE_STATIC_LIB" WIN32 NOT LINK_OGRE_DYNAMIC) |
---|
| 135 | ADD_COMPILER_FLAGS("-DSTATIC_BUILD" WIN32 NOT LINK_TCL_DYNAMIC) |
---|