Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/kicklib/cmake/LibraryConfig.cmake @ 8071

Last change on this file since 8071 was 8071, checked in by rgrieder, 13 years ago

Merged ois_update branch (before it was renamed to mac_osx) into kicklib branch.

  • Property svn:eol-style set to native
File size: 7.7 KB
RevLine 
[2626]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 #
[6417]27
[2618]28INCLUDE(CompareVersionStrings)
29INCLUDE(FindPackageHandleStandardArgs)
30
[2696]31# Prevent CMake from finding libraries in the installation folder on Windows.
[2645]32# There might already be an installation from another compiler
[5695]33IF(WIN32)
[2696]34  LIST(REMOVE_ITEM CMAKE_SYSTEM_PREFIX_PATH  "${CMAKE_INSTALL_PREFIX}")
35  LIST(REMOVE_ITEM CMAKE_SYSTEM_LIBRARY_PATH "${CMAKE_INSTALL_PREFIX}/bin")
36ENDIF()
[2645]37
[2631]38############## Platform Scripts #################
[2618]39
[2631]40# On Windows using a package causes way less problems
41SET(_option_msg "Set this to true to use precompiled dependecy archives")
[8071]42IF(WIN32 OR APPLE)
[2673]43  OPTION(DEPENDENCY_PACKAGE_ENABLE "${_option_msg}" ON)
[8071]44ELSE()
[2673]45  OPTION(DEPENDENCY_PACKAGE_ENABLE "${_option_msg}" FALSE)
[8071]46ENDIF()
[2618]47
48# Scripts for specific library and CMake config
49INCLUDE(LibraryConfigTardis)
[8071]50#INCLUDE(LibraryConfigOSX)
[1505]51
[2673]52IF(DEPENDENCY_PACKAGE_ENABLE)
53  GET_FILENAME_COMPONENT(_dep_dir_1 ${CMAKE_SOURCE_DIR}/../dependencies ABSOLUTE)
[7225]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)
[8057]61  ELSEIF(MSVC100)
62    SET(_compiler_prefix msvc10)
[7225]63  ENDIF()
[2673]64  FIND_PATH(DEPENDENCY_PACKAGE_DIR
[7225]65    NAMES version.txt
[2651]66    PATHS
67      ${CMAKE_SOURCE_DIR}/dependencies
[2673]68      ${_dep_dir_1}
69      ${_dep_dir_2}
[7225]70    PATH_SUFFIXES ${_compiler_prefix} ${_compiler_prefix}/dependencies
[2711]71    NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH
[2651]72  )
[2673]73  IF(NOT DEPENDENCY_PACKAGE_DIR)
[2631]74    MESSAGE(STATUS "Warning: Could not find dependency directory."
75                   "Disable LIBRARY_USE_PACKAGE if you have none intalled.")
[2651]76  ELSE()
[8071]77    IF(WIN32)
78      INCLUDE(PackageConfigMinGW)
79      INCLUDE(PackageConfigMSVC)
80      INCLUDE(PackageConfig) # For both msvc and mingw
81    ELSEIF(APPLE)
82      INCLUDE(PackageConfigOSX)
83    ENDIF(WIN32)
[3196]84  ENDIF()
[2673]85ENDIF(DEPENDENCY_PACKAGE_ENABLE)
[2631]86
[5781]87# User script
88SET(LIBRARY_CONFIG_USER_SCRIPT "" CACHE FILEPATH
89    "Specify a CMake script if you wish to write your own library path config.
90     See LibraryConfigTardis.cmake for an example.")
91IF(LIBRARY_CONFIG_USER_SCRIPT)
92  IF(EXISTS ${CMAKE_MODULE_PATH}/${LIBRARY_CONFIG_USER_SCRIPT})
93    INCLUDE(${CMAKE_MODULE_PATH}/${LIBRARY_CONFIG_USER_SCRIPT})
94  ENDIF()
95ENDIF(LIBRARY_CONFIG_USER_SCRIPT)
96
97
[2616]98############### Library finding #################
99# Performs the search and sets the variables    #
[2579]100
[7948]101FIND_PACKAGE(OGRE     1.6    REQUIRED)
[7943]102#FIND_PACKAGE(ENet     1.1    REQUIRED)
[7944]103FIND_PACKAGE(Lua5.1          REQUIRED)
[5781]104FIND_PACKAGE(Ogg             REQUIRED)
105FIND_PACKAGE(Vorbis          REQUIRED)
106FIND_PACKAGE(ALUT            REQUIRED)
107FIND_PACKAGE(ZLIB            REQUIRED)
[7224]108IF(POCO_REQUIRED)
109  FIND_PACKAGE(POCO          REQUIRED)
[7956]110  # Always link against POCO too because of threading
111  SET(OGRE_LIBRARY ${OGRE_LIBRARY} ${POCO_LIBRARY})
[7224]112ENDIF()
[5781]113IF(WIN32)
[7449]114  FIND_PACKAGE(DbgHelp)
[5781]115  FIND_PACKAGE(DirectX       REQUIRED)
[7224]116ENDIF()
[5781]117
118##### CEGUI #####
119# We make use of the CEGUI script module called CEGUILua.
[7941]120# However there is a small issue with that: Both CEGUILua and Orxonox use
121# Lua library functions on the same objects. And it turns out that in this case
122# the linked library must be EXACTLY the same.
[7943]123# Since Lua v5.1 has been out for a long while, this does not seem to be a
124# problem anymore, at least as long as Lua 5.2 is not released.
[7947]125FIND_PACKAGE(CEGUI 0.6 REQUIRED)
[5781]126
127##### OpenAL #####
128FIND_PACKAGE(OpenAL REQUIRED)
129# Also use parent include dir (without AL/) for ALUT
130IF(OPENAL_INCLUDE_DIR MATCHES "/AL$")
131  GET_FILENAME_COMPONENT(ALT_OPENAL_INCLUDE_DIR ${OPENAL_INCLUDE_DIR} PATH)
132ENDIF()
133SET(OPENAL_INCLUDE_DIRS ${OPENAL_INCLUDE_DIR} ${ALT_OPENAL_INCLUDE_DIR})
134# Notfiy user
135FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenAL DEFAULT_MSG OPENAL_LIBRARY OPENAL_INCLUDE_DIR)
136# Hide variables created by the script
137MARK_AS_ADVANCED(OPENAL_INCLUDE_DIR OPENAL_LIBRARY)
138
139##### Tcl #####
140# We only require Tcl, so avoid confusing user about other Tcl stuff by
141# applying a little workaround
142SET(Tclsh_FIND_QUIETLY TRUE)
143FIND_PACKAGE(TCL QUIET)
144# Display messages separately
145SET(TCL_FIND_QUIETLY FALSE)
146FIND_PACKAGE_HANDLE_STANDARD_ARGS(TCL DEFAULT_MSG TCL_LIBRARY TCL_INCLUDE_PATH)
147
[2616]148##### Boost #####
[8066]149# Expand the next statement if newer boost versions are released
[7237]150SET(Boost_ADDITIONAL_VERSIONS 1.37 1.37.0 1.38 1.38.0 1.39 1.39.0 1.40 1.40.0
[8066]151                              1.41 1.41.0 1.42 1.42.0 1.43 1.43.0 1.44 1.44.0
152                              1.45 1.45.0 1.46 1.46.0 1.46.1)
[6461]153IF( NOT TARDIS )
154  FIND_PACKAGE(Boost 1.35 REQUIRED thread filesystem system date_time)
155ENDIF()
[2673]156# No auto linking, so this option is useless anyway
157MARK_AS_ADVANCED(Boost_LIB_DIAGNOSTIC_DEFINITIONS)
[8071]158# Complain about incompatibilities
159IF(GCC_VERSION)
160  COMPARE_VERSION_STRINGS("${GCC_VERSION}" "4.4.0" _compare_result)
161  IF(NOT _compare_result LESS 0)
162    IF(${Boost_VERSION} LESS 103700)
163      MESSAGE(STATUS "Warning: Boost versions earlier than 1.37 may not compile with GCC 4.4 or later!")
164    ENDIF()
165  ENDIF()
166ENDIF()
[2618]167
[3304]168
[2618]169####### Static/Dynamic linking options ##########
170
171# On Windows dynamically linked libraries need some special treatment
172# You may want to edit these settings if you provide your own libraries
173# Note: Default option in the libraries vary, but our default option is dynamic
174IF(WIN32)
[7944]175  OPTION(LINK_BOOST_DYNAMIC  "Link Boost dynamically on Windows" TRUE)
176  OPTION(LINK_CEGUI_DYNAMIC  "Link CEGUI dynamicylly on Windows" TRUE)
177  #OPTION(LINK_ENET_DYNAMIC   "Link ENet dynamically on Windows" TRUE)
178  OPTION(LINK_OGRE_DYNAMIC   "Link OGRE dynamically on Windows" TRUE)
179  OPTION(LINK_TCL_DYNAMIC    "Link TCL dynamically on Windows" TRUE)
180  OPTION(LINK_ZLIB_DYNAMIC   "Link ZLib dynamically on Windows" TRUE)
181  OPTION(LINK_LUA5.1_DYNAMIC "Link Lua dynamically on Windows" TRUE)
[2925]182
183  IF(DEPENDENCY_PACKAGE_ENABLE)
184    MARK_AS_ADVANCED(
[7459]185      LINK_BOOST_DYNAMIC LINK_CEGUI_DYNAMIC #LINK_ENET_DYNAMIC
[5781]186      LINK_OGRE_DYNAMIC  LINK_TCL_DYNAMIC   LINK_ZLIB_DYNAMIC
[7944]187      LINK_LUA5.1_DYNAMIC
[2925]188    )
189  ENDIF()
[2618]190ENDIF(WIN32)
[5781]191
192
193################# OGRE Plugins ##################
194
195# More plugins: Plugin_BSPSceneManager, Plugin_OctreeSceneManager
[7243]196SET(OGRE_PLUGINS_INT Plugin_ParticleFX)
[5781]197IF(WIN32)
198  # CG program manager is probably DirectX related (not available under unix)
199  LIST(APPEND OGRE_PLUGINS_INT Plugin_CgProgramManager)
200ENDIF(WIN32)
201SET(OGRE_PLUGINS ${OGRE_PLUGINS_INT} CACHE STRING
202   "Specify which OGRE plugins to load. Existance check is performed.")
203
204# Check the plugins and determine the plugin folder
205# You can give a hint by setting the environment variable ENV{OGRE_PLUGIN_DIR}
206INCLUDE(CheckOGREPlugins)
207CHECK_OGRE_PLUGINS(${OGRE_PLUGINS})
208
Note: See TracBrowser for help on using the repository browser.