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 | # |
---|
25 | |
---|
26 | # Required macros and functions |
---|
27 | INCLUDE(FlagUtilities) |
---|
28 | INCLUDE(TargetUtilities) |
---|
29 | |
---|
30 | # Configure the two headers and set some options |
---|
31 | INCLUDE(OrxonoxConfig.cmake) |
---|
32 | |
---|
33 | ####### Library Behaviour (dependencies) ######## |
---|
34 | |
---|
35 | # Disable auto linking completely for Boost and POCO |
---|
36 | ADD_COMPILER_FLAGS("-DBOOST_ALL_NO_LIB") |
---|
37 | ADD_COMPILER_FLAGS("-DPOCO_NO_AUTOMATIC_LIBS") |
---|
38 | |
---|
39 | IF(WIN32) |
---|
40 | # If no defines are specified, these libs get linked statically |
---|
41 | ADD_COMPILER_FLAGS("-DBOOST_ALL_DYN_LINK" LINK_BOOST_DYNAMIC) |
---|
42 | #ADD_COMPILER_FLAGS("-DENET_DLL" LINK_ENET_DYNAMIC) |
---|
43 | ADD_COMPILER_FLAGS("-DLUA_BUILD_AS_DLL" LINK_LUA5.1_DYNAMIC) |
---|
44 | # If no defines are specified, these libs get linked dynamically |
---|
45 | ADD_COMPILER_FLAGS("-DCEGUI_STATIC -DTOLUA_STATIC" NOT LINK_CEGUI_DYNAMIC) |
---|
46 | ADD_COMPILER_FLAGS("-DOGRE_STATIC_LIB" NOT LINK_OGRE_DYNAMIC) |
---|
47 | ADD_COMPILER_FLAGS("-DSTATIC_BUILD" NOT LINK_TCL_DYNAMIC) |
---|
48 | |
---|
49 | # Target Windows XP as minimum Windows version |
---|
50 | # And try to catch all the different macro defines for that... |
---|
51 | ADD_COMPILER_FLAGS("-D_WIN32_WINNT=0x0501") |
---|
52 | ADD_COMPILER_FLAGS("-D_WIN32_WINDOWS=0x0501") |
---|
53 | ADD_COMPILER_FLAGS("-DWINVER=0x0501") |
---|
54 | ADD_COMPILER_FLAGS("-DNTDDI_VERSION=0x05010000") |
---|
55 | ENDIF(WIN32) |
---|
56 | |
---|
57 | # Visual Leak Dectector configuration |
---|
58 | IF(MSVC AND VLD_FOUND) |
---|
59 | OPTION(VISUAL_LEAK_DETECTOR_ENABLE "Memory leak detector" OFF) |
---|
60 | IF(VISUAL_LEAK_DETECTOR_ENABLE) |
---|
61 | # Force library linking by forcing the inclusion of a symbol |
---|
62 | ADD_LINKER_FLAGS("-INCLUDE:__imp_?vld@@3VVisualLeakDetector@@A" Debug) |
---|
63 | IF(MSVC90) |
---|
64 | # VS 2008 incremental linker crashes with /INCLUDE most of the time |
---|
65 | REMOVE_LINKER_FLAGS("-INCREMENTAL:YES" Debug) |
---|
66 | ADD_LINKER_FLAGS ("-INCREMENTAL:NO" Debug) |
---|
67 | ENDIF() |
---|
68 | IF(NOT DISABLE_COMPILATIONS) |
---|
69 | # Compilations seem to generate 'memory leaks' with static variables |
---|
70 | MESSAGE("Warning: You should disable Compilations when using VLD!") |
---|
71 | ENDIF() |
---|
72 | ENDIF() |
---|
73 | ENDIF() |
---|
74 | |
---|
75 | ######### Library Behaviour (external) ########## |
---|
76 | |
---|
77 | # Use TinyXML++ |
---|
78 | ADD_COMPILER_FLAGS("-DTIXML_USE_TICPP") |
---|
79 | |
---|
80 | # Default linking for externals |
---|
81 | IF(CMAKE_BUILD_TYPE MATCHES "(Debug|RelForDevs)") |
---|
82 | SET(_default_link_mode "SHARED") |
---|
83 | ELSE() |
---|
84 | SET(_default_link_mode "STATIC") |
---|
85 | ENDIF() |
---|
86 | SET(_message "Link mode for external libraries that we build ourselves. |
---|
87 | MSVC Note: certain libraries will not be linked shared.") |
---|
88 | SET(ORXONOX_EXTERNAL_LINK_MODE "${_default_link_mode}" CACHE STRING "${_message}") |
---|
89 | |
---|
90 | IF(ORXONOX_EXTERNAL_LINK_MODE STREQUAL "SHARED") |
---|
91 | SET(_external_shared_link TRUE) |
---|
92 | ELSE() |
---|
93 | SET(_external_shared_link FALSE) |
---|
94 | ENDIF() |
---|
95 | # If no defines are specified, these libs get linked dynamically |
---|
96 | ADD_COMPILER_FLAGS("-DENET_DLL" WIN32 _external_shared_link) |
---|
97 | ADD_COMPILER_FLAGS("-DOGRE_GUIRENDERER_STATIC_LIB" WIN32 NOT _external_shared_link) |
---|
98 | ADD_COMPILER_FLAGS("-DOIS_STATIC_LIB" WIN32 NOT _external_shared_link) |
---|
99 | |
---|
100 | ############## Include Directories ############## |
---|
101 | |
---|
102 | # Set the search paths for include files |
---|
103 | INCLUDE_DIRECTORIES( |
---|
104 | # OrxonoxConfig.h |
---|
105 | ${CMAKE_CURRENT_BINARY_DIR} |
---|
106 | |
---|
107 | # All includes in "externals" should be prefixed with the path |
---|
108 | # relative to "external" to avoid conflicts |
---|
109 | ${CMAKE_CURRENT_SOURCE_DIR}/external |
---|
110 | # Include directories needed even if only included by Orxonox |
---|
111 | ${CMAKE_CURRENT_SOURCE_DIR}/external/bullet |
---|
112 | ${CMAKE_CURRENT_SOURCE_DIR}/external/ois |
---|
113 | |
---|
114 | # External |
---|
115 | ${OGRE_INCLUDE_DIR} |
---|
116 | ${CEGUI_INCLUDE_DIR} |
---|
117 | ${CEGUI_TOLUA_INCLUDE_DIR} |
---|
118 | #${ENET_INCLUDE_DIR} |
---|
119 | ${Boost_INCLUDE_DIRS} |
---|
120 | ${POCO_INCLUDE_DIR} |
---|
121 | ${OPENAL_INCLUDE_DIRS} |
---|
122 | ${ALUT_INCLUDE_DIR} |
---|
123 | ${VORBIS_INCLUDE_DIR} |
---|
124 | ${OGG_INCLUDE_DIR} |
---|
125 | ${LUA5.1_INCLUDE_DIR} |
---|
126 | ${TCL_INCLUDE_PATH} |
---|
127 | ${DIRECTX_INCLUDE_DIR} |
---|
128 | ${ZLIB_INCLUDE_DIR} |
---|
129 | ) |
---|
130 | |
---|
131 | IF(CEGUI_OLD_VERSION) |
---|
132 | INCLUDE_DIRECTORIES(${CEGUILUA_INCLUDE_DIR}) |
---|
133 | ENDIF() |
---|
134 | |
---|
135 | IF (DBGHELP_FOUND) |
---|
136 | INCLUDE_DIRECTORIES(${DBGHELP_INCLUDE_DIR}) |
---|
137 | ENDIF() |
---|
138 | |
---|
139 | IF(VISUAL_LEAK_DETECTOR_ENABLE) |
---|
140 | INCLUDE_DIRECTORIES(${VLD_INCLUDE_DIR}) |
---|
141 | ENDIF() |
---|
142 | |
---|
143 | ############## CEGUI OGRE Renderer ############## |
---|
144 | |
---|
145 | IF(CEGUI_OGRE_RENDERER_BUILD_REQUIRED) |
---|
146 | SET(CEGUI_OGRE_RENDERER_LIBRARY ogreceguirenderer_orxonox) |
---|
147 | ENDIF() |
---|
148 | |
---|
149 | ################### Tolua Bind ################## |
---|
150 | |
---|
151 | # Create directory because the tolua application doesn't work otherwise |
---|
152 | IF(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/toluabind/${CMAKE_CFG_INTDIR}) |
---|
153 | FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/toluabind/${CMAKE_CFG_INTDIR}) |
---|
154 | ENDIF() |
---|
155 | |
---|
156 | INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/toluabind/${CMAKE_CFG_INTDIR}) |
---|
157 | |
---|
158 | ################ Sub Directories ################ |
---|
159 | |
---|
160 | ADD_SUBDIRECTORY(external) |
---|
161 | ADD_SUBDIRECTORY(libraries) |
---|
162 | ADD_SUBDIRECTORY(orxonox) |
---|
163 | SET(ORXONOX_MODULES CACHE INTERNAL "") |
---|
164 | ADD_SUBDIRECTORY(modules) |
---|
165 | |
---|
166 | ################## Executable ################### |
---|
167 | |
---|
168 | INCLUDE_DIRECTORIES( |
---|
169 | ${CMAKE_CURRENT_SOURCE_DIR}/libraries |
---|
170 | ${CMAKE_CURRENT_SOURCE_DIR}/orxonox |
---|
171 | ) |
---|
172 | |
---|
173 | # Translate argument |
---|
174 | IF(ORXONOX_USE_WINMAIN) |
---|
175 | SET(ORXONOX_WIN32 WIN32) |
---|
176 | ENDIF() |
---|
177 | |
---|
178 | SET(ORXONOX_MAIN_FILES Orxonox.cc) |
---|
179 | |
---|
180 | # Add special source file for OS X |
---|
181 | IF(APPLE) |
---|
182 | LIST(APPEND ORXONOX_MAIN_FILES OrxonoxMac.mm) |
---|
183 | ENDIF() |
---|
184 | |
---|
185 | ORXONOX_ADD_EXECUTABLE(orxonox-main |
---|
186 | # When defined as WIN32 this removes the console window on Windows |
---|
187 | ${ORXONOX_WIN32} |
---|
188 | LINK_LIBRARIES |
---|
189 | orxonox |
---|
190 | SOURCE_FILES |
---|
191 | ${ORXONOX_MAIN_FILES} |
---|
192 | OUTPUT_NAME orxonox |
---|
193 | ) |
---|
194 | # Main executable should depend on all modules |
---|
195 | ADD_DEPENDENCIES(orxonox-main ${ORXONOX_MODULES}) |
---|
196 | |
---|
197 | # Get name to configure the run scripts |
---|
198 | GET_TARGET_PROPERTY(_exec_loc orxonox-main LOCATION) |
---|
199 | GET_FILENAME_COMPONENT(_exec_name ${_exec_loc} NAME) |
---|
200 | SET(ORXONOX_EXECUTABLE_NAME ${_exec_name} CACHE INTERNAL "") |
---|
201 | |
---|
202 | |
---|
203 | # When using Visual Studio we want to use the output directory as working |
---|
204 | # directory and we also want to specify where the external dlls |
---|
205 | # (lua, ogre, etc.) are. The problem hereby is that these information cannot |
---|
206 | # be specified in CMake because they are not stored in the actual project file. |
---|
207 | # This workaround will create a configured *.vcproj.user file that holds the |
---|
208 | # right values. When starting the solution for the first time, |
---|
209 | # these get written to the *vcproj.yourPCname.yourname.user |
---|
210 | IF(MSVC) |
---|
211 | IF(CMAKE_CL_64) |
---|
212 | SET(MSVC_PLATFORM "x64") |
---|
213 | ELSE() |
---|
214 | SET(MSVC_PLATFORM "Win32") |
---|
215 | ENDIF() |
---|
216 | IF(MSVC10) |
---|
217 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/orxonox-main.vcxproj.user.in" "${CMAKE_CURRENT_BINARY_DIR}/orxonox-main.vcxproj.user") |
---|
218 | ELSE() |
---|
219 | STRING(REGEX REPLACE "^Visual Studio ([0-9][0-9]?).*$" "\\1" |
---|
220 | VISUAL_STUDIO_VERSION_SIMPLE "${CMAKE_GENERATOR}") |
---|
221 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/orxonox-main.vcproj.user.in" "${CMAKE_CURRENT_BINARY_DIR}/orxonox-main.vcproj.user") |
---|
222 | ENDIF() |
---|
223 | ENDIF(MSVC) |
---|
224 | |
---|
225 | # Apple Mac OS X specific build settings |
---|
226 | IF(APPLE) |
---|
227 | # On Apple we need to link to AppKit and Foundation frameworks |
---|
228 | TARGET_LINK_LIBRARIES(orxonox-main |
---|
229 | "-framework AppKit" |
---|
230 | "-framework Foundation" |
---|
231 | ) |
---|
232 | |
---|
233 | # Post-build step for the creation of the Dev-App bundle |
---|
234 | INCLUDE(PrepareDevBundle) |
---|
235 | ADD_CUSTOM_COMMAND( |
---|
236 | TARGET orxonox-main |
---|
237 | POST_BUILD |
---|
238 | # Copy the executable into the Orxonox.app |
---|
239 | COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/${ORXONOX_EXECUTABLE_NAME}" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/${PROJECT_NAME}.app/Contents/MacOS" |
---|
240 | # Copy the dev-build marker file to Orxonox.app |
---|
241 | COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/orxonox_dev_build.keep_me" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/${PROJECT_NAME}.app/Contents/MacOS" |
---|
242 | # Create a shortcut of the application to the root of the build tree |
---|
243 | COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/${PROJECT_NAME}.app" "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.app" |
---|
244 | ) |
---|
245 | ENDIF(APPLE) |
---|
246 | |
---|
247 | #################### Doxygen #################### |
---|
248 | |
---|
249 | # Prepare include paths for Doxygen. This is necessary to display |
---|
250 | # the correct path to use when including a file, e.g. |
---|
251 | # core/XMLPort.h instead of src/core/XMLPort.h |
---|
252 | |
---|
253 | INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/modules) |
---|
254 | GET_DIRECTORY_PROPERTY(_temp INCLUDE_DIRECTORIES) |
---|
255 | # Replace ';' by spaces |
---|
256 | STRING(REPLACE ";" " " _temp "${_temp}") |
---|
257 | SET(DOXYGEN_INCLUDE_DIRECTORIES "${_temp}" PARENT_SCOPE) |
---|