Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 2624 was 2624, checked in by rgrieder, 15 years ago

Replaced most of the ELSE(…) and ENDIF(…) with ELSE() and ENDIF(). Kept the shorter and the spreaded ones for better clarity since that's what it originally was thought for. But I can really pollute the code when having long conditions and lots of IFs.

  • Property svn:eol-style set to native
File size: 5.6 KB
Line 
1INCLUDE(CompareVersionStrings)
2INCLUDE(FindPackageHandleStandardArgs)
3
4################ Misc Options ###################
5
6OPTION(LIBRARY_USE_PACKAGE_IF_SUPPORTED
7       "When set to false CMake will only look in the standard paths for libraries" ON)
8
9
10############## Platform Scripts #################
11
12# Scripts for specific library and CMake config
13INCLUDE(LibraryConfigTardis)
14INCLUDE(LibraryConfigApple)
15INCLUDE(LibraryConfigMSVC)
16INCLUDE(LibraryConfigMinGW)
17
18# User script
19SET(LIBRARY_CONFIG_USER_SCRIPT "" CACHE FILEPATH
20    "Specify a CMake script if you wish to write your own library path config.
21     See LibraryConfigTardis.cmake or LibraryConfigMinGW.cmake for examples.")
22IF(LIBRARY_CONFIG_USER_SCRIPT)
23  IF(EXISTS ${CMAKE_MODULE_PATH}/${LIBRARY_CONFIG_USER_SCRIPT}.cmake)
24    INCLUDE(${LIBRARY_CONFIG_USER_SCRIPT})
25  ELSEIF(EXISTS ${LIBRARY_CONFIG_USER_SCRIPT})
26    INCLUDE(${LIBRARY_CONFIG_USER_SCRIPT})
27  ELSEIF(EXISTS ${CMAKE_MODULE_PATH}/${LIBRARY_CONFIG_USER_SCRIPT})
28    INCLUDE(${CMAKE_MODULE_PATH}/${LIBRARY_CONFIG_USER_SCRIPT})
29  ENDIF()
30ENDIF(LIBRARY_CONFIG_USER_SCRIPT)
31
32
33############### Library finding #################
34# Performs the search and sets the variables    #
35
36FIND_PACKAGE(OGRE  1.4 EXACT REQUIRED)
37FIND_PACKAGE(ENet  1.1       REQUIRED)
38FIND_PACKAGE(Ogg             REQUIRED)
39FIND_PACKAGE(Vorbis          REQUIRED)
40FIND_PACKAGE(ALUT            REQUIRED)
41FIND_PACKAGE(ZLIB            REQUIRED)
42IF(WIN32)
43  FIND_PACKAGE(DirectX       REQUIRED)
44ENDIF(WIN32)
45
46##### CEGUI #####
47# We make use of the CEGUI script module called CEGUILua.
48# However there is a small issue with that: We use Tolua, a C++ binding
49# generator ourselves. And we also have to use our bindings in the same
50# lua state is CEGUILua's. Unfortunately this implies that both lua runtime
51# version are equal or else you get segmentation faults.
52# In order to match the Lua versions we decided to ship CEGUILua in our
53# repository, mainly because there is no way to determine which version of
54# Lua CEGUILua was linked against (you'd have to specify yourself) and secondly
55# because we can then choose the Lua version. Future plans might involve only
56# accepting Lua 5.1.
57
58# Insert all internally supported CEGUILua versions here
59SET(CEGUILUA_INTERNAL_SUPPORT 0.5.0 0.6.0 0.6.1 0.6.2)
60OPTION(CEGUILUA_USE_EXTERNAL_LIBRARY "Force the use of external CEGUILua library" OFF)
61FIND_PACKAGE(CEGUI 0.5 REQUIRED)
62
63##### Lua #####
64IF(CEGUILUA_USE_EXTERNAL_LIBRARY)
65  COMPARE_VERSION_STRINGS(${CEGUI_VERSION} "0.6" _version_comparison)
66  IF(version_comparison LESS 0)
67    SET(LUA_VERSION_REQUEST 5.0)
68  ELSE()
69    SET(LUA_VERSION_REQUEST 5.1)
70  ENDIF()
71ELSE()
72  SET(LUA_VERSION_REQUEST 5)
73ENDIF()
74FIND_PACKAGE(Lua ${LUA_VERSION_REQUEST} EXACT REQUIRED)
75
76##### OpenAL #####
77FIND_PACKAGE(OpenAL REQUIRED)
78# ALUT's headers include openal headers, but like <AL/al.h>, not <al.h>
79# Unfortunately this is not the case on all systems, so FindOpenAL.cmake
80# specifies the directory/AL, which now causes problems with ALUT.
81IF(DEFINED OPENAL_FOUND_FIRST_TIME)
82  SET(OPENAL_FOUND_FIRST_TIME FALSE CACHE INTERNAL "")
83ELSE()
84  SET(OPENAL_FOUND_FIRST_TIME TRUE CACHE INTERNAL "")
85  STRING(REGEX REPLACE "^(.*)/AL$" "\\1" _openal_dir_2 ${OPENAL_INCLUDE_DIR})
86  IF(_openal_dir_2)
87    SET(OPENAL_INCLUDE_DIR ${OPENAL_INCLUDE_DIR} ${_openal_dir_2} CACHE STRING "" FORCE)
88  ENDIF()
89ENDIF()
90# Hide variables created by the script
91MARK_AS_ADVANCED(
92  OPENAL_INCLUDE_DIR
93  OPENAL_LIBRARY
94)
95
96##### TCL #####
97# We only require TCL, so avoid confusing user about other TCL stuff by
98# applying a little workaround
99SET(Tclsh_FIND_QUIETLY TRUE)
100FIND_PACKAGE(TCL 8.4 REQUIRED QUIET)
101# Display messages separately
102SET(TCL_FIND_QUIETLY FALSE)
103FIND_PACKAGE_HANDLE_STANDARD_ARGS(TCL DEFAULT_MSG TCL_LIBRARY TCL_INCLUDE_PATH)
104# Workaround a CMake bug that doesn't set the variables to the cache
105# Occurs at least on CMake 2.6.2 and 2.6.0 under Windows
106SET(TCL_LIBRARY ${TCL_LIBRARY} CACHE FILEPATH "")
107SET(TCL_INCLUDE_PATH ${TCL_INCLUDE_PATH} CACHE PATH "")
108
109##### Boost #####
110# Expand the next statement if newer boost versions than 1.36.1 are released
111SET(Boost_ADDITIONAL_VERSIONS 1.37 1.37.0)
112FIND_PACKAGE(Boost 1.34 REQUIRED thread filesystem)
113# With MSVC, automatic linking is performed for boost. So wee need to tell
114# the linker where to find them. Also note that when running FindBoost for the
115# first time, it will set ${Boost_LIBRARIES} to "" but afterwards to the libs.
116IF (MSVC)
117  # Little bit hacky, but Boost_LIBRARY_DIRS doesn't get set right when having
118  # debug and optimized libraries.
119  GET_FILENAME_COMPONENT(BOOST_LINK_DIR "${Boost_THREAD_LIBRARY_RELEASE}" PATH)
120  LINK_DIRECTORIES(${BOOST_LINK_DIR})
121ENDIF (MSVC)
122
123
124####### Static/Dynamic linking options ##########
125
126# On Windows dynamically linked libraries need some special treatment
127# You may want to edit these settings if you provide your own libraries
128# Note: Default option in the libraries vary, but our default option is dynamic
129IF(WIN32)
130  OPTION(LINK_BOOST_DYNAMIC "Link Boost dynamically on Windows" TRUE)
131  OPTION(LINK_CEGUI_DYNAMIC "Link CEGUI dynamicylly on Windows" TRUE)
132  OPTION(LINK_ENET_DYNAMIC  "Link ENet dynamically on Windows" TRUE)
133  OPTION(LINK_OGRE_DYNAMIC  "Link OGRE dynamically on Windows" TRUE)
134  OPTION(LINK_TCL_DYNAMIC   "Link TCL dynamically on Windows" TRUE)
135  OPTION(LINK_ZLIB_DYNAMIC  "Link ZLib dynamically on Windows" TRUE)
136  COMPARE_VERSION_STRINGS("${LUA_VERSION}" "5.1" _version_comparison)
137  IF(_version_comparison LESS 0)
138    OPTION(LINK_LUA_DYNAMIC "Link Lua dynamically on Windows" FALSE)
139  ELSE(_version_comparison LESS 0)
140    OPTION(LINK_LUA_DYNAMIC "Link Lua dynamically on Windows" TRUE)
141  ENDIF(_version_comparison LESS 0)
142ENDIF(WIN32)
Note: See TracBrowser for help on using the repository browser.