| 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 | |
|---|
| 28 | INCLUDE(CompareVersionStrings) |
|---|
| 29 | INCLUDE(FindPackageHandleStandardArgs) |
|---|
| 30 | |
|---|
| 31 | # Prevent CMake from finding libraries in the installation folder on Windows. |
|---|
| 32 | # There might already be an installation from another compiler |
|---|
| 33 | IF(WIN32) |
|---|
| 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() |
|---|
| 37 | |
|---|
| 38 | ############## Platform Scripts ################# |
|---|
| 39 | |
|---|
| 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 OR APPLE) |
|---|
| 43 | OPTION(DEPENDENCY_PACKAGE_ENABLE "${_option_msg}" ON) |
|---|
| 44 | ELSE() |
|---|
| 45 | OPTION(DEPENDENCY_PACKAGE_ENABLE "${_option_msg}" FALSE) |
|---|
| 46 | ENDIF() |
|---|
| 47 | |
|---|
| 48 | # Scripts for specific library and CMake config |
|---|
| 49 | INCLUDE(LibraryConfigTardis) |
|---|
| 50 | |
|---|
| 51 | IF(DEPENDENCY_PACKAGE_ENABLE) |
|---|
| 52 | IF(APPLE AND NOT EXISTS ${CMAKE_SOURCE_DIR}/dependencies) |
|---|
| 53 | # Let CMake automatically download and extract the dependency package on Mac OS X |
|---|
| 54 | # TODO: Handle download errors and always select newest package |
|---|
| 55 | SET(_dep_package_current "OrxonoxDeps_110428_2.0_OSX.tar.bz2") |
|---|
| 56 | SET(_dep_package_url "http://svn.orxonox.net/ogre/apple/precompiled_dependencies") |
|---|
| 57 | MESSAGE(STATUS "Downloading Mac OS X dependency package.") |
|---|
| 58 | FILE(DOWNLOAD |
|---|
| 59 | ${_dep_package_url}/${_dep_package_current} |
|---|
| 60 | ${CMAKE_SOURCE_DIR}/${_dep_package_current} |
|---|
| 61 | ) |
|---|
| 62 | MESSAGE(STATUS "Extracting Mac OS X dependency package.") |
|---|
| 63 | EXECUTE_PROCESS( |
|---|
| 64 | COMMAND ${CMAKE_COMMAND} -E tar -jxf ${_dep_package_current} |
|---|
| 65 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} |
|---|
| 66 | OUTPUT_FILE ${CMAKE_BINARY_DIR}/dep_pack_extract_log.keep_me |
|---|
| 67 | ) |
|---|
| 68 | # Delete the dependency archive once we no longer need it |
|---|
| 69 | FILE(REMOVE ${CMAKE_SOURCE_DIR}/${_dep_package_current}) |
|---|
| 70 | ENDIF() |
|---|
| 71 | |
|---|
| 72 | GET_FILENAME_COMPONENT(_dep_dir_1 ${CMAKE_SOURCE_DIR}/../dependencies ABSOLUTE) |
|---|
| 73 | GET_FILENAME_COMPONENT(_dep_dir_2 ${CMAKE_SOURCE_DIR}/../lib_dist ABSOLUTE) |
|---|
| 74 | IF(MINGW) |
|---|
| 75 | SET(_compiler_prefix mingw) |
|---|
| 76 | ELSEIF(MSVC80) |
|---|
| 77 | SET(_compiler_prefix msvc8) |
|---|
| 78 | ELSEIF(MSVC90) |
|---|
| 79 | SET(_compiler_prefix msvc9) |
|---|
| 80 | ELSEIF(MSVC10) |
|---|
| 81 | SET(_compiler_prefix msvc10) |
|---|
| 82 | ENDIF() |
|---|
| 83 | FIND_PATH(DEPENDENCY_PACKAGE_DIR |
|---|
| 84 | NAMES version.txt |
|---|
| 85 | PATHS |
|---|
| 86 | ${CMAKE_SOURCE_DIR}/dependencies |
|---|
| 87 | ${_dep_dir_1} |
|---|
| 88 | ${_dep_dir_2} |
|---|
| 89 | PATH_SUFFIXES ${_compiler_prefix} ${_compiler_prefix}/dependencies |
|---|
| 90 | NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH |
|---|
| 91 | ) |
|---|
| 92 | IF(NOT DEPENDENCY_PACKAGE_DIR) |
|---|
| 93 | MESSAGE(STATUS "Warning: Could not find dependency directory." |
|---|
| 94 | "Disable LIBRARY_USE_PACKAGE if you have none intalled.") |
|---|
| 95 | ELSE() |
|---|
| 96 | IF(WIN32) |
|---|
| 97 | INCLUDE(PackageConfigMinGW) |
|---|
| 98 | INCLUDE(PackageConfigMSVC) |
|---|
| 99 | INCLUDE(PackageConfig) # For both msvc and mingw |
|---|
| 100 | ELSEIF(APPLE) |
|---|
| 101 | INCLUDE(PackageConfigOSX) |
|---|
| 102 | ENDIF(WIN32) |
|---|
| 103 | ENDIF() |
|---|
| 104 | ENDIF(DEPENDENCY_PACKAGE_ENABLE) |
|---|
| 105 | |
|---|
| 106 | # User script |
|---|
| 107 | SET(LIBRARY_CONFIG_USER_SCRIPT "" CACHE FILEPATH |
|---|
| 108 | "Specify a CMake script if you wish to write your own library path config. |
|---|
| 109 | See LibraryConfigTardis.cmake for an example.") |
|---|
| 110 | IF(LIBRARY_CONFIG_USER_SCRIPT) |
|---|
| 111 | IF(EXISTS ${CMAKE_MODULE_PATH}/${LIBRARY_CONFIG_USER_SCRIPT}) |
|---|
| 112 | INCLUDE(${CMAKE_MODULE_PATH}/${LIBRARY_CONFIG_USER_SCRIPT}) |
|---|
| 113 | ENDIF() |
|---|
| 114 | ENDIF(LIBRARY_CONFIG_USER_SCRIPT) |
|---|
| 115 | |
|---|
| 116 | |
|---|
| 117 | ############### Library finding ################# |
|---|
| 118 | # Performs the search and sets the variables # |
|---|
| 119 | |
|---|
| 120 | #FIND_PACKAGE(ENet 1.2 REQUIRED) |
|---|
| 121 | FIND_PACKAGE(CEGUI 0.6 REQUIRED) |
|---|
| 122 | FIND_PACKAGE(Lua5.1 REQUIRED) |
|---|
| 123 | FIND_PACKAGE(Ogg REQUIRED) |
|---|
| 124 | FIND_PACKAGE(Vorbis REQUIRED) |
|---|
| 125 | FIND_PACKAGE(ALUT REQUIRED) |
|---|
| 126 | FIND_PACKAGE(ZLIB REQUIRED) |
|---|
| 127 | |
|---|
| 128 | IF(WIN32) |
|---|
| 129 | FIND_PACKAGE(DbgHelp) |
|---|
| 130 | FIND_PACKAGE(DirectX REQUIRED) |
|---|
| 131 | ENDIF() |
|---|
| 132 | |
|---|
| 133 | |
|---|
| 134 | ##### OpenAL ##### |
|---|
| 135 | FIND_PACKAGE(OpenAL REQUIRED) |
|---|
| 136 | # Also use parent include dir (without AL/) for ALUT |
|---|
| 137 | IF(OPENAL_INCLUDE_DIR MATCHES "/AL$") |
|---|
| 138 | GET_FILENAME_COMPONENT(ALT_OPENAL_INCLUDE_DIR ${OPENAL_INCLUDE_DIR} PATH) |
|---|
| 139 | ENDIF() |
|---|
| 140 | SET(OPENAL_INCLUDE_DIRS ${OPENAL_INCLUDE_DIR} ${ALT_OPENAL_INCLUDE_DIR}) |
|---|
| 141 | # Notfiy user |
|---|
| 142 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenAL DEFAULT_MSG OPENAL_LIBRARY OPENAL_INCLUDE_DIR) |
|---|
| 143 | # Hide variables created by the script |
|---|
| 144 | MARK_AS_ADVANCED(OPENAL_INCLUDE_DIR OPENAL_LIBRARY) |
|---|
| 145 | |
|---|
| 146 | ##### Tcl ##### |
|---|
| 147 | # We only require Tcl, so avoid confusing user about other Tcl stuff by |
|---|
| 148 | # applying a little workaround |
|---|
| 149 | SET(Tclsh_FIND_QUIETLY TRUE) |
|---|
| 150 | FIND_PACKAGE(TCL QUIET) |
|---|
| 151 | # Display messages separately |
|---|
| 152 | SET(TCL_FIND_QUIETLY FALSE) |
|---|
| 153 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(TCL DEFAULT_MSG TCL_LIBRARY TCL_INCLUDE_PATH) |
|---|
| 154 | |
|---|
| 155 | ##### Boost ##### |
|---|
| 156 | # Expand the next statement if newer boost versions are released |
|---|
| 157 | SET(Boost_ADDITIONAL_VERSIONS 1.40 1.40.0 1.41 1.41.0 1.42 1.42.0 1.43 1.43.0 |
|---|
| 158 | 1.44 1.44.0 1.45 1.45.0 1.46 1.46.0 1.46.1) |
|---|
| 159 | IF(NOT TARDIS) |
|---|
| 160 | FIND_PACKAGE(Boost 1.40 REQUIRED thread filesystem system date_time) |
|---|
| 161 | ENDIF() |
|---|
| 162 | # No auto linking, so this option is useless anyway |
|---|
| 163 | MARK_AS_ADVANCED(Boost_LIB_DIAGNOSTIC_DEFINITIONS) |
|---|
| 164 | |
|---|
| 165 | ##### OGRE ##### |
|---|
| 166 | FIND_PACKAGE(OGRE 1.6 REQUIRED) |
|---|
| 167 | # For Ogre >= 1.7, we might need a threading library |
|---|
| 168 | # Variables are either defined by dependency package config or by FindOGRE |
|---|
| 169 | IF(OGRE_NEEDS_POCO) |
|---|
| 170 | FIND_PACKAGE(POCO REQUIRED) |
|---|
| 171 | # Always link against POCO too because of threading |
|---|
| 172 | SET(OGRE_LIBRARY ${OGRE_LIBRARY} ${POCO_LIBRARY}) |
|---|
| 173 | ELSEIF(OGRE_NEEDS_BOOST) |
|---|
| 174 | # Always link against boost too because of threading |
|---|
| 175 | SET(OGRE_LIBRARY ${OGRE_LIBRARY} ${Boost_THREAD_LIBRARY}) |
|---|
| 176 | ENDIF() |
|---|
| 177 | |
|---|
| 178 | |
|---|
| 179 | ####### Static/Dynamic linking options ########## |
|---|
| 180 | |
|---|
| 181 | # On Windows dynamically linked libraries need some special treatment |
|---|
| 182 | # You may want to edit these settings if you provide your own libraries |
|---|
| 183 | # Note: Default option in the libraries vary, but our default option is dynamic |
|---|
| 184 | IF(WIN32) |
|---|
| 185 | OPTION(LINK_BOOST_DYNAMIC "Link Boost dynamically on Windows" TRUE) |
|---|
| 186 | OPTION(LINK_CEGUI_DYNAMIC "Link CEGUI dynamicylly on Windows" TRUE) |
|---|
| 187 | #OPTION(LINK_ENET_DYNAMIC "Link ENet dynamically on Windows" TRUE) |
|---|
| 188 | OPTION(LINK_OGRE_DYNAMIC "Link OGRE dynamically on Windows" TRUE) |
|---|
| 189 | OPTION(LINK_TCL_DYNAMIC "Link TCL dynamically on Windows" TRUE) |
|---|
| 190 | OPTION(LINK_ZLIB_DYNAMIC "Link ZLib dynamically on Windows" TRUE) |
|---|
| 191 | OPTION(LINK_LUA5.1_DYNAMIC "Link Lua dynamically on Windows" TRUE) |
|---|
| 192 | |
|---|
| 193 | IF(DEPENDENCY_PACKAGE_ENABLE) |
|---|
| 194 | MARK_AS_ADVANCED( |
|---|
| 195 | LINK_BOOST_DYNAMIC LINK_CEGUI_DYNAMIC #LINK_ENET_DYNAMIC |
|---|
| 196 | LINK_OGRE_DYNAMIC LINK_TCL_DYNAMIC LINK_ZLIB_DYNAMIC |
|---|
| 197 | LINK_LUA5.1_DYNAMIC |
|---|
| 198 | ) |
|---|
| 199 | ENDIF() |
|---|
| 200 | ENDIF(WIN32) |
|---|
| 201 | |
|---|
| 202 | |
|---|
| 203 | ################# OGRE Plugins ################## |
|---|
| 204 | |
|---|
| 205 | # Check the plugins and determine the plugin folder |
|---|
| 206 | # You can give a hint by setting the environment variable ENV{OGRE_PLUGIN_DIR} |
|---|
| 207 | INCLUDE(CheckOGREPlugins) |
|---|
| 208 | # Note 1: First argument (as string!) are for mandatory plugins, second one is |
|---|
| 209 | # for optional ones. |
|---|
| 210 | # Note 2: Render systems are found automatically (at least one required) |
|---|
| 211 | CHECK_OGRE_PLUGINS("Plugin_ParticleFX" "Plugin_CgProgramManager") |
|---|
| 212 | |
|---|