Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/buildsystem2/cmake/LibraryConfig.cmake @ 2626

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

Added license text to all CMake files except to the subdirectoties of the libraries.
Also adjusted some the Find script documentation and wrote Descriptions for every file not in src/.

  • Property svn:eol-style set to native
File size: 6.7 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################ Misc Options ###################
32
33OPTION(LIBRARY_USE_PACKAGE_IF_SUPPORTED
34       "When set to false CMake will only look in the standard paths for libraries" ON)
35
36
37############## Platform Scripts #################
38
39# Scripts for specific library and CMake config
40INCLUDE(LibraryConfigTardis)
41INCLUDE(LibraryConfigApple)
42INCLUDE(LibraryConfigMSVC)
43INCLUDE(LibraryConfigMinGW)
44
45# User script
46SET(LIBRARY_CONFIG_USER_SCRIPT "" CACHE FILEPATH
47    "Specify a CMake script if you wish to write your own library path config.
48     See LibraryConfigTardis.cmake or LibraryConfigMinGW.cmake for examples.")
49IF(LIBRARY_CONFIG_USER_SCRIPT)
50  IF(EXISTS ${CMAKE_MODULE_PATH}/${LIBRARY_CONFIG_USER_SCRIPT}.cmake)
51    INCLUDE(${LIBRARY_CONFIG_USER_SCRIPT})
52  ELSEIF(EXISTS ${LIBRARY_CONFIG_USER_SCRIPT})
53    INCLUDE(${LIBRARY_CONFIG_USER_SCRIPT})
54  ELSEIF(EXISTS ${CMAKE_MODULE_PATH}/${LIBRARY_CONFIG_USER_SCRIPT})
55    INCLUDE(${CMAKE_MODULE_PATH}/${LIBRARY_CONFIG_USER_SCRIPT})
56  ENDIF()
57ENDIF(LIBRARY_CONFIG_USER_SCRIPT)
58
59
60############### Library finding #################
61# Performs the search and sets the variables    #
62
63FIND_PACKAGE(OGRE  1.4 EXACT REQUIRED)
64FIND_PACKAGE(ENet  1.1       REQUIRED)
65FIND_PACKAGE(Ogg             REQUIRED)
66FIND_PACKAGE(Vorbis          REQUIRED)
67FIND_PACKAGE(ALUT            REQUIRED)
68FIND_PACKAGE(ZLIB            REQUIRED)
69IF(WIN32)
70  FIND_PACKAGE(DirectX       REQUIRED)
71ENDIF(WIN32)
72
73##### CEGUI #####
74# We make use of the CEGUI script module called CEGUILua.
75# However there is a small issue with that: We use Tolua, a C++ binding
76# generator ourselves. And we also have to use our bindings in the same
77# lua state is CEGUILua's. Unfortunately this implies that both lua runtime
78# version are equal or else you get segmentation faults.
79# In order to match the Lua versions we decided to ship CEGUILua in our
80# repository, mainly because there is no way to determine which version of
81# Lua CEGUILua was linked against (you'd have to specify yourself) and secondly
82# because we can then choose the Lua version. Future plans might involve only
83# accepting Lua 5.1.
84
85# Insert all internally supported CEGUILua versions here
86SET(CEGUILUA_INTERNAL_SUPPORT 0.5.0 0.6.0 0.6.1 0.6.2)
87OPTION(CEGUILUA_USE_EXTERNAL_LIBRARY "Force the use of external CEGUILua library" OFF)
88FIND_PACKAGE(CEGUI 0.5 REQUIRED)
89
90##### Lua #####
91IF(CEGUILUA_USE_EXTERNAL_LIBRARY)
92  COMPARE_VERSION_STRINGS(${CEGUI_VERSION} "0.6" _version_comparison)
93  IF(version_comparison LESS 0)
94    SET(LUA_VERSION_REQUEST 5.0)
95  ELSE()
96    SET(LUA_VERSION_REQUEST 5.1)
97  ENDIF()
98ELSE()
99  SET(LUA_VERSION_REQUEST 5)
100ENDIF()
101FIND_PACKAGE(Lua ${LUA_VERSION_REQUEST} EXACT REQUIRED)
102
103##### OpenAL #####
104FIND_PACKAGE(OpenAL REQUIRED)
105# ALUT's headers include openal headers, but like <AL/al.h>, not <al.h>
106# Unfortunately this is not the case on all systems, so FindOpenAL.cmake
107# specifies the directory/AL, which now causes problems with ALUT.
108IF(DEFINED OPENAL_FOUND_FIRST_TIME)
109  SET(OPENAL_FOUND_FIRST_TIME FALSE CACHE INTERNAL "")
110ELSE()
111  SET(OPENAL_FOUND_FIRST_TIME TRUE CACHE INTERNAL "")
112  STRING(REGEX REPLACE "^(.*)/AL$" "\\1" _openal_dir_2 ${OPENAL_INCLUDE_DIR})
113  IF(_openal_dir_2)
114    SET(OPENAL_INCLUDE_DIR ${OPENAL_INCLUDE_DIR} ${_openal_dir_2} CACHE STRING "" FORCE)
115  ENDIF()
116ENDIF()
117# Hide variables created by the script
118MARK_AS_ADVANCED(
119  OPENAL_INCLUDE_DIR
120  OPENAL_LIBRARY
121)
122
123##### TCL #####
124# We only require TCL, so avoid confusing user about other TCL stuff by
125# applying a little workaround
126SET(Tclsh_FIND_QUIETLY TRUE)
127FIND_PACKAGE(TCL 8.4 REQUIRED QUIET)
128# Display messages separately
129SET(TCL_FIND_QUIETLY FALSE)
130FIND_PACKAGE_HANDLE_STANDARD_ARGS(TCL DEFAULT_MSG TCL_LIBRARY TCL_INCLUDE_PATH)
131# Workaround a CMake bug that doesn't set the variables to the cache
132# Occurs at least on CMake 2.6.2 and 2.6.0 under Windows
133SET(TCL_LIBRARY ${TCL_LIBRARY} CACHE FILEPATH "")
134SET(TCL_INCLUDE_PATH ${TCL_INCLUDE_PATH} CACHE PATH "")
135
136##### Boost #####
137# Expand the next statement if newer boost versions than 1.36.1 are released
138SET(Boost_ADDITIONAL_VERSIONS 1.37 1.37.0)
139FIND_PACKAGE(Boost 1.34 REQUIRED thread filesystem)
140# With MSVC, automatic linking is performed for boost. So wee need to tell
141# the linker where to find them. Also note that when running FindBoost for the
142# first time, it will set ${Boost_LIBRARIES} to "" but afterwards to the libs.
143IF (MSVC)
144  # Little bit hacky, but Boost_LIBRARY_DIRS doesn't get set right when having
145  # debug and optimized libraries.
146  GET_FILENAME_COMPONENT(BOOST_LINK_DIR "${Boost_THREAD_LIBRARY_RELEASE}" PATH)
147  LINK_DIRECTORIES(${BOOST_LINK_DIR})
148ENDIF (MSVC)
149
150
151####### Static/Dynamic linking options ##########
152
153# On Windows dynamically linked libraries need some special treatment
154# You may want to edit these settings if you provide your own libraries
155# Note: Default option in the libraries vary, but our default option is dynamic
156IF(WIN32)
157  OPTION(LINK_BOOST_DYNAMIC "Link Boost dynamically on Windows" TRUE)
158  OPTION(LINK_CEGUI_DYNAMIC "Link CEGUI dynamicylly on Windows" TRUE)
159  OPTION(LINK_ENET_DYNAMIC  "Link ENet dynamically on Windows" TRUE)
160  OPTION(LINK_OGRE_DYNAMIC  "Link OGRE dynamically on Windows" TRUE)
161  OPTION(LINK_TCL_DYNAMIC   "Link TCL dynamically on Windows" TRUE)
162  OPTION(LINK_ZLIB_DYNAMIC  "Link ZLib dynamically on Windows" TRUE)
163  COMPARE_VERSION_STRINGS("${LUA_VERSION}" "5.1" _version_comparison)
164  IF(_version_comparison LESS 0)
165    OPTION(LINK_LUA_DYNAMIC "Link Lua dynamically on Windows" FALSE)
166  ELSE(_version_comparison LESS 0)
167    OPTION(LINK_LUA_DYNAMIC "Link Lua dynamically on Windows" TRUE)
168  ENDIF(_version_comparison LESS 0)
169ENDIF(WIN32)
Note: See TracBrowser for help on using the repository browser.