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 | ################ Misc Options ################### |
---|
32 | |
---|
33 | OPTION(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 |
---|
40 | INCLUDE(LibraryConfigTardis) |
---|
41 | INCLUDE(LibraryConfigApple) |
---|
42 | INCLUDE(LibraryConfigMSVC) |
---|
43 | INCLUDE(LibraryConfigMinGW) |
---|
44 | |
---|
45 | # User script |
---|
46 | SET(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.") |
---|
49 | IF(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() |
---|
57 | ENDIF(LIBRARY_CONFIG_USER_SCRIPT) |
---|
58 | |
---|
59 | |
---|
60 | ############### Library finding ################# |
---|
61 | # Performs the search and sets the variables # |
---|
62 | |
---|
63 | FIND_PACKAGE(OGRE 1.4 EXACT REQUIRED) |
---|
64 | FIND_PACKAGE(ENet 1.1 REQUIRED) |
---|
65 | FIND_PACKAGE(Ogg REQUIRED) |
---|
66 | FIND_PACKAGE(Vorbis REQUIRED) |
---|
67 | FIND_PACKAGE(ALUT REQUIRED) |
---|
68 | FIND_PACKAGE(ZLIB REQUIRED) |
---|
69 | IF(WIN32) |
---|
70 | FIND_PACKAGE(DirectX REQUIRED) |
---|
71 | ENDIF(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 |
---|
86 | SET(CEGUILUA_INTERNAL_SUPPORT 0.5.0 0.6.0 0.6.1 0.6.2) |
---|
87 | OPTION(CEGUILUA_USE_EXTERNAL_LIBRARY "Force the use of external CEGUILua library" OFF) |
---|
88 | FIND_PACKAGE(CEGUI 0.5 REQUIRED) |
---|
89 | |
---|
90 | ##### Lua ##### |
---|
91 | IF(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() |
---|
98 | ELSE() |
---|
99 | SET(LUA_VERSION_REQUEST 5) |
---|
100 | ENDIF() |
---|
101 | FIND_PACKAGE(Lua ${LUA_VERSION_REQUEST} EXACT REQUIRED) |
---|
102 | |
---|
103 | ##### OpenAL ##### |
---|
104 | FIND_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. |
---|
108 | IF(DEFINED OPENAL_FOUND_FIRST_TIME) |
---|
109 | SET(OPENAL_FOUND_FIRST_TIME FALSE CACHE INTERNAL "") |
---|
110 | ELSE() |
---|
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() |
---|
116 | ENDIF() |
---|
117 | # Hide variables created by the script |
---|
118 | MARK_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 |
---|
126 | SET(Tclsh_FIND_QUIETLY TRUE) |
---|
127 | FIND_PACKAGE(TCL 8.4 REQUIRED QUIET) |
---|
128 | # Display messages separately |
---|
129 | SET(TCL_FIND_QUIETLY FALSE) |
---|
130 | FIND_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 |
---|
133 | SET(TCL_LIBRARY ${TCL_LIBRARY} CACHE FILEPATH "") |
---|
134 | SET(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 |
---|
138 | SET(Boost_ADDITIONAL_VERSIONS 1.37 1.37.0) |
---|
139 | FIND_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. |
---|
143 | IF (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}) |
---|
148 | ENDIF (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 |
---|
156 | IF(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) |
---|
169 | ENDIF(WIN32) |
---|