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