Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/ggz/cmake/LibraryConfig.cmake @ 6193

Last change on this file since 6193 was 3009, checked in by rgrieder, 15 years ago

Inadvertently forgot to adjust the ENDIF statement.

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