Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 2645 was 2645, checked in by rgrieder, 15 years ago
  • Bugfix: CMake searches the install path per default when finding libraries. That means having Orxonox built my MSVC already installed will screw your mingw compilation.

—> Removed install path from the search paths for Windows

  • Bugfix: Media path default value was still pointing to the development media directory.

Tested mingw and msvc 2008 binaries on another windows xp box (no installed depdencies, no visual studio, no mingw installed, no DirectX SDK, just DX9.0c). It runs without initial orxonox.ini, as should be the case anyway.
Now its time to test this on Linux, though there will be files written to usr/bin

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