Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/buildsystem3/cmake/BuildConfig.cmake @ 2698

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

Temporary fix for the relative path problem:
On Unix, absolute paths are used always.
On Windows, relative paths are used for the installed version.
That means you cannot relocated orxonox on Unix and you must not run orxonox from another directory than where the executable is on Windows (run scripts still work because they "cd").

  • Property svn:eol-style set to native
File size: 7.1 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 Options ##################
28
29# Set binary output directories
30SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
31SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
32SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
33
34# Take care of some CMake 2.6.0 leftovers
35MARK_AS_ADVANCED(EXECUTABLE_OUTPUT_PATH LIBRARY_OUTPUT_PATH)
36
37# Sets where to find the external libraries like OgreMain.dll at runtime
38# On Unix you should not have to change this at all.
39IF(NOT ORXONOX_RUNTIME_LIBRARY_DIRECTORY)
40  SET(ORXONOX_RUNTIME_LIBRARY_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
41ENDIF()
42
43# Set Debug build to default when not having multi-config generator like msvc
44IF(NOT CMAKE_CONFIGURATION_TYPES)
45  IF(NOT CMAKE_BUILD_TYPE)
46    SET(CMAKE_BUILD_TYPE Debug CACHE STRING
47        "Build types are: Debug, Release, MinSizeRel, RelWithDebInfo" FORCE)
48  ENDIF()
49  MARK_AS_ADVANCED(CLEAR CMAKE_BUILD_TYPE)
50
51  MESSAGE(STATUS "*** Build type is ${CMAKE_BUILD_TYPE} ***")
52ELSE()
53  IF(CMAKE_BUILD_TYPE)
54    SET(CMAKE_BUILD_TYPE CACHE STRING FORCE)
55  ENDIF()
56  MARK_AS_ADVANCED(CMAKE_BUILD_TYPE)
57ENDIF()
58
59OPTION(EXTRA_COMPILER_WARNINGS "Enable some extra warnings (heavily pollutes the output)")
60
61
62################# OGRE Plugins ##################
63
64# More plugins: Plugin_BSPSceneManager, Plugin_OctreeSceneManager
65SET(OGRE_PLUGINS_INT Plugin_ParticleFX)
66IF(WIN32)
67  # CG program manager is probably DirectX related (not available under unix)
68  LIST(APPEND OGRE_PLUGINS_INT Plugin_CgProgramManager)
69ENDIF(WIN32)
70SET(OGRE_PLUGINS ${OGRE_PLUGINS_INT} CACHE STRING
71   "Specify which OGRE plugins to load. Existance check is performed.")
72
73# Check the plugins and determine the plugin folder
74# You can give a hint by setting the environment variable ENV{OGRE_PLUGIN_DIR}
75INCLUDE(CheckOGREPlugins)
76CHECK_OGRE_PLUGINS(${OGRE_PLUGINS})
77
78
79################ Compiler Config ################
80
81INCLUDE(FlagUtilities)
82
83# Configure the compiler specific build options
84IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUC)
85  INCLUDE(BuildConfigGCC)
86ELSEIF(MSVC)
87  INCLUDE(BuildConfigMSVC)
88ELSE()
89  MESSAGE(STATUS "Warning: Your compiler is not officially supported.")
90ENDIF()
91
92SET(USER_SCRIPT_BUILD_CONFIG "" CACHE FILEPATH
93    "Specify a CMake script if you wish to write your own build config.
94     See BuildConfigGCC.cmake or BuildConfigMSVC.cmake for examples.")
95IF(USER_SCRIPT_BUILD_CONFIG)
96  IF(EXISTS ${CMAKE_MODULE_PATH}/${USER_SCRIPT_BUILD_CONFIG}.cmake)
97    INCLUDE(${USER_SCRIPT_BUILD_CONFIG})
98  ELSEIF(EXISTS ${USER_SCRIPT_BUILD_CONFIG})
99    INCLUDE(${USER_SCRIPT_BUILD_CONFIG})
100  ELSEIF(EXISTS ${CMAKE_MODULE_PATH}/${USER_SCRIPT_BUILD_CONFIG})
101    INCLUDE(${CMAKE_MODULE_PATH}/${USER_SCRIPT_BUILD_CONFIG})
102  ENDIF()
103ENDIF(USER_SCRIPT_BUILD_CONFIG)
104
105
106################# Test options ##################
107
108OPTION(TESTING_ENABLE "Enable build tests.")
109IF(TESTING_ENABLE)
110  ENABLE_TESTING()
111ENDIF(TESTING_ENABLE)
112
113OPTION(NETWORK_TESTING_ENABLED "Build network testing tools: i.e. chatclient chatserver and alike.")
114OPTION(NETWORKTRAFFIC_TESTING_ENABLED "Build dummyserver4 and dummyclient4.")
115
116
117############# Installation Settings #############
118
119IF(UNIX)
120  SET(ORXONOX_RUNTIME_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/bin)
121  SET(ORXONOX_LIBRARY_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/lib/orxonox)
122  SET(ORXONOX_ARCHIVE_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/lib/orxonox/static)
123  SET(ORXONOX_MEDIA_INSTALL_PATH   ${CMAKE_INSTALL_PREFIX}/share/orxonox)
124  SET(ORXONOX_DOC_INSTALL_PATH     ${CMAKE_INSTALL_PREFIX}/share/doc/orxonox)
125  GET_FILENAME_COMPONENT(USER_DIR ~ ABSOLUTE)
126  SET(ORXONOX_LOG_INSTALL_PATH     ${USER_DIR}/.orxonox/log)
127  SET(ORXONOX_CONFIG_INSTALL_PATH  ${USER_DIR}/.orxonox/config)
128
129  # Execution paths, either relative to the binary dir or absolute
130  # For Windows copy&paste installs relative paths are much better
131  SET(ORXONOX_MEDIA_INSTALL_PATH_EXEC  ${ORXONOX_MEDIA_INSTALL_PATH})
132  SET(ORXONOX_CONFIG_INSTALL_PATH_EXEC ${ORXONOX_CONFIG_INSTALL_PATH})
133  SET(ORXONOX_LOG_INSTALL_PATH_EXEC    ${ORXONOX_LOG_INSTALL_PATH})
134ELSEIF(WIN32)
135  SET(ORXONOX_RUNTIME_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/bin)
136  SET(ORXONOX_LIBRARY_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/lib)
137  SET(ORXONOX_ARCHIVE_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/lib/static)
138  SET(ORXONOX_MEDIA_INSTALL_PATH   ${CMAKE_INSTALL_PREFIX}/media)
139  SET(ORXONOX_DOC_INSTALL_PATH     ${CMAKE_INSTALL_PREFIX}/doc)
140  SET(ORXONOX_LOG_INSTALL_PATH     ${CMAKE_INSTALL_PREFIX}/log)
141  SET(ORXONOX_CONFIG_INSTALL_PATH  ${CMAKE_INSTALL_PREFIX}/config)
142
143  # Execution paths, either relative to the binary dir or absolute
144  # For Windows copy&paste installs relative paths are much better
145  SET(ORXONOX_MEDIA_INSTALL_PATH_EXEC  ../media)
146  SET(ORXONOX_CONFIG_INSTALL_PATH_EXEC ../config)
147  SET(ORXONOX_LOG_INSTALL_PATH_EXEC    ../log)
148ENDIF()
149
150
151################## Unix rpath ###################
152
153# use, i.e. don't skip the full RPATH for the build tree
154SET(CMAKE_SKIP_BUILD_RPATH  FALSE)
155
156# when building, don't use the install RPATH already
157# (but later on when installing)
158SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) 
159
160# the RPATH to be used when installing
161SET(CMAKE_INSTALL_RPATH ${ORXONOX_LIBRARY_INSTALL_PATH})
162
163# add the automatically determined parts of the RPATH
164# which point to directories outside the build tree to the install RPATH
165SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
166
167
168######## Static/Dynamic linking defines #########
169
170# Disable Boost auto linking completely
171ADD_COMPILER_FLAGS("-DBOOST_ALL_NO_LIB")
172
173# If no defines are specified, these libs get linked statically
174ADD_COMPILER_FLAGS("-DBOOST_ALL_DYN_LINK" WIN32 LINK_BOOST_DYNAMIC)
175ADD_COMPILER_FLAGS("-DENET_DLL"           WIN32 LINK_ENET_DYNAMIC)
176ADD_COMPILER_FLAGS("-DLUA_BUILD_AS_DLL"   WIN32 LINK_LUA_DYNAMIC)
177ADD_COMPILER_FLAGS("-DZLIB_DLL"           WIN32 LINK_ZLIB_DYNAMIC)
178
179# If no defines are specified, these libs get linked dynamically
180# You can change that optionally in the Cache.
181ADD_COMPILER_FLAGS("-DCEGUI_STATIC"       WIN32 NOT LINK_CEGUI_DYNAMIC)
182ADD_COMPILER_FLAGS("-DOGRE_STATIC_LIB"    WIN32 NOT LINK_OGRE_DYNAMIC)
183ADD_COMPILER_FLAGS("-DSTATIC_BUILD"       WIN32 NOT LINK_TCL_DYNAMIC)
Note: See TracBrowser for help on using the repository browser.