Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/mac_osx/cmake/LibraryConfig.cmake @ 8016

Last change on this file since 8016 was 7682, checked in by youngk, 14 years ago

Changed handling of the dependency package and increased consistence for options.

  • Property svn:eol-style set to native
File size: 8.5 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(WIN32)
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 OR APPLE)
43  OPTION(DEPENDENCY_PACKAGE_ENABLE "${_option_msg}" ON)
44ELSE()
45  OPTION(DEPENDENCY_PACKAGE_ENABLE "${_option_msg}" FALSE)
46ENDIF()
47
48# Scripts for specific library and CMake config
49INCLUDE(LibraryConfigTardis)
50#INCLUDE(LibraryConfigOSX)
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 ABSOLUTE)
55  IF(MINGW)
56    SET(_compiler_prefix mingw)
57  ELSEIF(MSVC80)
58    SET(_compiler_prefix msvc8)
59  ELSEIF(MSVC90)
60    SET(_compiler_prefix msvc9)
61  ENDIF()
62  FIND_PATH(DEPENDENCY_PACKAGE_DIR
63    NAMES version.txt
64    PATHS
65      ${CMAKE_SOURCE_DIR}/dependencies
66      ${_dep_dir_1}
67      ${_dep_dir_2}
68    PATH_SUFFIXES ${_compiler_prefix} ${_compiler_prefix}/dependencies
69    NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH
70  )
71  IF(NOT DEPENDENCY_PACKAGE_DIR)
72    MESSAGE(STATUS "Warning: Could not find dependency directory."
73                   "Disable LIBRARY_USE_PACKAGE if you have none intalled.")
74  ELSE()
75    IF(WIN32)
76      INCLUDE(PackageConfigMinGW)
77      INCLUDE(PackageConfigMSVC)
78      INCLUDE(PackageConfig) # For both msvc and mingw
79    ELSEIF(APPLE)
80      INCLUDE(PackageConfigOSX)
81    ENDIF(WIN32)
82  ENDIF()
83ENDIF(DEPENDENCY_PACKAGE_ENABLE)
84
85# User script
86SET(LIBRARY_CONFIG_USER_SCRIPT "" CACHE FILEPATH
87    "Specify a CMake script if you wish to write your own library path config.
88     See LibraryConfigTardis.cmake for an example.")
89IF(LIBRARY_CONFIG_USER_SCRIPT)
90  IF(EXISTS ${CMAKE_MODULE_PATH}/${LIBRARY_CONFIG_USER_SCRIPT})
91    INCLUDE(${CMAKE_MODULE_PATH}/${LIBRARY_CONFIG_USER_SCRIPT})
92  ENDIF()
93ENDIF(LIBRARY_CONFIG_USER_SCRIPT)
94
95
96############### Library finding #################
97# Performs the search and sets the variables    #
98
99FIND_PACKAGE(OGRE  1.4       REQUIRED)
100#FIND_PACKAGE(ENet  1.1       REQUIRED)
101FIND_PACKAGE(Ogg             REQUIRED)
102FIND_PACKAGE(Vorbis          REQUIRED)
103FIND_PACKAGE(ALUT            REQUIRED)
104FIND_PACKAGE(ZLIB            REQUIRED)
105IF(POCO_REQUIRED)
106  FIND_PACKAGE(POCO          REQUIRED)
107ENDIF()
108IF(WIN32)
109  FIND_PACKAGE(DbgHelp)
110  FIND_PACKAGE(DirectX       REQUIRED)
111ENDIF()
112
113##### CEGUI #####
114# We make use of the CEGUI script module called CEGUILua.
115# However there is a small issue with that: We use Tolua, a C++ binding
116# generator ourselves. And we also have to use our bindings in the same
117# lua state is CEGUILua's. Unfortunately this implies that both lua runtime
118# version are equal or else you get segmentation faults.
119# In order to match the Lua versions we decided to ship CEGUILua in our
120# repository, mainly because there is no way to determine which version of
121# Lua CEGUILua was linked against (you'd have to specify yourself) and secondly
122# because we can then choose the Lua version. Future plans might involve only
123# accepting Lua 5.1.
124
125# Insert all internally supported CEGUILua versions here
126SET(CEGUILUA_INTERNAL_SUPPORT 0.5.0 0.6.0 0.6.1 0.6.2)
127OPTION(CEGUILUA_USE_EXTERNAL_LIBRARY "Force the use of external CEGUILua library" OFF)
128FIND_PACKAGE(CEGUI 0.5 REQUIRED)
129
130##### Lua #####
131IF(CEGUILUA_USE_EXTERNAL_LIBRARY)
132  COMPARE_VERSION_STRINGS(${CEGUI_VERSION} "0.6" _version_comparison)
133  IF(version_comparison LESS 0)
134    SET(LUA_VERSION_REQUEST 5.0)
135  ELSE()
136    SET(LUA_VERSION_REQUEST 5.1)
137  ENDIF()
138ELSE()
139  SET(LUA_VERSION_REQUEST 5)
140ENDIF()
141FIND_PACKAGE(Lua ${LUA_VERSION_REQUEST} EXACT REQUIRED)
142
143##### OpenAL #####
144FIND_PACKAGE(OpenAL REQUIRED)
145# Also use parent include dir (without AL/) for ALUT
146IF(OPENAL_INCLUDE_DIR MATCHES "/AL$")
147  GET_FILENAME_COMPONENT(ALT_OPENAL_INCLUDE_DIR ${OPENAL_INCLUDE_DIR} PATH)
148ENDIF()
149SET(OPENAL_INCLUDE_DIRS ${OPENAL_INCLUDE_DIR} ${ALT_OPENAL_INCLUDE_DIR})
150# Notfiy user
151FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenAL DEFAULT_MSG OPENAL_LIBRARY OPENAL_INCLUDE_DIR)
152# Hide variables created by the script
153MARK_AS_ADVANCED(OPENAL_INCLUDE_DIR OPENAL_LIBRARY)
154
155##### Tcl #####
156# We only require Tcl, so avoid confusing user about other Tcl stuff by
157# applying a little workaround
158SET(Tclsh_FIND_QUIETLY TRUE)
159FIND_PACKAGE(TCL QUIET)
160# Display messages separately
161SET(TCL_FIND_QUIETLY FALSE)
162FIND_PACKAGE_HANDLE_STANDARD_ARGS(TCL DEFAULT_MSG TCL_LIBRARY TCL_INCLUDE_PATH)
163
164##### Boost #####
165# Expand the next statement if newer boost versions than 1.36.1 are released
166SET(Boost_ADDITIONAL_VERSIONS 1.37 1.37.0 1.38 1.38.0 1.39 1.39.0 1.40 1.40.0
167                              1.41 1.41.0 1.42 1.42.0 1.43 1.43.0 1.44 1.44.0)
168IF( NOT TARDIS )
169  FIND_PACKAGE(Boost 1.35 REQUIRED thread filesystem system date_time)
170ENDIF()
171# No auto linking, so this option is useless anyway
172MARK_AS_ADVANCED(Boost_LIB_DIAGNOSTIC_DEFINITIONS)
173# Complain about incompatibilities
174IF(GCC_VERSION)
175  COMPARE_VERSION_STRINGS("${GCC_VERSION}" "4.4.0" _compare_result)
176  IF(NOT _compare_result LESS 0)
177    IF(${Boost_VERSION} LESS 103700)
178      MESSAGE(STATUS "Warning: Boost versions earlier than 1.37 may not compile with GCC 4.4 or later!")
179    ENDIF()
180  ENDIF()
181ENDIF()
182
183
184####### Static/Dynamic linking options ##########
185
186# On Windows dynamically linked libraries need some special treatment
187# You may want to edit these settings if you provide your own libraries
188# Note: Default option in the libraries vary, but our default option is dynamic
189IF(WIN32)
190  OPTION(LINK_BOOST_DYNAMIC "Link Boost dynamically on Windows" TRUE)
191  OPTION(LINK_CEGUI_DYNAMIC "Link CEGUI dynamicylly on Windows" TRUE)
192  #OPTION(LINK_ENET_DYNAMIC  "Link ENet dynamically on Windows" TRUE)
193  OPTION(LINK_OGRE_DYNAMIC  "Link OGRE dynamically on Windows" TRUE)
194  OPTION(LINK_TCL_DYNAMIC   "Link TCL dynamically on Windows" TRUE)
195  OPTION(LINK_ZLIB_DYNAMIC  "Link ZLib dynamically on Windows" TRUE)
196  COMPARE_VERSION_STRINGS("${LUA_VERSION}" "5.1" _version_comparison)
197  IF(_version_comparison LESS 0)
198    OPTION(LINK_LUA_DYNAMIC "Link Lua dynamically on Windows" FALSE)
199  ELSE(_version_comparison LESS 0)
200    OPTION(LINK_LUA_DYNAMIC "Link Lua dynamically on Windows" TRUE)
201  ENDIF(_version_comparison LESS 0)
202
203  IF(DEPENDENCY_PACKAGE_ENABLE)
204    MARK_AS_ADVANCED(
205      LINK_BOOST_DYNAMIC LINK_CEGUI_DYNAMIC #LINK_ENET_DYNAMIC
206      LINK_OGRE_DYNAMIC  LINK_TCL_DYNAMIC   LINK_ZLIB_DYNAMIC
207      LINK_LUA_DYNAMIC
208    )
209  ENDIF()
210ENDIF(WIN32)
211
212
213################# OGRE Plugins ##################
214
215# More plugins: Plugin_BSPSceneManager, Plugin_OctreeSceneManager
216SET(OGRE_PLUGINS_INT Plugin_ParticleFX)
217IF(WIN32)
218  # CG program manager is probably DirectX related (not available under unix)
219  LIST(APPEND OGRE_PLUGINS_INT Plugin_CgProgramManager)
220ENDIF(WIN32)
221SET(OGRE_PLUGINS ${OGRE_PLUGINS_INT} CACHE STRING
222   "Specify which OGRE plugins to load. Existance check is performed.")
223
224# Check the plugins and determine the plugin folder
225# You can give a hint by setting the environment variable ENV{OGRE_PLUGIN_DIR}
226INCLUDE(CheckOGREPlugins)
227CHECK_OGRE_PLUGINS(${OGRE_PLUGINS})
228
Note: See TracBrowser for help on using the repository browser.