Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/buildsystem2/cmake/LibraryConfig.cmake @ 2644

Last change on this file since 2644 was 2644, checked in by rgrieder, 15 years ago
  • Installation instructions for the config files (tcl scripts and ini files). This is temporary until we have config directory.
  • On windows, all DLLs from a precompiled package get installed too
  • added media folder with a CMakeLists.txt
  • media files get installed to media/ (Windows) or to /share/orxonox (Unix)
  • Property svn:eol-style set to native
File size: 7.6 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############## Platform Scripts #################
32
33# On Windows using a package causes way less problems
34SET(_option_msg "Set this to true to use precompiled dependecy archives")
35IF(WIN32)
36  OPTION(USE_DEPENDENCY_PACKAGE "${_option_msg}" ON)
37ELSE(WIN32)
38  OPTION(USE_DEPENDENCY_PACKAGE "${_option_msg}" FALSE)
39ENDIF(WIN32)
40
41# Scripts for specific library and CMake config
42INCLUDE(LibraryConfigTardis)
43INCLUDE(LibraryConfigApple)
44
45IF(USE_DEPENDENCY_PACKAGE)
46  IF(EXISTS ${CMAKE_SOURCE_DIR}/dependencies/include)
47    SET(DEPENDENCY_DIR "${CMAKE_SOURCE_DIR}/dependencies" CACHE PATH "")
48  ELSEIF(EXISTS ${CMAKE_SOURCE_DIR}/../dependencies/include)
49    SET(DEPENDENCY_DIR "${CMAKE_SOURCE_DIR}/../dependencies" CACHE PATH "")
50  ELSEIF(EXISTS ${CMAKE_SOURCE_DIR}/../lib_dist/dependencies/include)
51    SET(DEPENDENCY_DIR "${CMAKE_SOURCE_DIR}/../lib_dist/dependencies" CACHE PATH "")
52  ELSE()
53    MESSAGE(STATUS "Warning: Could not find dependency directory."
54                   "Disable LIBRARY_USE_PACKAGE if you have none intalled.")
55  ENDIF()
56  IF(DEPENDENCY_DIR)
57    FILE(GLOB _package_config_files dependencies/PackageConfig*.cmake)
58    FOREACH(_file ${_package_config_files})
59      INCLUDE(${_file})
60    ENDFOREACH(_file)
61  ENDIF()
62
63  # On Windows, DLLs have to be in the executable folder
64  IF(WIN32)
65    # When installing a debug version, we really can't know which libraries
66    # are used in released mode because there might be deps of deps.
67    INSTALL(DIRECTORY ${DEP_BINARY_DIR}/ DESTINATION bin CONFIGURATIONS Debug)
68
69    # Try to filter out all the debug libraries. If the regex doesn't do the
70    # job anymore, simply adjust it.
71    FILE(GLOB _dependencies_all "${DEP_BINARY_DIR}/*")
72    FOREACH(_dep ${_dependencies_all})
73      IF(NOT _dep MATCHES "_[Dd]\\.[a-zA-Z0-9+-]+$|-mt-gd-|^.*\\.pdb$")
74        LIST(APPEND _dependencies_release "${_dep}")
75      ENDIF()
76    ENDFOREACH(_dep)
77    INSTALL(FILES ${_dependencies_release} DESTINATION bin
78            CONFIGURATIONS Release RelWithDebInfo MinSizeRel)
79  ENDIF(WIN32)
80ENDIF(USE_DEPENDENCY_PACKAGE)
81
82# User script
83SET(LIBRARY_CONFIG_USER_SCRIPT "" CACHE FILEPATH
84    "Specify a CMake script if you wish to write your own library path config.
85     See LibraryConfigTardis.cmake or LibraryConfigMinGW.cmake for examples.")
86IF(LIBRARY_CONFIG_USER_SCRIPT)
87  IF(EXISTS ${CMAKE_MODULE_PATH}/${LIBRARY_CONFIG_USER_SCRIPT}.cmake)
88    INCLUDE(${LIBRARY_CONFIG_USER_SCRIPT})
89  ELSEIF(EXISTS ${LIBRARY_CONFIG_USER_SCRIPT})
90    INCLUDE(${LIBRARY_CONFIG_USER_SCRIPT})
91  ELSEIF(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
100FIND_PACKAGE(OGRE  1.4 EXACT REQUIRED)
101FIND_PACKAGE(ENet  1.1       REQUIRED)
102FIND_PACKAGE(Ogg             REQUIRED)
103FIND_PACKAGE(Vorbis          REQUIRED)
104FIND_PACKAGE(ALUT            REQUIRED)
105FIND_PACKAGE(ZLIB            REQUIRED)
106IF(WIN32)
107  FIND_PACKAGE(DirectX       REQUIRED)
108ENDIF(WIN32)
109
110##### CEGUI #####
111# We make use of the CEGUI script module called CEGUILua.
112# However there is a small issue with that: We use Tolua, a C++ binding
113# generator ourselves. And we also have to use our bindings in the same
114# lua state is CEGUILua's. Unfortunately this implies that both lua runtime
115# version are equal or else you get segmentation faults.
116# In order to match the Lua versions we decided to ship CEGUILua in our
117# repository, mainly because there is no way to determine which version of
118# Lua CEGUILua was linked against (you'd have to specify yourself) and secondly
119# because we can then choose the Lua version. Future plans might involve only
120# accepting Lua 5.1.
121
122# Insert all internally supported CEGUILua versions here
123SET(CEGUILUA_INTERNAL_SUPPORT 0.5.0 0.6.0 0.6.1 0.6.2)
124OPTION(CEGUILUA_USE_EXTERNAL_LIBRARY "Force the use of external CEGUILua library" OFF)
125FIND_PACKAGE(CEGUI 0.5 REQUIRED)
126
127##### Lua #####
128IF(CEGUILUA_USE_EXTERNAL_LIBRARY)
129  COMPARE_VERSION_STRINGS(${CEGUI_VERSION} "0.6" _version_comparison)
130  IF(version_comparison LESS 0)
131    SET(LUA_VERSION_REQUEST 5.0)
132  ELSE()
133    SET(LUA_VERSION_REQUEST 5.1)
134  ENDIF()
135ELSE()
136  SET(LUA_VERSION_REQUEST 5)
137ENDIF()
138FIND_PACKAGE(Lua ${LUA_VERSION_REQUEST} EXACT REQUIRED)
139
140##### OpenAL #####
141FIND_PACKAGE(OpenAL REQUIRED)
142# Also use parent include dir (without AL/) for ALUT
143IF(OPENAL_INCLUDE_DIR MATCHES "/AL$")
144  GET_FILENAME_COMPONENT(ALT_OPENAL_INCLUDE_DIR ${OPENAL_INCLUDE_DIR} PATH)
145ENDIF()
146SET(OPENAL_INCLUDE_DIRS ${OPENAL_INCLUDE_DIR} ${ALT_OPENAL_INCLUDE_DIR})
147# Notfiy user
148FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenAL DEFAULT_MSG OPENAL_LIBRARY OPENAL_INCLUDE_DIR)
149# Hide variables created by the script
150MARK_AS_ADVANCED(OPENAL_INCLUDE_DIR OPENAL_LIBRARY)
151
152##### Tcl #####
153# We only require Tcl, so avoid confusing user about other Tcl stuff by
154# applying a little workaround
155SET(Tclsh_FIND_QUIETLY TRUE)
156FIND_PACKAGE(TCL 8.4 REQUIRED QUIET)
157# Display messages separately
158SET(TCL_FIND_QUIETLY FALSE)
159FIND_PACKAGE_HANDLE_STANDARD_ARGS(TCL DEFAULT_MSG TCL_LIBRARY TCL_INCLUDE_PATH)
160
161##### Boost #####
162# Expand the next statement if newer boost versions than 1.36.1 are released
163SET(Boost_ADDITIONAL_VERSIONS 1.37 1.37.0)
164# MSVC seems to be the only compiler requiring system and date_time
165IF(MSVC)
166  FIND_PACKAGE(Boost 1.34 REQUIRED thread filesystem date_time system)
167ELSE(MSVC)
168  FIND_PACKAGE(Boost 1.34 REQUIRED thread filesystem system)
169ENDIF(MSVC)
170
171####### Static/Dynamic linking options ##########
172
173# On Windows dynamically linked libraries need some special treatment
174# You may want to edit these settings if you provide your own libraries
175# Note: Default option in the libraries vary, but our default option is dynamic
176IF(WIN32)
177  OPTION(LINK_BOOST_DYNAMIC "Link Boost dynamically on Windows" TRUE)
178  OPTION(LINK_CEGUI_DYNAMIC "Link CEGUI dynamicylly on Windows" TRUE)
179  OPTION(LINK_ENET_DYNAMIC  "Link ENet dynamically on Windows" TRUE)
180  OPTION(LINK_OGRE_DYNAMIC  "Link OGRE dynamically on Windows" TRUE)
181  OPTION(LINK_TCL_DYNAMIC   "Link TCL dynamically on Windows" TRUE)
182  OPTION(LINK_ZLIB_DYNAMIC  "Link ZLib dynamically on Windows" TRUE)
183  COMPARE_VERSION_STRINGS("${LUA_VERSION}" "5.1" _version_comparison)
184  IF(_version_comparison LESS 0)
185    OPTION(LINK_LUA_DYNAMIC "Link Lua dynamically on Windows" FALSE)
186  ELSE(_version_comparison LESS 0)
187    OPTION(LINK_LUA_DYNAMIC "Link Lua dynamically on Windows" TRUE)
188  ENDIF(_version_comparison LESS 0)
189ENDIF(WIN32)
Note: See TracBrowser for help on using the repository browser.