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(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") |
---|
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) |
---|
43 | OPTION(DEPENDENCY_PACKAGE_ENABLE "${_option_msg}" ON) |
---|
44 | ELSE(WIN32) |
---|
45 | OPTION(DEPENDENCY_PACKAGE_ENABLE "${_option_msg}" FALSE) |
---|
46 | ENDIF(WIN32) |
---|
47 | |
---|
48 | # Scripts for specific library and CMake config |
---|
49 | INCLUDE(LibraryConfigTardis) |
---|
50 | INCLUDE(LibraryConfigApple) |
---|
51 | |
---|
52 | IF(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 | NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH |
---|
62 | ) |
---|
63 | IF(NOT DEPENDENCY_PACKAGE_DIR) |
---|
64 | MESSAGE(STATUS "Warning: Could not find dependency directory." |
---|
65 | "Disable LIBRARY_USE_PACKAGE if you have none intalled.") |
---|
66 | ELSE() |
---|
67 | INCLUDE(PackageConfigMinGW) |
---|
68 | INCLUDE(PackageConfigMSVC) |
---|
69 | INCLUDE(PackageConfig) # For both msvc and mingw |
---|
70 | ENDIF() |
---|
71 | ENDIF(DEPENDENCY_PACKAGE_ENABLE) |
---|
72 | |
---|
73 | # User script |
---|
74 | SET(USER_SCRIPT_LIBRARY_CONFIG "" CACHE FILEPATH |
---|
75 | "Specify a CMake script if you wish to write your own library path config. |
---|
76 | See LibraryConfigTardis.cmake or LibraryConfigMinGW.cmake for examples.") |
---|
77 | IF(USER_SCRIPT_LIBRARY_CONFIG) |
---|
78 | IF(EXISTS ${CMAKE_MODULE_PATH}/${USER_SCRIPT_LIBRARY_CONFIG}.cmake) |
---|
79 | INCLUDE(${USER_SCRIPT_LIBRARY_CONFIG}) |
---|
80 | ELSEIF(EXISTS ${USER_SCRIPT_LIBRARY_CONFIG}) |
---|
81 | INCLUDE(${USER_SCRIPT_LIBRARY_CONFIG}) |
---|
82 | ELSEIF(EXISTS ${CMAKE_MODULE_PATH}/${USER_SCRIPT_LIBRARY_CONFIG}) |
---|
83 | INCLUDE(${CMAKE_MODULE_PATH}/${USER_SCRIPT_LIBRARY_CONFIG}) |
---|
84 | ENDIF() |
---|
85 | ENDIF(USER_SCRIPT_LIBRARY_CONFIG) |
---|
86 | |
---|
87 | |
---|
88 | ############### Library finding ################# |
---|
89 | # Performs the search and sets the variables # |
---|
90 | |
---|
91 | FIND_PACKAGE(OGRE 1.4 EXACT REQUIRED) |
---|
92 | FIND_PACKAGE(ENet 1.1 REQUIRED) |
---|
93 | FIND_PACKAGE(Ogg REQUIRED) |
---|
94 | FIND_PACKAGE(Vorbis REQUIRED) |
---|
95 | FIND_PACKAGE(ALUT REQUIRED) |
---|
96 | FIND_PACKAGE(ZLIB REQUIRED) |
---|
97 | IF(WIN32) |
---|
98 | FIND_PACKAGE(DirectX REQUIRED) |
---|
99 | ENDIF(WIN32) |
---|
100 | |
---|
101 | ##### CEGUI ##### |
---|
102 | # We make use of the CEGUI script module called CEGUILua. |
---|
103 | # However there is a small issue with that: We use Tolua, a C++ binding |
---|
104 | # generator ourselves. And we also have to use our bindings in the same |
---|
105 | # lua state is CEGUILua's. Unfortunately this implies that both lua runtime |
---|
106 | # version are equal or else you get segmentation faults. |
---|
107 | # In order to match the Lua versions we decided to ship CEGUILua in our |
---|
108 | # repository, mainly because there is no way to determine which version of |
---|
109 | # Lua CEGUILua was linked against (you'd have to specify yourself) and secondly |
---|
110 | # because we can then choose the Lua version. Future plans might involve only |
---|
111 | # accepting Lua 5.1. |
---|
112 | |
---|
113 | # Insert all internally supported CEGUILua versions here |
---|
114 | SET(CEGUILUA_INTERNAL_SUPPORT 0.5.0 0.6.0 0.6.1 0.6.2) |
---|
115 | OPTION(CEGUILUA_USE_EXTERNAL_LIBRARY "Force the use of external CEGUILua library" OFF) |
---|
116 | FIND_PACKAGE(CEGUI 0.5 REQUIRED) |
---|
117 | |
---|
118 | ##### Lua ##### |
---|
119 | IF(CEGUILUA_USE_EXTERNAL_LIBRARY) |
---|
120 | COMPARE_VERSION_STRINGS(${CEGUI_VERSION} "0.6" _version_comparison) |
---|
121 | IF(version_comparison LESS 0) |
---|
122 | SET(LUA_VERSION_REQUEST 5.0) |
---|
123 | ELSE() |
---|
124 | SET(LUA_VERSION_REQUEST 5.1) |
---|
125 | ENDIF() |
---|
126 | ELSE() |
---|
127 | SET(LUA_VERSION_REQUEST 5) |
---|
128 | ENDIF() |
---|
129 | FIND_PACKAGE(Lua ${LUA_VERSION_REQUEST} EXACT REQUIRED) |
---|
130 | |
---|
131 | ##### OpenAL ##### |
---|
132 | FIND_PACKAGE(OpenAL REQUIRED) |
---|
133 | # Also use parent include dir (without AL/) for ALUT |
---|
134 | IF(OPENAL_INCLUDE_DIR MATCHES "/AL$") |
---|
135 | GET_FILENAME_COMPONENT(ALT_OPENAL_INCLUDE_DIR ${OPENAL_INCLUDE_DIR} PATH) |
---|
136 | ENDIF() |
---|
137 | SET(OPENAL_INCLUDE_DIRS ${OPENAL_INCLUDE_DIR} ${ALT_OPENAL_INCLUDE_DIR}) |
---|
138 | # Notfiy user |
---|
139 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenAL DEFAULT_MSG OPENAL_LIBRARY OPENAL_INCLUDE_DIR) |
---|
140 | # Hide variables created by the script |
---|
141 | MARK_AS_ADVANCED(OPENAL_INCLUDE_DIR OPENAL_LIBRARY) |
---|
142 | |
---|
143 | ##### Tcl ##### |
---|
144 | # We only require Tcl, so avoid confusing user about other Tcl stuff by |
---|
145 | # applying a little workaround |
---|
146 | SET(Tclsh_FIND_QUIETLY TRUE) |
---|
147 | FIND_PACKAGE(TCL QUIET) |
---|
148 | # Display messages separately |
---|
149 | SET(TCL_FIND_QUIETLY FALSE) |
---|
150 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(TCL DEFAULT_MSG TCL_LIBRARY TCL_INCLUDE_PATH) |
---|
151 | |
---|
152 | ##### Boost ##### |
---|
153 | # Expand the next statement if newer boost versions than 1.36.1 are released |
---|
154 | SET(Boost_ADDITIONAL_VERSIONS 1.37 1.37.0 1.38 1.38.0 1.39 1.39.0) |
---|
155 | # MSVC seems to be the only compiler requiring date_time |
---|
156 | IF(MSVC) |
---|
157 | FIND_PACKAGE(Boost 1.34 REQUIRED thread filesystem date_time) |
---|
158 | ELSE(MSVC) |
---|
159 | FIND_PACKAGE(Boost 1.34 REQUIRED thread filesystem) |
---|
160 | ENDIF(MSVC) |
---|
161 | # Boost 1.35 and newer also need the 'System' library |
---|
162 | IF(NOT Boost_VERSION LESS 103500) |
---|
163 | FIND_PACKAGE(Boost 1.35 REQUIRED system) |
---|
164 | ENDIF() |
---|
165 | # No auto linking, so this option is useless anyway |
---|
166 | MARK_AS_ADVANCED(Boost_LIB_DIAGNOSTIC_DEFINITIONS) |
---|
167 | |
---|
168 | ####### Static/Dynamic linking options ########## |
---|
169 | |
---|
170 | # On Windows dynamically linked libraries need some special treatment |
---|
171 | # You may want to edit these settings if you provide your own libraries |
---|
172 | # Note: Default option in the libraries vary, but our default option is dynamic |
---|
173 | IF(WIN32) |
---|
174 | OPTION(LINK_BOOST_DYNAMIC "Link Boost dynamically on Windows" TRUE) |
---|
175 | OPTION(LINK_CEGUI_DYNAMIC "Link CEGUI dynamicylly on Windows" TRUE) |
---|
176 | OPTION(LINK_ENET_DYNAMIC "Link ENet dynamically on Windows" TRUE) |
---|
177 | OPTION(LINK_OGRE_DYNAMIC "Link OGRE dynamically on Windows" TRUE) |
---|
178 | OPTION(LINK_TCL_DYNAMIC "Link TCL dynamically on Windows" TRUE) |
---|
179 | OPTION(LINK_ZLIB_DYNAMIC "Link ZLib dynamically on Windows" TRUE) |
---|
180 | COMPARE_VERSION_STRINGS("${LUA_VERSION}" "5.1" _version_comparison) |
---|
181 | IF(_version_comparison LESS 0) |
---|
182 | OPTION(LINK_LUA_DYNAMIC "Link Lua dynamically on Windows" FALSE) |
---|
183 | ELSE(_version_comparison LESS 0) |
---|
184 | OPTION(LINK_LUA_DYNAMIC "Link Lua dynamically on Windows" TRUE) |
---|
185 | ENDIF(_version_comparison LESS 0) |
---|
186 | |
---|
187 | IF(DEPENDENCY_PACKAGE_ENABLE) |
---|
188 | MARK_AS_ADVANCED( |
---|
189 | LINK_BOOST_DYNAMIC LINK_CEGUI_DYNAMIC LINK_ENET_DYNAMIC |
---|
190 | LINK_OGRE_DYNAMIC LINK_TCL_DYNAMIC LINK_ZLIB_DYNAMIC |
---|
191 | LINK_LUA_DYNAMIC |
---|
192 | ) |
---|
193 | ENDIF() |
---|
194 | ENDIF(WIN32) |
---|