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 |
---|
30 | SET(DEFAULT_RUNTIME_PATH bin) |
---|
31 | SET(DEFAULT_LIBRARY_PATH lib) |
---|
32 | SET(DEFAULT_ARCHIVE_PATH lib/static) |
---|
33 | SET(DEFAULT_DOC_PATH doc) |
---|
34 | SET(DEFAULT_MEDIA_PATH media) |
---|
35 | SET(DEFAULT_CONFIG_PATH config) |
---|
36 | SET(DEFAULT_LOG_PATH log) |
---|
37 | |
---|
38 | # Set output directories |
---|
39 | SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_RUNTIME_PATH}) |
---|
40 | SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_LIBRARY_PATH}) |
---|
41 | SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_ARCHIVE_PATH}) |
---|
42 | SET(CMAKE_DOC_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_DOC_PATH}) |
---|
43 | # Media directories are only inputs |
---|
44 | SET(CMAKE_CONFIG_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_CONFIG_PATH}) |
---|
45 | SET(CMAKE_LOG_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_LOG_PATH}) |
---|
46 | |
---|
47 | # Take care of some CMake 2.6.0 leftovers |
---|
48 | MARK_AS_ADVANCED(EXECUTABLE_OUTPUT_PATH LIBRARY_OUTPUT_PATH) |
---|
49 | |
---|
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. |
---|
52 | IF(NOT RUNTIME_LIBRARY_DIRECTORY) |
---|
53 | SET(RUNTIME_LIBRARY_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) |
---|
54 | ENDIF() |
---|
55 | |
---|
56 | # Set Debug build to default when not having multi-config generator like msvc |
---|
57 | IF(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) |
---|
61 | ENDIF() |
---|
62 | MARK_AS_ADVANCED(CLEAR CMAKE_BUILD_TYPE) |
---|
63 | |
---|
64 | MESSAGE(STATUS "*** Build type is ${CMAKE_BUILD_TYPE} ***") |
---|
65 | ELSE() |
---|
66 | IF(CMAKE_BUILD_TYPE) |
---|
67 | SET(CMAKE_BUILD_TYPE CACHE STRING FORCE) |
---|
68 | ENDIF() |
---|
69 | MARK_AS_ADVANCED(CMAKE_BUILD_TYPE) |
---|
70 | ENDIF() |
---|
71 | |
---|
72 | |
---|
73 | ################# OGRE Plugins ################## |
---|
74 | |
---|
75 | # More plugins: Plugin_BSPSceneManager, Plugin_OctreeSceneManager |
---|
76 | SET(OGRE_PLUGINS_INT Plugin_ParticleFX) |
---|
77 | IF(WIN32) |
---|
78 | # CG program manager is probably DirectX related (not available under unix) |
---|
79 | LIST(APPEND OGRE_PLUGINS_INT Plugin_CgProgramManager) |
---|
80 | ENDIF(WIN32) |
---|
81 | SET(OGRE_PLUGINS ${OGRE_PLUGINS_INT} CACHE STRING |
---|
82 | "Specify which OGRE plugins to load. Existance check is performed.") |
---|
83 | |
---|
84 | # Check the plugins and determine the plugin folder |
---|
85 | # You can give a hint by setting the environment variable ENV{OGRE_PLUGIN_DIR} |
---|
86 | INCLUDE(CheckOGREPlugins) |
---|
87 | CHECK_OGRE_PLUGINS(${OGRE_PLUGINS}) |
---|
88 | |
---|
89 | |
---|
90 | ################ Compiler Config ################ |
---|
91 | |
---|
92 | OPTION(EXTRA_COMPILER_WARNINGS "Enable some extra warnings (heavily pollutes the output)" FALSE) |
---|
93 | |
---|
94 | INCLUDE(FlagUtilities) |
---|
95 | |
---|
96 | # Configure the compiler specific build options |
---|
97 | IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUC) |
---|
98 | INCLUDE(BuildConfigGCC) |
---|
99 | ELSEIF(MSVC) |
---|
100 | INCLUDE(BuildConfigMSVC) |
---|
101 | ELSE() |
---|
102 | MESSAGE(STATUS "Warning: Your compiler is not officially supported.") |
---|
103 | ENDIF() |
---|
104 | |
---|
105 | SET(USER_SCRIPT_BUILD_CONFIG "" CACHE FILEPATH |
---|
106 | "Specify a CMake script if you wish to write your own build config. |
---|
107 | See BuildConfigGCC.cmake or BuildConfigMSVC.cmake for examples.") |
---|
108 | IF(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}) |
---|
115 | ENDIF() |
---|
116 | ENDIF(USER_SCRIPT_BUILD_CONFIG) |
---|
117 | |
---|
118 | |
---|
119 | ############# Installation Settings ############# |
---|
120 | |
---|
121 | SET(_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\"") |
---|
122 | IF(UNIX) |
---|
123 | OPTION(INSTALL_COPYABLE "${_info_text}" FALSE) |
---|
124 | ELSE() |
---|
125 | OPTION(INSTALL_COPYABLE "${_info_text}" TRUE) |
---|
126 | ENDIF() |
---|
127 | |
---|
128 | # Default installation paths |
---|
129 | SET(RUNTIME_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${DEFAULT_RUNTIME_PATH}) |
---|
130 | SET(LIBRARY_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${DEFAULT_LIBRARY_PATH}) |
---|
131 | SET(ARCHIVE_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${DEFAULT_ARCHIVE_PATH}) |
---|
132 | SET(DOC_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${DEFAULT_DOC_PATH}) |
---|
133 | SET(MEDIA_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${DEFAULT_MEDIA_PATH}) |
---|
134 | SET(CONFIG_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${DEFAULT_CONFIG_PATH}) |
---|
135 | SET(LOG_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${DEFAULT_LOG_PATH}) |
---|
136 | |
---|
137 | IF(NOT INSTALL_COPYABLE) |
---|
138 | IF(UNIX) # Apple too? |
---|
139 | # Using absolute paths |
---|
140 | SET(RUNTIME_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX}/bin) |
---|
141 | SET(LIBRARY_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX}/lib/orxonox) |
---|
142 | SET(ARCHIVE_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX}/lib/orxonox/static) |
---|
143 | SET(DOC_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX}/share/doc/orxonox) |
---|
144 | SET(MEDIA_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX}/share/orxonox) |
---|
145 | ENDIF() |
---|
146 | |
---|
147 | # Leave empty because it is user and therefore runtime dependent |
---|
148 | SET(CONFIG_INSTALL_DIRECTORY) |
---|
149 | SET(LOG_INSTALL_DIRECTORY) |
---|
150 | ENDIF() |
---|
151 | |
---|
152 | |
---|
153 | ################## Unix rpath ################### |
---|
154 | |
---|
155 | # use, i.e. don't skip the full RPATH for the build tree |
---|
156 | SET(CMAKE_SKIP_BUILD_RPATH FALSE) |
---|
157 | |
---|
158 | # when building, don't use the install RPATH already |
---|
159 | # (but later on when installing) |
---|
160 | SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) |
---|
161 | |
---|
162 | # the RPATH to be used when installing |
---|
163 | IF(INSTALL_COPYABLE) |
---|
164 | SET(CMAKE_INSTALL_RPATH ${DEFAULT_LIBRARY_PATH}) |
---|
165 | ELSE() |
---|
166 | SET(CMAKE_INSTALL_RPATH ${LIBRARY_INSTALL_DIRECTORY}) |
---|
167 | ENDIF() |
---|
168 | |
---|
169 | # add the automatically determined parts of the RPATH |
---|
170 | # which point to directories outside the build tree to the install RPATH |
---|
171 | SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) |
---|
172 | |
---|
173 | |
---|
174 | ################ Various options ################ |
---|
175 | |
---|
176 | # Enable expensive optimisations: Use this for a binary release build |
---|
177 | OPTION(ORXONOX_RELEASE "Enable when building restributable releases" FALSE) |
---|
178 | |
---|
179 | # Use WinMain() or main()? |
---|
180 | IF(WIN32) |
---|
181 | OPTION(ORXONOX_USE_WINMAIN "Use WinMain (doesn't show console) or main" FALSE) |
---|
182 | ENDIF() |
---|
183 | |
---|
184 | # Global switch to disable Precompiled Header Files |
---|
185 | IF(PCH_COMPILER_SUPPORT) |
---|
186 | OPTION(PCH_ENABLE "Global PCH switch" TRUE) |
---|
187 | ENDIF() |
---|
188 | |
---|
189 | |
---|
190 | ############ Static/Dynamic linking ############# |
---|
191 | |
---|
192 | # Default linking is SHARED |
---|
193 | SET(ORXONOX_DEFAULT_LINK SHARED) |
---|
194 | |
---|
195 | # Disable Boost auto linking completely |
---|
196 | ADD_COMPILER_FLAGS("-DBOOST_ALL_NO_LIB") |
---|
197 | |
---|
198 | # If no defines are specified, these libs get linked statically |
---|
199 | ADD_COMPILER_FLAGS("-DBOOST_ALL_DYN_LINK" WIN32 LINK_BOOST_DYNAMIC) |
---|
200 | ADD_COMPILER_FLAGS("-DENET_DLL" WIN32 LINK_ENET_DYNAMIC) |
---|
201 | ADD_COMPILER_FLAGS("-DLUA_BUILD_AS_DLL" WIN32 LINK_LUA_DYNAMIC) |
---|
202 | ADD_COMPILER_FLAGS("-DZLIB_DLL" WIN32 LINK_ZLIB_DYNAMIC) |
---|
203 | |
---|
204 | # If no defines are specified, these libs get linked dynamically |
---|
205 | # You can change that optionally in the Cache. |
---|
206 | ADD_COMPILER_FLAGS("-DCEGUI_STATIC" WIN32 NOT LINK_CEGUI_DYNAMIC) |
---|
207 | ADD_COMPILER_FLAGS("-DOGRE_STATIC_LIB" WIN32 NOT LINK_OGRE_DYNAMIC) |
---|
208 | ADD_COMPILER_FLAGS("-DSTATIC_BUILD" WIN32 NOT LINK_TCL_DYNAMIC) |
---|