Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/libraries/cmake/BuildConfig.cmake @ 5706

Last change on this file since 5706 was 5666, checked in by landauf, 15 years ago

renamed plugins as modules

  • Property svn:eol-style set to native
File size: 8.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 compilers and sets build options.
24 #    This also includes handling the OGRE plugins and the media directory.
25 #
26
27################# Misc Settings #################
28
29# Standard path suffixes, might not hold everywhere though
30SET(DEFAULT_RUNTIME_PATH bin)
31SET(DEFAULT_LIBRARY_PATH lib)
32SET(DEFAULT_ARCHIVE_PATH lib/static)
33SET(DEFAULT_MODULE_PATH  lib/modules)
34SET(DEFAULT_DOC_PATH     doc)
35SET(DEFAULT_MEDIA_PATH   media)
36SET(DEFAULT_CONFIG_PATH  config)
37SET(DEFAULT_LOG_PATH     log)
38
39# Set output directories
40SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_RUNTIME_PATH})
41SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_LIBRARY_PATH})
42SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_ARCHIVE_PATH})
43SET(CMAKE_MODULE_OUTPUT_DIRECTORY  ${CMAKE_BINARY_DIR}/${DEFAULT_MODULE_PATH})
44# Do not set doc and media, rather check in the two subdirectories
45# whether they concur with the DEFAULT_..._PATH
46SET(CMAKE_CONFIG_OUTPUT_DIRECTORY  ${CMAKE_BINARY_DIR}/${DEFAULT_CONFIG_PATH})
47SET(CMAKE_LOG_OUTPUT_DIRECTORY     ${CMAKE_BINARY_DIR}/${DEFAULT_LOG_PATH})
48
49# Take care of some CMake 2.6.0 leftovers
50MARK_AS_ADVANCED(EXECUTABLE_OUTPUT_PATH LIBRARY_OUTPUT_PATH)
51
52# Sets where to find the external libraries like OgreMain.dll at runtime
53# On Unix you should not have to change this at all.
54IF(NOT ORXONOX_RUNTIME_LIBRARY_DIRECTORY)
55  SET(ORXONOX_RUNTIME_LIBRARY_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
56ENDIF()
57
58# Set Debug build to default when not having multi-config generator like msvc
59IF(NOT CMAKE_CONFIGURATION_TYPES)
60  IF(NOT CMAKE_BUILD_TYPE)
61    SET(CMAKE_BUILD_TYPE Debug CACHE STRING
62        "Build types are: Debug, Release, MinSizeRel, RelWithDebInfo" FORCE)
63  ENDIF()
64  MARK_AS_ADVANCED(CLEAR CMAKE_BUILD_TYPE)
65
66  MESSAGE(STATUS "*** Build type is ${CMAKE_BUILD_TYPE} ***")
67ELSE()
68  IF(CMAKE_BUILD_TYPE)
69    SET(CMAKE_BUILD_TYPE CACHE STRING FORCE)
70  ENDIF()
71  MARK_AS_ADVANCED(CMAKE_BUILD_TYPE)
72ENDIF()
73
74# Set the extension of the dynamic modules
75SET(ORXONOX_MODULE_EXTENSION ".module")
76
77################# OGRE Plugins ##################
78
79# More plugins: Plugin_BSPSceneManager, Plugin_OctreeSceneManager
80SET(OGRE_PLUGINS_INT Plugin_ParticleFX)
81IF(WIN32)
82  # CG program manager is probably DirectX related (not available under unix)
83  LIST(APPEND OGRE_PLUGINS_INT Plugin_CgProgramManager)
84ENDIF(WIN32)
85SET(OGRE_PLUGINS ${OGRE_PLUGINS_INT} CACHE STRING
86   "Specify which OGRE plugins to load. Existance check is performed.")
87
88# Check the plugins and determine the plugin folder
89# You can give a hint by setting the environment variable ENV{OGRE_PLUGIN_DIR}
90INCLUDE(CheckOGREPlugins)
91CHECK_OGRE_PLUGINS(${OGRE_PLUGINS})
92
93
94################ Compiler Config ################
95
96OPTION(EXTRA_COMPILER_WARNINGS "Enable some extra warnings (heavily pollutes the output)" FALSE)
97
98INCLUDE(FlagUtilities)
99
100# Configure the compiler specific build options
101IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUC)
102  INCLUDE(BuildConfigGCC)
103ELSEIF(MSVC)
104  INCLUDE(BuildConfigMSVC)
105ELSE()
106  MESSAGE(STATUS "Warning: Your compiler is not officially supported.")
107ENDIF()
108
109SET(USER_SCRIPT_BUILD_CONFIG "" CACHE FILEPATH
110    "Specify a CMake script if you wish to write your own build config.
111     See BuildConfigGCC.cmake or BuildConfigMSVC.cmake for examples.")
112IF(USER_SCRIPT_BUILD_CONFIG)
113  IF(EXISTS ${CMAKE_MODULE_PATH}/${USER_SCRIPT_BUILD_CONFIG}.cmake)
114    INCLUDE(${USER_SCRIPT_BUILD_CONFIG})
115  ELSEIF(EXISTS ${USER_SCRIPT_BUILD_CONFIG})
116    INCLUDE(${USER_SCRIPT_BUILD_CONFIG})
117  ELSEIF(EXISTS ${CMAKE_MODULE_PATH}/${USER_SCRIPT_BUILD_CONFIG})
118    INCLUDE(${CMAKE_MODULE_PATH}/${USER_SCRIPT_BUILD_CONFIG})
119  ENDIF()
120ENDIF(USER_SCRIPT_BUILD_CONFIG)
121
122
123############# Installation Settings #############
124
125SET(_info_text "Puts all installed files in subfolders of the install prefix path. That root folder can then be moved, copied and renamed as you wish. The executable will not write to folders like ~/.orxonox or \"Applictation Data\"")
126IF(UNIX)
127  OPTION(INSTALL_COPYABLE "${_info_text}" FALSE)
128ELSE()
129  OPTION(INSTALL_COPYABLE "${_info_text}" TRUE)
130ENDIF()
131
132IF(INSTALL_COPYABLE)
133  # Note the relative paths. They will be resolved at runtime.
134  # For CMake operations CMAKE_INSTALL_PREFIX is always appended.
135  SET(ORXONOX_RUNTIME_INSTALL_PATH ${DEFAULT_RUNTIME_PATH})
136  SET(ORXONOX_LIBRARY_INSTALL_PATH ${DEFAULT_LIBRARY_PATH})
137  SET(ORXONOX_ARCHIVE_INSTALL_PATH ${DEFAULT_ARCHIVE_PATH})
138  SET(ORXONOX_MODULE_INSTALL_PATH  ${DEFAULT_MODULE_PATH})
139  SET(ORXONOX_DOC_INSTALL_PATH     ${DEFAULT_DOC_PATH})
140  SET(ORXONOX_MEDIA_INSTALL_PATH   ${DEFAULT_MEDIA_PATH})
141  SET(ORXONOX_CONFIG_INSTALL_PATH  ${DEFAULT_CONFIG_PATH})
142  SET(ORXONOX_LOG_INSTALL_PATH     ${DEFAULT_LOG_PATH})
143
144ELSEIF(UNIX) # Apple too?
145  # Using absolute paths
146  SET(ORXONOX_RUNTIME_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/bin)
147  SET(ORXONOX_LIBRARY_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/lib/orxonox)
148  SET(ORXONOX_ARCHIVE_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/lib/orxonox/static)
149  SET(ORXONOX_MODULE_INSTALL_PATH  ${CMAKE_INSTALL_PREFIX}/lib/orxonox/modules)
150  SET(ORXONOX_DOC_INSTALL_PATH     ${CMAKE_INSTALL_PREFIX}/share/doc/orxonox)
151  SET(ORXONOX_MEDIA_INSTALL_PATH   ${CMAKE_INSTALL_PREFIX}/share/orxonox)
152  # These two paths are user and therefore runtime dependent --> only set relatively
153  SET(ORXONOX_CONFIG_INSTALL_PATH  ${DEFAULT_CONFIG_PATH})
154  SET(ORXONOX_LOG_INSTALL_PATH     ${DEFAULT_LOG_PATH})
155
156ELSEIF(WIN32)
157  SET(ORXONOX_RUNTIME_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/${DEFAULT_RUNTIME_PATH})
158  SET(ORXONOX_LIBRARY_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/${DEFAULT_LIBRARY_PATH})
159  SET(ORXONOX_ARCHIVE_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/${DEFAULT_ARCHIVE_PATH})
160  SET(ORXONOX_MODULE_INSTALL_PATH  ${CMAKE_INSTALL_PREFIX}/${DEFAULT_MODULE_PATH})
161  SET(ORXONOX_DOC_INSTALL_PATH     ${CMAKE_INSTALL_PREFIX}/${DEFAULT_DOC_PATH})
162  SET(ORXONOX_MEDIA_INSTALL_PATH   ${CMAKE_INSTALL_PREFIX}/${DEFAULT_MEDIA_PATH})
163  # Leave empty because it is user and therefore runtime dependent
164  SET(ORXONOX_CONFIG_INSTALL_PATH  ${DEFAULT_CONFIG_PATH})
165  SET(ORXONOX_LOG_INSTALL_PATH     ${DEFAULT_LOG_PATH})
166ENDIF()
167
168
169################## Unix rpath ###################
170
171# use, i.e. don't skip the full RPATH for the build tree
172SET(CMAKE_SKIP_BUILD_RPATH  FALSE)
173
174# when building, don't use the install RPATH already
175# (but later on when installing)
176SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
177
178# the RPATH to be used when installing
179SET(CMAKE_INSTALL_RPATH ${ORXONOX_LIBRARY_INSTALL_PATH})
180
181# add the automatically determined parts of the RPATH
182# which point to directories outside the build tree to the install RPATH
183SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
184
185
186################ Various options ################
187
188# Enable expensive optimisations: Use this for a binary release build
189OPTION(ORXONOX_RELEASE "Enable when building restributable releases" FALSE)
190
191# Use WinMain() or main()?
192IF(WIN32)
193  OPTION(ORXONOX_USE_WINMAIN "Use WinMain (doesn't show console) or main" FALSE)
194ENDIF()
195
196# Global switch to disable Precompiled Header Files
197IF(PCH_COMPILER_SUPPORT)
198  OPTION(PCH_ENABLE "Global PCH switch" TRUE)
199ENDIF()
200
201
202############ Static/Dynamic linking #############
203
204# Default linking is SHARED
205SET(ORXONOX_DEFAULT_LINK SHARED)
206
207# Disable Boost auto linking completely
208ADD_COMPILER_FLAGS("-DBOOST_ALL_NO_LIB")
209
210# If no defines are specified, these libs get linked statically
211ADD_COMPILER_FLAGS("-DBOOST_ALL_DYN_LINK" WIN32 LINK_BOOST_DYNAMIC)
212ADD_COMPILER_FLAGS("-DENET_DLL"           WIN32 LINK_ENET_DYNAMIC)
213ADD_COMPILER_FLAGS("-DLUA_BUILD_AS_DLL"   WIN32 LINK_LUA_DYNAMIC)
214ADD_COMPILER_FLAGS("-DZLIB_DLL"           WIN32 LINK_ZLIB_DYNAMIC)
215
216# If no defines are specified, these libs get linked dynamically
217# You can change that optionally in the Cache.
218ADD_COMPILER_FLAGS("-DCEGUI_STATIC"       WIN32 NOT LINK_CEGUI_DYNAMIC)
219ADD_COMPILER_FLAGS("-DOGRE_STATIC_LIB"    WIN32 NOT LINK_OGRE_DYNAMIC)
220ADD_COMPILER_FLAGS("-DSTATIC_BUILD"       WIN32 NOT LINK_TCL_DYNAMIC)
Note: See TracBrowser for help on using the repository browser.