Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/cmake/BuildConfig.cmake @ 2732

Last change on this file since 2732 was 2723, checked in by rgrieder, 16 years ago

Unix update for the copyable installation.

  • Property svn:eol-style set to native
File size: 8.2 KB
RevLine 
[2579]1 #
[2626]2 #             ORXONOX - the hottest 3D action shooter ever to exist
3 #                             > www.orxonox.net <
[2579]4 #
[2626]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.
[2579]9 #
[2626]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.
[2579]14 #
[2626]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.
[2579]18 #
19 #
[2626]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.
[2579]25 #
26
[2673]27################# Misc Options ##################
[2582]28
[2702]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_DOC_PATH     doc)
34SET(DEFAULT_MEDIA_PATH   media)
35SET(DEFAULT_CONFIG_PATH  config)
36SET(DEFAULT_LOG_PATH     log)
[2612]37
[2702]38# Set output directories
39SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_RUNTIME_PATH})
40SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_LIBRARY_PATH})
41SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_ARCHIVE_PATH})
42# Do not set doc and media, rather check in the two subdirectories
43# whether they concur with the DEFAULT_..._PATH
44SET(CMAKE_CONFIG_OUTPUT_DIRECTORY  ${CMAKE_BINARY_DIR}/${DEFAULT_CONFIG_PATH})
45SET(CMAKE_LOG_OUTPUT_DIRECTORY     ${CMAKE_BINARY_DIR}/${DEFAULT_LOG_PATH})
46
[2673]47# Take care of some CMake 2.6.0 leftovers
48MARK_AS_ADVANCED(EXECUTABLE_OUTPUT_PATH LIBRARY_OUTPUT_PATH)
49
[2618]50# Sets where to find the external libraries like OgreMain.dll at runtime
51# On Unix you should not have to change this at all.
[2621]52IF(NOT ORXONOX_RUNTIME_LIBRARY_DIRECTORY)
53  SET(ORXONOX_RUNTIME_LIBRARY_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
[2624]54ENDIF()
[2618]55
[2612]56# Set Debug build to default when not having multi-config generator like msvc
[2618]57IF(NOT CMAKE_CONFIGURATION_TYPES)
58  IF(NOT CMAKE_BUILD_TYPE)
59    SET(CMAKE_BUILD_TYPE Debug CACHE STRING
60        "Build types are: Debug, Release, MinSizeRel, RelWithDebInfo" FORCE)
[2624]61  ENDIF()
[2618]62  MARK_AS_ADVANCED(CLEAR CMAKE_BUILD_TYPE)
[2636]63
64  MESSAGE(STATUS "*** Build type is ${CMAKE_BUILD_TYPE} ***")
[2624]65ELSE()
[2618]66  IF(CMAKE_BUILD_TYPE)
67    SET(CMAKE_BUILD_TYPE CACHE STRING FORCE)
[2624]68  ENDIF()
[2618]69  MARK_AS_ADVANCED(CMAKE_BUILD_TYPE)
[2624]70ENDIF()
[2612]71
[2582]72
[2673]73################# OGRE Plugins ##################
74
[2585]75# More plugins: Plugin_BSPSceneManager, Plugin_OctreeSceneManager
[2673]76SET(OGRE_PLUGINS_INT Plugin_ParticleFX)
[2592]77IF(WIN32)
78  # CG program manager is probably DirectX related (not available under unix)
[2618]79  LIST(APPEND OGRE_PLUGINS_INT Plugin_CgProgramManager)
[2592]80ENDIF(WIN32)
[2618]81SET(OGRE_PLUGINS ${OGRE_PLUGINS_INT} CACHE STRING
82   "Specify which OGRE plugins to load. Existance check is performed.")
[2585]83
[2612]84# Check the plugins and determine the plugin folder
85# You can give a hint by setting the environment variable ENV{OGRE_PLUGIN_DIR}
86INCLUDE(CheckOGREPlugins)
[2618]87CHECK_OGRE_PLUGINS(${OGRE_PLUGINS})
[2585]88
[2582]89
[2673]90################ Compiler Config ################
[2582]91
[2719]92OPTION(EXTRA_COMPILER_WARNINGS "Enable some extra warnings (heavily pollutes the output)")
93
[2621]94INCLUDE(FlagUtilities)
[2582]95
[2621]96# Configure the compiler specific build options
97IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUC)
98  INCLUDE(BuildConfigGCC)
99ELSEIF(MSVC)
100  INCLUDE(BuildConfigMSVC)
[2624]101ELSE()
[2621]102  MESSAGE(STATUS "Warning: Your compiler is not officially supported.")
[2624]103ENDIF()
[2621]104
[2673]105SET(USER_SCRIPT_BUILD_CONFIG "" CACHE FILEPATH
[2621]106    "Specify a CMake script if you wish to write your own build config.
107     See BuildConfigGCC.cmake or BuildConfigMSVC.cmake for examples.")
[2673]108IF(USER_SCRIPT_BUILD_CONFIG)
109  IF(EXISTS ${CMAKE_MODULE_PATH}/${USER_SCRIPT_BUILD_CONFIG}.cmake)
110    INCLUDE(${USER_SCRIPT_BUILD_CONFIG})
111  ELSEIF(EXISTS ${USER_SCRIPT_BUILD_CONFIG})
112    INCLUDE(${USER_SCRIPT_BUILD_CONFIG})
113  ELSEIF(EXISTS ${CMAKE_MODULE_PATH}/${USER_SCRIPT_BUILD_CONFIG})
114    INCLUDE(${CMAKE_MODULE_PATH}/${USER_SCRIPT_BUILD_CONFIG})
[2624]115  ENDIF()
[2673]116ENDIF(USER_SCRIPT_BUILD_CONFIG)
[2621]117
118
[2673]119################# Test options ##################
[2612]120
[2673]121OPTION(TESTING_ENABLE "Enable build tests.")
122IF(TESTING_ENABLE)
[2612]123  ENABLE_TESTING()
[2673]124ENDIF(TESTING_ENABLE)
[2612]125
[2678]126OPTION(NETWORK_TESTING_ENABLED "Build network testing tools: i.e. chatclient chatserver and alike.")
127OPTION(NETWORKTRAFFIC_TESTING_ENABLED "Build dummyserver4 and dummyclient4.")
[2680]128
129
[2673]130############# Installation Settings #############
[2612]131
[2702]132SET(_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\"")
[2657]133IF(UNIX)
[2702]134  OPTION(INSTALL_COPYABLE "${_info_text}" FALSE)
135ELSE()
136  OPTION(INSTALL_COPYABLE "${_info_text}" TRUE)
137ENDIF()
138
139IF(INSTALL_COPYABLE)
140  # Note the relative paths. They will be resolved at runtime.
141  # For CMake operations CMAKE_INSTALL_PREFIX is always appended.
142  SET(ORXONOX_RUNTIME_INSTALL_PATH ${DEFAULT_RUNTIME_PATH})
[2723]143  SET(ORXONOX_LIBRARY_INSTALL_PATH ${DEFAULT_LIBRARY_PATH})
[2702]144  SET(ORXONOX_ARCHIVE_INSTALL_PATH ${DEFAULT_ARCHIVE_PATH})
145  SET(ORXONOX_DOC_INSTALL_PATH     ${DEFAULT_DOC_PATH})
146  SET(ORXONOX_MEDIA_INSTALL_PATH   ${DEFAULT_MEDIA_PATH})
147  SET(ORXONOX_CONFIG_INSTALL_PATH  ${DEFAULT_CONFIG_PATH})
148  SET(ORXONOX_LOG_INSTALL_PATH     ${DEFAULT_LOG_PATH})
149
150ELSEIF(UNIX) # Apple too?
151  # Using absolute paths
[2689]152  SET(ORXONOX_RUNTIME_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/bin)
[2657]153  SET(ORXONOX_LIBRARY_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/lib/orxonox)
154  SET(ORXONOX_ARCHIVE_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/lib/orxonox/static)
[2702]155  SET(ORXONOX_DOC_INSTALL_PATH     ${CMAKE_INSTALL_PREFIX}/share/doc/orxonox)
[2657]156  SET(ORXONOX_MEDIA_INSTALL_PATH   ${CMAKE_INSTALL_PREFIX}/share/orxonox)
[2702]157  # These two paths are user and therefore runtime dependent --> only set relatively
158  SET(ORXONOX_CONFIG_INSTALL_PATH  ${DEFAULT_CONFIG_PATH})
159  SET(ORXONOX_LOG_INSTALL_PATH     ${DEFAULT_LOG_PATH})
[2687]160
[2657]161ELSEIF(WIN32)
[2702]162  SET(ORXONOX_RUNTIME_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/${DEFAULT_RUNTIME_PATH})
163  SET(ORXONOX_LIBRARY_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/${DEFAULT_LIBRARY_PATH})
164  SET(ORXONOX_ARCHIVE_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/${DEFAULT_ARCHIVE_PATH})
165  SET(ORXONOX_DOC_INSTALL_PATH     ${CMAKE_INSTALL_PREFIX}/${DEFAULT_DOC_PATH})
166  SET(ORXONOX_MEDIA_INSTALL_PATH   ${CMAKE_INSTALL_PREFIX}/${DEFAULT_MEDIA_PATH})
167  # Leave empty because it is user and therefore runtime dependent
168  SET(ORXONOX_CONFIG_INSTALL_PATH  ${DEFAULT_CONFIG_PATH})
169  SET(ORXONOX_LOG_INSTALL_PATH     ${DEFAULT_LOG_PATH})
[2657]170ENDIF()
171
172
[2673]173################## Unix rpath ###################
[2657]174
175# use, i.e. don't skip the full RPATH for the build tree
176SET(CMAKE_SKIP_BUILD_RPATH  FALSE)
177
178# when building, don't use the install RPATH already
179# (but later on when installing)
180SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) 
181
182# the RPATH to be used when installing
[2658]183SET(CMAKE_INSTALL_RPATH ${ORXONOX_LIBRARY_INSTALL_PATH})
[2657]184
185# add the automatically determined parts of the RPATH
186# which point to directories outside the build tree to the install RPATH
187SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
188
189
[2673]190######## Static/Dynamic linking defines #########
[2612]191
[2630]192# Disable Boost auto linking completely
193ADD_COMPILER_FLAGS("-DBOOST_ALL_NO_LIB")
194
[2621]195# If no defines are specified, these libs get linked statically
196ADD_COMPILER_FLAGS("-DBOOST_ALL_DYN_LINK" WIN32 LINK_BOOST_DYNAMIC)
197ADD_COMPILER_FLAGS("-DENET_DLL"           WIN32 LINK_ENET_DYNAMIC)
198ADD_COMPILER_FLAGS("-DLUA_BUILD_AS_DLL"   WIN32 LINK_LUA_DYNAMIC)
199ADD_COMPILER_FLAGS("-DZLIB_DLL"           WIN32 LINK_ZLIB_DYNAMIC)
200
201# If no defines are specified, these libs get linked dynamically
202# You can change that optionally in the Cache.
203ADD_COMPILER_FLAGS("-DCEGUI_STATIC"       WIN32 NOT LINK_CEGUI_DYNAMIC)
204ADD_COMPILER_FLAGS("-DOGRE_STATIC_LIB"    WIN32 NOT LINK_OGRE_DYNAMIC)
205ADD_COMPILER_FLAGS("-DSTATIC_BUILD"       WIN32 NOT LINK_TCL_DYNAMIC)
Note: See TracBrowser for help on using the repository browser.