[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 | # |
---|
| 27 | |
---|
[2618] | 28 | INCLUDE(CompareVersionStrings) |
---|
| 29 | INCLUDE(FindPackageHandleStandardArgs) |
---|
| 30 | |
---|
[2645] | 31 | # Prevent CMake from finding libraries in the installation folder on windows |
---|
| 32 | # There might already be an installation from another compiler |
---|
| 33 | LIST(REMOVE_ITEM CMAKE_SYSTEM_PREFIX_PATH "${CMAKE_INSTALL_PREFIX}") |
---|
[2651] | 34 | LIST(REMOVE_ITEM CMAKE_SYSTEM_LIBRARY_PATH "${CMAKE_INSTALL_PREFIX}/bin") |
---|
[2645] | 35 | |
---|
[2631] | 36 | ############## Platform Scripts ################# |
---|
[2618] | 37 | |
---|
[2631] | 38 | # On Windows using a package causes way less problems |
---|
| 39 | SET(_option_msg "Set this to true to use precompiled dependecy archives") |
---|
| 40 | IF(WIN32) |
---|
[2673] | 41 | OPTION(DEPENDENCY_PACKAGE_ENABLE "${_option_msg}" ON) |
---|
[2631] | 42 | ELSE(WIN32) |
---|
[2673] | 43 | OPTION(DEPENDENCY_PACKAGE_ENABLE "${_option_msg}" FALSE) |
---|
[2631] | 44 | ENDIF(WIN32) |
---|
[2618] | 45 | |
---|
| 46 | # Scripts for specific library and CMake config |
---|
| 47 | INCLUDE(LibraryConfigTardis) |
---|
| 48 | INCLUDE(LibraryConfigApple) |
---|
[1505] | 49 | |
---|
[2673] | 50 | IF(DEPENDENCY_PACKAGE_ENABLE) |
---|
| 51 | GET_FILENAME_COMPONENT(_dep_dir_1 ${CMAKE_SOURCE_DIR}/../dependencies ABSOLUTE) |
---|
| 52 | GET_FILENAME_COMPONENT(_dep_dir_2 ${CMAKE_SOURCE_DIR}/../lib_dist/dependencies ABSOLUTE) |
---|
| 53 | FIND_PATH(DEPENDENCY_PACKAGE_DIR |
---|
[2675] | 54 | NAMES include |
---|
[2651] | 55 | PATHS |
---|
| 56 | ${CMAKE_SOURCE_DIR}/dependencies |
---|
[2673] | 57 | ${_dep_dir_1} |
---|
| 58 | ${_dep_dir_2} |
---|
[2651] | 59 | ) |
---|
[2673] | 60 | IF(NOT DEPENDENCY_PACKAGE_DIR) |
---|
[2631] | 61 | MESSAGE(STATUS "Warning: Could not find dependency directory." |
---|
| 62 | "Disable LIBRARY_USE_PACKAGE if you have none intalled.") |
---|
[2651] | 63 | ELSE() |
---|
[2674] | 64 | INCLUDE(PackageConfigMinGW) |
---|
| 65 | INCLUDE(PackageConfigMSVC) |
---|
| 66 | |
---|
[2673] | 67 | # On Windows, DLLs have to be in the executable folder, install them |
---|
[2651] | 68 | IF(DEP_BINARY_DIR AND WIN32) |
---|
| 69 | # When installing a debug version, we really can't know which libraries |
---|
| 70 | # are used in released mode because there might be deps of deps. |
---|
[2652] | 71 | INSTALL( |
---|
| 72 | DIRECTORY ${DEP_BINARY_DIR}/ |
---|
| 73 | DESTINATION bin |
---|
| 74 | CONFIGURATIONS Debug |
---|
| 75 | REGEX "^.*\\.pdb$" EXCLUDE |
---|
| 76 | ) |
---|
[2644] | 77 | |
---|
[2651] | 78 | # Try to filter out all the debug libraries. If the regex doesn't do the |
---|
| 79 | # job anymore, simply adjust it. |
---|
[2652] | 80 | INSTALL( |
---|
| 81 | DIRECTORY ${DEP_BINARY_DIR}/ |
---|
| 82 | DESTINATION bin |
---|
| 83 | CONFIGURATIONS Release RelWithDebInfo MinSizeRel |
---|
| 84 | REGEX "_[Dd]\\.[a-zA-Z0-9+-]+$|-mt-gd-|^.*\\.pdb$" EXCLUDE |
---|
| 85 | ) |
---|
[2651] | 86 | ENDIF(DEP_BINARY_DIR AND WIN32) |
---|
[2673] | 87 | ENDIF(NOT DEPENDENCY_PACKAGE_DIR) |
---|
| 88 | ENDIF(DEPENDENCY_PACKAGE_ENABLE) |
---|
[2631] | 89 | |
---|
[2618] | 90 | # User script |
---|
[2673] | 91 | SET(USER_SCRIPT_LIBRARY_CONFIG "" CACHE FILEPATH |
---|
[2618] | 92 | "Specify a CMake script if you wish to write your own library path config. |
---|
| 93 | See LibraryConfigTardis.cmake or LibraryConfigMinGW.cmake for examples.") |
---|
[2673] | 94 | IF(USER_SCRIPT_LIBRARY_CONFIG) |
---|
| 95 | IF(EXISTS ${CMAKE_MODULE_PATH}/${USER_SCRIPT_LIBRARY_CONFIG}.cmake) |
---|
| 96 | INCLUDE(${USER_SCRIPT_LIBRARY_CONFIG}) |
---|
| 97 | ELSEIF(EXISTS ${USER_SCRIPT_LIBRARY_CONFIG}) |
---|
| 98 | INCLUDE(${USER_SCRIPT_LIBRARY_CONFIG}) |
---|
| 99 | ELSEIF(EXISTS ${CMAKE_MODULE_PATH}/${USER_SCRIPT_LIBRARY_CONFIG}) |
---|
| 100 | INCLUDE(${CMAKE_MODULE_PATH}/${USER_SCRIPT_LIBRARY_CONFIG}) |
---|
[2624] | 101 | ENDIF() |
---|
[2673] | 102 | ENDIF(USER_SCRIPT_LIBRARY_CONFIG) |
---|
[2618] | 103 | |
---|
| 104 | |
---|
[2616] | 105 | ############### Library finding ################# |
---|
| 106 | # Performs the search and sets the variables # |
---|
[2579] | 107 | |
---|
[2616] | 108 | FIND_PACKAGE(OGRE 1.4 EXACT REQUIRED) |
---|
| 109 | FIND_PACKAGE(ENet 1.1 REQUIRED) |
---|
| 110 | FIND_PACKAGE(Ogg REQUIRED) |
---|
| 111 | FIND_PACKAGE(Vorbis REQUIRED) |
---|
| 112 | FIND_PACKAGE(ALUT REQUIRED) |
---|
| 113 | FIND_PACKAGE(ZLIB REQUIRED) |
---|
| 114 | IF(WIN32) |
---|
| 115 | FIND_PACKAGE(DirectX REQUIRED) |
---|
| 116 | ENDIF(WIN32) |
---|
[1505] | 117 | |
---|
[2616] | 118 | ##### CEGUI ##### |
---|
| 119 | # We make use of the CEGUI script module called CEGUILua. |
---|
| 120 | # However there is a small issue with that: We use Tolua, a C++ binding |
---|
| 121 | # generator ourselves. And we also have to use our bindings in the same |
---|
| 122 | # lua state is CEGUILua's. Unfortunately this implies that both lua runtime |
---|
| 123 | # version are equal or else you get segmentation faults. |
---|
| 124 | # In order to match the Lua versions we decided to ship CEGUILua in our |
---|
| 125 | # repository, mainly because there is no way to determine which version of |
---|
| 126 | # Lua CEGUILua was linked against (you'd have to specify yourself) and secondly |
---|
| 127 | # because we can then choose the Lua version. Future plans might involve only |
---|
| 128 | # accepting Lua 5.1. |
---|
| 129 | |
---|
| 130 | # Insert all internally supported CEGUILua versions here |
---|
| 131 | SET(CEGUILUA_INTERNAL_SUPPORT 0.5.0 0.6.0 0.6.1 0.6.2) |
---|
| 132 | OPTION(CEGUILUA_USE_EXTERNAL_LIBRARY "Force the use of external CEGUILua library" OFF) |
---|
| 133 | FIND_PACKAGE(CEGUI 0.5 REQUIRED) |
---|
| 134 | |
---|
[2615] | 135 | ##### Lua ##### |
---|
| 136 | IF(CEGUILUA_USE_EXTERNAL_LIBRARY) |
---|
| 137 | COMPARE_VERSION_STRINGS(${CEGUI_VERSION} "0.6" _version_comparison) |
---|
| 138 | IF(version_comparison LESS 0) |
---|
| 139 | SET(LUA_VERSION_REQUEST 5.0) |
---|
[2624] | 140 | ELSE() |
---|
[2615] | 141 | SET(LUA_VERSION_REQUEST 5.1) |
---|
[2624] | 142 | ENDIF() |
---|
| 143 | ELSE() |
---|
[2615] | 144 | SET(LUA_VERSION_REQUEST 5) |
---|
[2624] | 145 | ENDIF() |
---|
[2615] | 146 | FIND_PACKAGE(Lua ${LUA_VERSION_REQUEST} EXACT REQUIRED) |
---|
[2510] | 147 | |
---|
[2616] | 148 | ##### OpenAL ##### |
---|
| 149 | FIND_PACKAGE(OpenAL REQUIRED) |
---|
[2630] | 150 | # Also use parent include dir (without AL/) for ALUT |
---|
| 151 | IF(OPENAL_INCLUDE_DIR MATCHES "/AL$") |
---|
| 152 | GET_FILENAME_COMPONENT(ALT_OPENAL_INCLUDE_DIR ${OPENAL_INCLUDE_DIR} PATH) |
---|
[2624] | 153 | ENDIF() |
---|
[2630] | 154 | SET(OPENAL_INCLUDE_DIRS ${OPENAL_INCLUDE_DIR} ${ALT_OPENAL_INCLUDE_DIR}) |
---|
[2628] | 155 | # Notfiy user |
---|
| 156 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenAL DEFAULT_MSG OPENAL_LIBRARY OPENAL_INCLUDE_DIR) |
---|
[2616] | 157 | # Hide variables created by the script |
---|
[2628] | 158 | MARK_AS_ADVANCED(OPENAL_INCLUDE_DIR OPENAL_LIBRARY) |
---|
[2616] | 159 | |
---|
[2637] | 160 | ##### Tcl ##### |
---|
| 161 | # We only require Tcl, so avoid confusing user about other Tcl stuff by |
---|
[2616] | 162 | # applying a little workaround |
---|
| 163 | SET(Tclsh_FIND_QUIETLY TRUE) |
---|
[2677] | 164 | FIND_PACKAGE(TCL QUIET) |
---|
[2616] | 165 | # Display messages separately |
---|
| 166 | SET(TCL_FIND_QUIETLY FALSE) |
---|
| 167 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(TCL DEFAULT_MSG TCL_LIBRARY TCL_INCLUDE_PATH) |
---|
| 168 | |
---|
| 169 | ##### Boost ##### |
---|
| 170 | # Expand the next statement if newer boost versions than 1.36.1 are released |
---|
| 171 | SET(Boost_ADDITIONAL_VERSIONS 1.37 1.37.0) |
---|
[2649] | 172 | # MSVC seems to be the only compiler requiring date_time |
---|
[2630] | 173 | IF(MSVC) |
---|
[2649] | 174 | FIND_PACKAGE(Boost 1.34 REQUIRED thread filesystem date_time) |
---|
[2630] | 175 | ELSE(MSVC) |
---|
[2649] | 176 | FIND_PACKAGE(Boost 1.34 REQUIRED thread filesystem) |
---|
[2630] | 177 | ENDIF(MSVC) |
---|
[2649] | 178 | # Boost 1.35 and newer also need the 'System' library |
---|
| 179 | IF(NOT Boost_VERSION LESS 103500) |
---|
| 180 | FIND_PACKAGE(Boost 1.35 REQUIRED system) |
---|
| 181 | ENDIF() |
---|
[2673] | 182 | # No auto linking, so this option is useless anyway |
---|
| 183 | MARK_AS_ADVANCED(Boost_LIB_DIAGNOSTIC_DEFINITIONS) |
---|
[2618] | 184 | |
---|
| 185 | ####### Static/Dynamic linking options ########## |
---|
| 186 | |
---|
| 187 | # On Windows dynamically linked libraries need some special treatment |
---|
| 188 | # You may want to edit these settings if you provide your own libraries |
---|
| 189 | # Note: Default option in the libraries vary, but our default option is dynamic |
---|
| 190 | IF(WIN32) |
---|
| 191 | OPTION(LINK_BOOST_DYNAMIC "Link Boost dynamically on Windows" TRUE) |
---|
| 192 | OPTION(LINK_CEGUI_DYNAMIC "Link CEGUI dynamicylly on Windows" TRUE) |
---|
| 193 | OPTION(LINK_ENET_DYNAMIC "Link ENet dynamically on Windows" TRUE) |
---|
| 194 | OPTION(LINK_OGRE_DYNAMIC "Link OGRE dynamically on Windows" TRUE) |
---|
| 195 | OPTION(LINK_TCL_DYNAMIC "Link TCL dynamically on Windows" TRUE) |
---|
| 196 | OPTION(LINK_ZLIB_DYNAMIC "Link ZLib dynamically on Windows" TRUE) |
---|
| 197 | COMPARE_VERSION_STRINGS("${LUA_VERSION}" "5.1" _version_comparison) |
---|
| 198 | IF(_version_comparison LESS 0) |
---|
| 199 | OPTION(LINK_LUA_DYNAMIC "Link Lua dynamically on Windows" FALSE) |
---|
| 200 | ELSE(_version_comparison LESS 0) |
---|
| 201 | OPTION(LINK_LUA_DYNAMIC "Link Lua dynamically on Windows" TRUE) |
---|
| 202 | ENDIF(_version_comparison LESS 0) |
---|
| 203 | ENDIF(WIN32) |
---|