Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/buildsystem3/cmake/LibraryConfig.cmake @ 2696

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

Bugfix: Accidentally removed /usr from the CMAKE_PREFIX_PATH.

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