Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

Removed support for Boost versions less than 1.40.

  • Property svn:eol-style set to native
File size: 7.2 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
51IF(DEPENDENCY_PACKAGE_ENABLE)
52  GET_FILENAME_COMPONENT(_dep_dir_1 ${CMAKE_SOURCE_DIR}/../dependencies ABSOLUTE)
53  GET_FILENAME_COMPONENT(_dep_dir_2 ${CMAKE_SOURCE_DIR}/../lib_dist ABSOLUTE)
54  IF(MINGW)
55    SET(_compiler_prefix mingw)
56  ELSEIF(MSVC80)
57    SET(_compiler_prefix msvc8)
58  ELSEIF(MSVC90)
59    SET(_compiler_prefix msvc9)
60  ELSEIF(MSVC10)
61    SET(_compiler_prefix msvc10)
62  ENDIF()
63  FIND_PATH(DEPENDENCY_PACKAGE_DIR
64    NAMES version.txt
65    PATHS
66      ${CMAKE_SOURCE_DIR}/dependencies
67      ${_dep_dir_1}
68      ${_dep_dir_2}
69    PATH_SUFFIXES ${_compiler_prefix} ${_compiler_prefix}/dependencies
70    NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH
71  )
72  IF(NOT DEPENDENCY_PACKAGE_DIR)
73    MESSAGE(STATUS "Warning: Could not find dependency directory."
74                   "Disable LIBRARY_USE_PACKAGE if you have none intalled.")
75  ELSE()
76    IF(WIN32)
77      INCLUDE(PackageConfigMinGW)
78      INCLUDE(PackageConfigMSVC)
79      INCLUDE(PackageConfig) # For both msvc and mingw
80    ELSEIF(APPLE)
81      INCLUDE(PackageConfigOSX)
82    ENDIF(WIN32)
83  ENDIF()
84ENDIF(DEPENDENCY_PACKAGE_ENABLE)
85
86# User script
87SET(LIBRARY_CONFIG_USER_SCRIPT "" CACHE FILEPATH
88    "Specify a CMake script if you wish to write your own library path config.
89     See LibraryConfigTardis.cmake for an example.")
90IF(LIBRARY_CONFIG_USER_SCRIPT)
91  IF(EXISTS ${CMAKE_MODULE_PATH}/${LIBRARY_CONFIG_USER_SCRIPT})
92    INCLUDE(${CMAKE_MODULE_PATH}/${LIBRARY_CONFIG_USER_SCRIPT})
93  ENDIF()
94ENDIF(LIBRARY_CONFIG_USER_SCRIPT)
95
96
97############### Library finding #################
98# Performs the search and sets the variables    #
99
100#FIND_PACKAGE(ENet     1.2    REQUIRED)
101FIND_PACKAGE(CEGUI    0.6    REQUIRED)
102FIND_PACKAGE(Lua5.1          REQUIRED)
103FIND_PACKAGE(Ogg             REQUIRED)
104FIND_PACKAGE(Vorbis          REQUIRED)
105FIND_PACKAGE(ALUT            REQUIRED)
106FIND_PACKAGE(ZLIB            REQUIRED)
107
108IF(WIN32)
109  FIND_PACKAGE(DbgHelp)
110  FIND_PACKAGE(DirectX       REQUIRED)
111ENDIF()
112
113
114##### OpenAL #####
115FIND_PACKAGE(OpenAL REQUIRED)
116# Also use parent include dir (without AL/) for ALUT
117IF(OPENAL_INCLUDE_DIR MATCHES "/AL$")
118  GET_FILENAME_COMPONENT(ALT_OPENAL_INCLUDE_DIR ${OPENAL_INCLUDE_DIR} PATH)
119ENDIF()
120SET(OPENAL_INCLUDE_DIRS ${OPENAL_INCLUDE_DIR} ${ALT_OPENAL_INCLUDE_DIR})
121# Notfiy user
122FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenAL DEFAULT_MSG OPENAL_LIBRARY OPENAL_INCLUDE_DIR)
123# Hide variables created by the script
124MARK_AS_ADVANCED(OPENAL_INCLUDE_DIR OPENAL_LIBRARY)
125
126##### Tcl #####
127# We only require Tcl, so avoid confusing user about other Tcl stuff by
128# applying a little workaround
129SET(Tclsh_FIND_QUIETLY TRUE)
130FIND_PACKAGE(TCL QUIET)
131# Display messages separately
132SET(TCL_FIND_QUIETLY FALSE)
133FIND_PACKAGE_HANDLE_STANDARD_ARGS(TCL DEFAULT_MSG TCL_LIBRARY TCL_INCLUDE_PATH)
134
135##### Boost #####
136# Expand the next statement if newer boost versions are released
137SET(Boost_ADDITIONAL_VERSIONS 1.40 1.40.0 1.41 1.41.0 1.42 1.42.0 1.43 1.43.0
138                              1.44 1.44.0 1.45 1.45.0 1.46 1.46.0 1.46.1)
139IF(NOT TARDIS)
140  FIND_PACKAGE(Boost 1.40 REQUIRED thread filesystem system date_time)
141ENDIF()
142# No auto linking, so this option is useless anyway
143MARK_AS_ADVANCED(Boost_LIB_DIAGNOSTIC_DEFINITIONS)
144
145##### OGRE #####
146FIND_PACKAGE(OGRE 1.6 REQUIRED)
147# For Ogre >= 1.7, we might need a threading library
148# Variables are either defined by dependency package config or by FindOGRE
149IF(OGRE_NEEDS_POCO)
150  FIND_PACKAGE(POCO REQUIRED)
151  # Always link against POCO too because of threading
152  SET(OGRE_LIBRARY ${OGRE_LIBRARY} ${POCO_LIBRARY})
153ELSEIF(OGRE_NEEDS_BOOST)
154  # Always link against boost too because of threading
155  SET(OGRE_LIBRARY ${OGRE_LIBRARY} ${Boost_THREAD_LIBRARY})
156ENDIF()
157
158
159####### Static/Dynamic linking options ##########
160
161# On Windows dynamically linked libraries need some special treatment
162# You may want to edit these settings if you provide your own libraries
163# Note: Default option in the libraries vary, but our default option is dynamic
164IF(WIN32)
165  OPTION(LINK_BOOST_DYNAMIC  "Link Boost dynamically on Windows" TRUE)
166  OPTION(LINK_CEGUI_DYNAMIC  "Link CEGUI dynamicylly on Windows" TRUE)
167  #OPTION(LINK_ENET_DYNAMIC   "Link ENet dynamically on Windows" TRUE)
168  OPTION(LINK_OGRE_DYNAMIC   "Link OGRE dynamically on Windows" TRUE)
169  OPTION(LINK_TCL_DYNAMIC    "Link TCL dynamically on Windows" TRUE)
170  OPTION(LINK_ZLIB_DYNAMIC   "Link ZLib dynamically on Windows" TRUE)
171  OPTION(LINK_LUA5.1_DYNAMIC "Link Lua dynamically on Windows" TRUE)
172
173  IF(DEPENDENCY_PACKAGE_ENABLE)
174    MARK_AS_ADVANCED(
175      LINK_BOOST_DYNAMIC LINK_CEGUI_DYNAMIC #LINK_ENET_DYNAMIC
176      LINK_OGRE_DYNAMIC  LINK_TCL_DYNAMIC   LINK_ZLIB_DYNAMIC
177      LINK_LUA5.1_DYNAMIC
178    )
179  ENDIF()
180ENDIF(WIN32)
181
182
183################# OGRE Plugins ##################
184
185# More plugins: Plugin_BSPSceneManager, Plugin_OctreeSceneManager
186SET(OGRE_PLUGINS_INT Plugin_ParticleFX)
187IF(WIN32)
188  # CG program manager is probably DirectX related (not available under unix)
189  LIST(APPEND OGRE_PLUGINS_INT Plugin_CgProgramManager)
190ENDIF(WIN32)
191SET(OGRE_PLUGINS ${OGRE_PLUGINS_INT} CACHE STRING
192   "Specify which OGRE plugins to load. Existance check is performed.")
193
194# Check the plugins and determine the plugin folder
195# You can give a hint by setting the environment variable ENV{OGRE_PLUGIN_DIR}
196INCLUDE(CheckOGREPlugins)
197CHECK_OGRE_PLUGINS(${OGRE_PLUGINS})
198
Note: See TracBrowser for help on using the repository browser.