[2626] | 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 the external libraries. Whenever possible, the find scripts |
---|
| 24 | # from the CMake module path are used, but that required some adjustments |
---|
| 25 | # for certain libraries (Boost, OpenAL, TCL) |
---|
| 26 | # |
---|
[6417] | 27 | |
---|
[2618] | 28 | INCLUDE(CompareVersionStrings) |
---|
| 29 | INCLUDE(FindPackageHandleStandardArgs) |
---|
| 30 | |
---|
[2696] | 31 | # Prevent CMake from finding libraries in the installation folder on Windows. |
---|
[2645] | 32 | # There might already be an installation from another compiler |
---|
[5695] | 33 | IF(WIN32) |
---|
[2696] | 34 | LIST(REMOVE_ITEM CMAKE_SYSTEM_PREFIX_PATH "${CMAKE_INSTALL_PREFIX}") |
---|
| 35 | LIST(REMOVE_ITEM CMAKE_SYSTEM_LIBRARY_PATH "${CMAKE_INSTALL_PREFIX}/bin") |
---|
| 36 | ENDIF() |
---|
[2645] | 37 | |
---|
[2631] | 38 | ############## Platform Scripts ################# |
---|
[2618] | 39 | |
---|
[2631] | 40 | # On Windows using a package causes way less problems |
---|
| 41 | SET(_option_msg "Set this to true to use precompiled dependecy archives") |
---|
| 42 | IF(WIN32) |
---|
[2673] | 43 | OPTION(DEPENDENCY_PACKAGE_ENABLE "${_option_msg}" ON) |
---|
[2631] | 44 | ELSE(WIN32) |
---|
[2673] | 45 | OPTION(DEPENDENCY_PACKAGE_ENABLE "${_option_msg}" FALSE) |
---|
[2631] | 46 | ENDIF(WIN32) |
---|
[2618] | 47 | |
---|
| 48 | # Scripts for specific library and CMake config |
---|
| 49 | INCLUDE(LibraryConfigTardis) |
---|
[5781] | 50 | INCLUDE(LibraryConfigApple) |
---|
[1505] | 51 | |
---|
[2673] | 52 | IF(DEPENDENCY_PACKAGE_ENABLE) |
---|
| 53 | GET_FILENAME_COMPONENT(_dep_dir_1 ${CMAKE_SOURCE_DIR}/../dependencies ABSOLUTE) |
---|
[7225] | 54 | GET_FILENAME_COMPONENT(_dep_dir_2 ${CMAKE_SOURCE_DIR}/../lib_dist ABSOLUTE) |
---|
| 55 | IF(MINGW) |
---|
| 56 | SET(_compiler_prefix mingw) |
---|
| 57 | ELSEIF(MSVC80) |
---|
| 58 | SET(_compiler_prefix msvc8) |
---|
| 59 | ELSEIF(MSVC90) |
---|
| 60 | SET(_compiler_prefix msvc9) |
---|
| 61 | ENDIF() |
---|
[2673] | 62 | FIND_PATH(DEPENDENCY_PACKAGE_DIR |
---|
[7225] | 63 | NAMES version.txt |
---|
[2651] | 64 | PATHS |
---|
| 65 | ${CMAKE_SOURCE_DIR}/dependencies |
---|
[2673] | 66 | ${_dep_dir_1} |
---|
| 67 | ${_dep_dir_2} |
---|
[7225] | 68 | PATH_SUFFIXES ${_compiler_prefix} ${_compiler_prefix}/dependencies |
---|
[2711] | 69 | NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH |
---|
[2651] | 70 | ) |
---|
[2673] | 71 | IF(NOT DEPENDENCY_PACKAGE_DIR) |
---|
[2631] | 72 | MESSAGE(STATUS "Warning: Could not find dependency directory." |
---|
| 73 | "Disable LIBRARY_USE_PACKAGE if you have none intalled.") |
---|
[2651] | 74 | ELSE() |
---|
[2674] | 75 | INCLUDE(PackageConfigMinGW) |
---|
| 76 | INCLUDE(PackageConfigMSVC) |
---|
[3196] | 77 | INCLUDE(PackageConfig) # For both msvc and mingw |
---|
| 78 | ENDIF() |
---|
[2673] | 79 | ENDIF(DEPENDENCY_PACKAGE_ENABLE) |
---|
[2631] | 80 | |
---|
[5781] | 81 | # User script |
---|
| 82 | SET(LIBRARY_CONFIG_USER_SCRIPT "" CACHE FILEPATH |
---|
| 83 | "Specify a CMake script if you wish to write your own library path config. |
---|
| 84 | See LibraryConfigTardis.cmake for an example.") |
---|
| 85 | IF(LIBRARY_CONFIG_USER_SCRIPT) |
---|
| 86 | IF(EXISTS ${CMAKE_MODULE_PATH}/${LIBRARY_CONFIG_USER_SCRIPT}) |
---|
| 87 | INCLUDE(${CMAKE_MODULE_PATH}/${LIBRARY_CONFIG_USER_SCRIPT}) |
---|
| 88 | ENDIF() |
---|
| 89 | ENDIF(LIBRARY_CONFIG_USER_SCRIPT) |
---|
| 90 | |
---|
| 91 | |
---|
[2616] | 92 | ############### Library finding ################# |
---|
| 93 | # Performs the search and sets the variables # |
---|
[2579] | 94 | |
---|
[5695] | 95 | FIND_PACKAGE(OGRE 1.4 REQUIRED) |
---|
[5781] | 96 | FIND_PACKAGE(ENet 1.1 REQUIRED) |
---|
| 97 | FIND_PACKAGE(Ogg REQUIRED) |
---|
| 98 | FIND_PACKAGE(Vorbis REQUIRED) |
---|
| 99 | FIND_PACKAGE(ALUT REQUIRED) |
---|
| 100 | FIND_PACKAGE(ZLIB REQUIRED) |
---|
[7224] | 101 | IF(POCO_REQUIRED) |
---|
| 102 | FIND_PACKAGE(POCO REQUIRED) |
---|
| 103 | ENDIF() |
---|
[5781] | 104 | IF(WIN32) |
---|
| 105 | FIND_PACKAGE(DirectX REQUIRED) |
---|
[7224] | 106 | ENDIF() |
---|
[5781] | 107 | |
---|
| 108 | ##### CEGUI ##### |
---|
| 109 | # We make use of the CEGUI script module called CEGUILua. |
---|
| 110 | # However there is a small issue with that: We use Tolua, a C++ binding |
---|
| 111 | # generator ourselves. And we also have to use our bindings in the same |
---|
| 112 | # lua state is CEGUILua's. Unfortunately this implies that both lua runtime |
---|
| 113 | # version are equal or else you get segmentation faults. |
---|
| 114 | # In order to match the Lua versions we decided to ship CEGUILua in our |
---|
| 115 | # repository, mainly because there is no way to determine which version of |
---|
| 116 | # Lua CEGUILua was linked against (you'd have to specify yourself) and secondly |
---|
| 117 | # because we can then choose the Lua version. Future plans might involve only |
---|
| 118 | # accepting Lua 5.1. |
---|
| 119 | |
---|
| 120 | # Insert all internally supported CEGUILua versions here |
---|
| 121 | SET(CEGUILUA_INTERNAL_SUPPORT 0.5.0 0.6.0 0.6.1 0.6.2) |
---|
| 122 | OPTION(CEGUILUA_USE_EXTERNAL_LIBRARY "Force the use of external CEGUILua library" OFF) |
---|
| 123 | FIND_PACKAGE(CEGUI 0.5 REQUIRED) |
---|
| 124 | |
---|
[2615] | 125 | ##### Lua ##### |
---|
| 126 | IF(CEGUILUA_USE_EXTERNAL_LIBRARY) |
---|
| 127 | COMPARE_VERSION_STRINGS(${CEGUI_VERSION} "0.6" _version_comparison) |
---|
| 128 | IF(version_comparison LESS 0) |
---|
| 129 | SET(LUA_VERSION_REQUEST 5.0) |
---|
[2624] | 130 | ELSE() |
---|
[2615] | 131 | SET(LUA_VERSION_REQUEST 5.1) |
---|
[2624] | 132 | ENDIF() |
---|
| 133 | ELSE() |
---|
[2615] | 134 | SET(LUA_VERSION_REQUEST 5) |
---|
[2624] | 135 | ENDIF() |
---|
[2615] | 136 | FIND_PACKAGE(Lua ${LUA_VERSION_REQUEST} EXACT REQUIRED) |
---|
[2510] | 137 | |
---|
[5781] | 138 | ##### OpenAL ##### |
---|
| 139 | FIND_PACKAGE(OpenAL REQUIRED) |
---|
| 140 | # Also use parent include dir (without AL/) for ALUT |
---|
| 141 | IF(OPENAL_INCLUDE_DIR MATCHES "/AL$") |
---|
| 142 | GET_FILENAME_COMPONENT(ALT_OPENAL_INCLUDE_DIR ${OPENAL_INCLUDE_DIR} PATH) |
---|
| 143 | ENDIF() |
---|
| 144 | SET(OPENAL_INCLUDE_DIRS ${OPENAL_INCLUDE_DIR} ${ALT_OPENAL_INCLUDE_DIR}) |
---|
| 145 | # Notfiy user |
---|
| 146 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenAL DEFAULT_MSG OPENAL_LIBRARY OPENAL_INCLUDE_DIR) |
---|
| 147 | # Hide variables created by the script |
---|
| 148 | MARK_AS_ADVANCED(OPENAL_INCLUDE_DIR OPENAL_LIBRARY) |
---|
| 149 | |
---|
| 150 | ##### Tcl ##### |
---|
| 151 | # We only require Tcl, so avoid confusing user about other Tcl stuff by |
---|
| 152 | # applying a little workaround |
---|
| 153 | SET(Tclsh_FIND_QUIETLY TRUE) |
---|
| 154 | FIND_PACKAGE(TCL QUIET) |
---|
| 155 | # Display messages separately |
---|
| 156 | SET(TCL_FIND_QUIETLY FALSE) |
---|
| 157 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(TCL DEFAULT_MSG TCL_LIBRARY TCL_INCLUDE_PATH) |
---|
| 158 | |
---|
[2616] | 159 | ##### Boost ##### |
---|
| 160 | # Expand the next statement if newer boost versions than 1.36.1 are released |
---|
[5794] | 161 | SET(Boost_ADDITIONAL_VERSIONS 1.37 1.37.0 1.38 1.38.0 1.39 1.39.0 1.40 1.40.0) |
---|
[6461] | 162 | IF( NOT TARDIS ) |
---|
| 163 | FIND_PACKAGE(Boost 1.35 REQUIRED thread filesystem system date_time) |
---|
| 164 | ENDIF() |
---|
[2673] | 165 | # No auto linking, so this option is useless anyway |
---|
| 166 | MARK_AS_ADVANCED(Boost_LIB_DIAGNOSTIC_DEFINITIONS) |
---|
[2618] | 167 | |
---|
[3304] | 168 | |
---|
[2618] | 169 | ####### Static/Dynamic linking options ########## |
---|
| 170 | |
---|
| 171 | # On Windows dynamically linked libraries need some special treatment |
---|
| 172 | # You may want to edit these settings if you provide your own libraries |
---|
| 173 | # Note: Default option in the libraries vary, but our default option is dynamic |
---|
| 174 | IF(WIN32) |
---|
| 175 | OPTION(LINK_BOOST_DYNAMIC "Link Boost dynamically on Windows" TRUE) |
---|
[5781] | 176 | OPTION(LINK_CEGUI_DYNAMIC "Link CEGUI dynamicylly on Windows" TRUE) |
---|
| 177 | OPTION(LINK_ENET_DYNAMIC "Link ENet dynamically on Windows" TRUE) |
---|
[2618] | 178 | OPTION(LINK_OGRE_DYNAMIC "Link OGRE dynamically on Windows" TRUE) |
---|
[5781] | 179 | OPTION(LINK_TCL_DYNAMIC "Link TCL dynamically on Windows" TRUE) |
---|
| 180 | OPTION(LINK_ZLIB_DYNAMIC "Link ZLib dynamically on Windows" TRUE) |
---|
[2618] | 181 | COMPARE_VERSION_STRINGS("${LUA_VERSION}" "5.1" _version_comparison) |
---|
| 182 | IF(_version_comparison LESS 0) |
---|
| 183 | OPTION(LINK_LUA_DYNAMIC "Link Lua dynamically on Windows" FALSE) |
---|
| 184 | ELSE(_version_comparison LESS 0) |
---|
| 185 | OPTION(LINK_LUA_DYNAMIC "Link Lua dynamically on Windows" TRUE) |
---|
| 186 | ENDIF(_version_comparison LESS 0) |
---|
[2925] | 187 | |
---|
| 188 | IF(DEPENDENCY_PACKAGE_ENABLE) |
---|
| 189 | MARK_AS_ADVANCED( |
---|
[5781] | 190 | LINK_BOOST_DYNAMIC LINK_CEGUI_DYNAMIC LINK_ENET_DYNAMIC |
---|
| 191 | LINK_OGRE_DYNAMIC LINK_TCL_DYNAMIC LINK_ZLIB_DYNAMIC |
---|
[2925] | 192 | LINK_LUA_DYNAMIC |
---|
| 193 | ) |
---|
| 194 | ENDIF() |
---|
[2618] | 195 | ENDIF(WIN32) |
---|
[5781] | 196 | |
---|
| 197 | |
---|
| 198 | ################# OGRE Plugins ################## |
---|
| 199 | |
---|
| 200 | # More plugins: Plugin_BSPSceneManager, Plugin_OctreeSceneManager |
---|
[7163] | 201 | SET(OGRE_PLUGINS_INT "Plugin_ParticleFX;Plugin_BSPSceneManager") |
---|
[5781] | 202 | IF(WIN32) |
---|
| 203 | # CG program manager is probably DirectX related (not available under unix) |
---|
| 204 | LIST(APPEND OGRE_PLUGINS_INT Plugin_CgProgramManager) |
---|
| 205 | ENDIF(WIN32) |
---|
| 206 | SET(OGRE_PLUGINS ${OGRE_PLUGINS_INT} CACHE STRING |
---|
| 207 | "Specify which OGRE plugins to load. Existance check is performed.") |
---|
| 208 | |
---|
| 209 | # Check the plugins and determine the plugin folder |
---|
| 210 | # You can give a hint by setting the environment variable ENV{OGRE_PLUGIN_DIR} |
---|
| 211 | INCLUDE(CheckOGREPlugins) |
---|
| 212 | CHECK_OGRE_PLUGINS(${OGRE_PLUGINS}) |
---|
| 213 | |
---|