Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 855 lines (723 sloc) 25.77 kB
6dd3c00 @dscharrer [cmake] Relax minimum CMake version requirement for non-MSVC compilers.
dscharrer authored
1 project(ArxLibertatis)
2
3 if(MSVC)
4 # CMake 2.8.5 or newer is needed for CMAKE_LIBRARY_ARCHITECTURE support.
5 cmake_minimum_required(VERSION 2.8.5)
6 # Change CMAKE_LIBRARY_ARCHITECTURE to ensure the right libs are used
7 if(CMAKE_CL_64)
8 set(CMAKE_LIBRARY_ARCHITECTURE "x64")
9 else()
10 set(CMAKE_LIBRARY_ARCHITECTURE "x86")
11 endif(CMAKE_CL_64)
12 else()
13 cmake_minimum_required(VERSION 2.8)
14 endif()
9c3e84d @lubosz stubby cmake build
lubosz authored
15
cbf67dd @dscharrer Use boost::filesystem to load non-packed asset files.
dscharrer authored
16 # For custom cmake modules.
17 set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
18
12825f4 @dscharrer Check size of char in CMakeLists.txt
dscharrer authored
19 include(CheckTypeSize)
7fa9f82 @dscharrer Write configure options to a header instead of passing them on the co…
dscharrer authored
20 include(CheckSymbolExists)
21 include(CheckCXXSourceCompiles)
22
f67374f @dscharrer Merge tools build into the main CMakeLists.txt and automatically extr…
dscharrer authored
23 include(BuildSystem)
cbf67dd @dscharrer Use boost::filesystem to load non-packed asset files.
dscharrer authored
24 include(CompileCheck)
1ea3ead @dscharrer Automatically generate a version string at build time.
dscharrer authored
25 include(VersionString)
e067d34 @dscharrer Add a ARX_FORCE_32BIT option to force a 32-bit build on 64-bit systems.
dscharrer authored
26
b7b0735 @SebastienLussier [CMake] Changed create_source_groups() to create a hierarchy that rep…
SebastienLussier authored
27 # Accepts a variable holding the source files
28 # and creates source groups (for VS, Xcode etc)
29 # that replicate the folder hierarchy on disk
30 macro( create_source_groups source_files_variable )
31 foreach( source_file ${${source_files_variable}} )
32 string( REGEX REPLACE ${CMAKE_CURRENT_SOURCE_DIR} "" relative_directory "${source_file}")
33 string( REGEX REPLACE "[\\\\/][^\\\\/]*$" "" relative_directory "${relative_directory}")
34 string( REGEX REPLACE "^[\\\\/]" "" relative_directory "${relative_directory}")
35
36 if( WIN32 )
37 string( REGEX REPLACE "/" "\\\\" relative_directory "${relative_directory}" )
38 endif( WIN32 )
39
40 source_group( "${relative_directory}" FILES ${source_file} )
41 endforeach()
42 endmacro()
5c2d73a @SebastienLussier Fixed VC2010 warnings/errors/projects
SebastienLussier authored
43
1f84e23 @SebastienLussier Added support for unity build (set env var "ARX_USE_UNITYBUILD=1" to …
SebastienLussier authored
44 ##############################################################################
45
5d3c963 @dscharrer Don't build tests by default as they don't work.
dscharrer authored
46 option(ARX_BUILD_TESTS "Build tests" OFF)
eb66ca0 @dscharrer Add descriptions to options in CMakeLists.txt so the default values d…
dscharrer authored
47 option(ARX_BUILD_TOOLS "Build tools" ON)
ec98148 @dscharrer Add stub SDL Window and InputBackend and OpenGL Renderer implementati…
dscharrer authored
48 option(ARX_BUILD_EDITOR "Build editor" OFF)
05cc8a6 @dscharrer Make building .scn file support optional. (raw unprocessed scenes, no…
dscharrer authored
49 option(ARX_BUILD_EDIT_LOADSAVE "Build save/load functions only used by the editor" ON)
eb66ca0 @dscharrer Add descriptions to options in CMakeLists.txt so the default values d…
dscharrer authored
50 option(ARX_USE_UNITYBUILD "Unity build" OFF)
a513d90 @dscharrer Add option to enbale GLIBC runtime debug checks.
dscharrer authored
51 option(ARX_DEBUG_EXTRA "Expensive debug options" OFF)
41d57f0 @dscharrer Make building the OpenAL and DirectSound backends optional.
dscharrer authored
52 option(ARX_USE_OPENAL "Build the OpenAL audio backend." ON)
7de379a @dscharrer Disable DirectX backends on linux; remove the ARX_FORCE_32BIT option;…
dscharrer authored
53 option(ARX_USE_DSOUND "Build the DirectSound audio backend." ON)
ec98148 @dscharrer Add stub SDL Window and InputBackend and OpenGL Renderer implementati…
dscharrer authored
54 option(ARX_USE_OPENGL "Build the OpenGL renderer backend." ON)
365d73b @SebastienLussier First working implementation of Arx using DirectX 9 (D3D9 & DInput8)
SebastienLussier authored
55 option(ARX_USE_D3D9 "Build the Direct3D 9 renderer backend." ON)
ec98148 @dscharrer Add stub SDL Window and InputBackend and OpenGL Renderer implementati…
dscharrer authored
56 option(ARX_USE_SDL "Build the SDL windowing backend." ON)
365d73b @SebastienLussier First working implementation of Arx using DirectX 9 (D3D9 & DInput8)
SebastienLussier authored
57 option(ARX_USE_DINPUT8 "Build the DirectInput 8 input backend." ON)
e067d34 @dscharrer Add a ARX_FORCE_32BIT option to force a 32-bit build on 64-bit systems.
dscharrer authored
58
7de379a @dscharrer Disable DirectX backends on linux; remove the ARX_FORCE_32BIT option;…
dscharrer authored
59 if((NOT LAST_CMAKE_CXX_FLAGS STREQUAL CMAKE_CXX_FLAGS) OR (NOT LAST_CMAKE_CXX_COMPILER STREQUAL CMAKE_CXX_COMPILER))
e067d34 @dscharrer Add a ARX_FORCE_32BIT option to force a 32-bit build on 64-bit systems.
dscharrer authored
60 force_recheck_library(DevIL IL)
61 force_recheck_library(ZLIB)
62 force_recheck_library(Freetype)
63 force_recheck_library(Threads)
3d874d1 @dscharrer Check if we can actually link against teh found OpenAL library.
dscharrer authored
64 force_recheck_library(OpenAL)
c5fb0d8 @dscharrer Check if we can link against the OpenGL library.
dscharrer authored
65 force_recheck_library(OpenGL)
d140a05 @dscharrer Start implementing OpenGLRenderer.
dscharrer authored
66 force_recheck_library(GLEW)
519b7f1 @dscharrer Add Boost as a dependency.
dscharrer authored
67 force_recheck_library(Boost)
68 unset(Boost_INCLUDE_DIR CACHE)
7de379a @dscharrer Disable DirectX backends on linux; remove the ARX_FORCE_32BIT option;…
dscharrer authored
69 set(LAST_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE INTERNAL "The last C++ compiler flags.")
70 set(LAST_CMAKE_CXX_COMPILER "${CMAKE_CXX_COMPILER}" CACHE INTERNAL "The last C++ compiler.")
e067d34 @dscharrer Add a ARX_FORCE_32BIT option to force a 32-bit build on 64-bit systems.
dscharrer authored
71 endif()
a36e2b1 @SebastienLussier Sort the unity build files list + changed ARX_USE_UNITYBUILD to a cma…
SebastienLussier authored
72
1c5f4e9 @dscharrer Fix wine build.
dscharrer authored
73 if(WINE)
74 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -U_WIN32 -U__CYGWIN__ -U__WIN32__ -UWIN32")
75 set(HAVE_WINAPI 1)
76 elseif(WIN32)
6ea23a6 @dscharrer Fix MinGW32 build, improve the crash handler.
dscharrer authored
77 if(NOT MSVC)
78 # We need to define WINVER for MinGW32 when requiring anything newer than Win95 / WinNT
79 add_definitions(-DWINVER=0x0500) # Require at least Windows 2000
80 endif()
8a115ab @dscharrer Don't check for OpenGL libraries when using winelib.
dscharrer authored
81 set(HAVE_WINAPI 1)
82 else()
83 set(HAVE_WINAPI 0)
84 endif()
85
86 if(NOT HAVE_WINAPI)
87 # The is no DirectX under linux
365d73b @SebastienLussier First working implementation of Arx using DirectX 9 (D3D9 & DInput8)
SebastienLussier authored
88 set(ARX_USE_D3D9 OFF)
8a115ab @dscharrer Don't check for OpenGL libraries when using winelib.
dscharrer authored
89 set(ARX_USE_DSOUND OFF)
365d73b @SebastienLussier First working implementation of Arx using DirectX 9 (D3D9 & DInput8)
SebastienLussier authored
90 set(ARX_USE_DINPUT8 OFF)
91 else()
92 if(ARX_USE_D3D9)
93 find_package(DirectX REQUIRED)
94 endif()
8a115ab @dscharrer Don't check for OpenGL libraries when using winelib.
dscharrer authored
95 endif()
96
9ca39c4 @SebastienLussier Added freetype using find_package() in CMakeList.txt
SebastienLussier authored
97 find_package(Freetype REQUIRED)
734fab0 @dscharrer Use find_package in CMakeLists.txt instead of hardcoding library name…
dscharrer authored
98 find_package(DevIL REQUIRED)
99 find_package(ZLIB REQUIRED)
100 find_package(Threads REQUIRED)
c105d07 @dscharrer Make building the OpenGLRenderer optional, disabled by default.
dscharrer authored
101 if(ARX_USE_OPENGL)
102 find_package(OpenGL REQUIRED)
d140a05 @dscharrer Start implementing OpenGLRenderer.
dscharrer authored
103 find_package(GLEW REQUIRED)
c105d07 @dscharrer Make building the OpenGLRenderer optional, disabled by default.
dscharrer authored
104 endif()
3b2fea8 @SebastienLussier Fix bad merge + issue with std::vsnprintf
SebastienLussier authored
105 if(ARX_USE_OPENAL)
b43b234 @dscharrer Make the OpenAL effect extension optional so we can build against old…
dscharrer authored
106 find_package(OpenAL 1.1 REQUIRED)
107 find_package(OpenALEFX)
41d57f0 @dscharrer Make building the OpenAL and DirectSound backends optional.
dscharrer authored
108 endif()
734fab0 @dscharrer Use find_package in CMakeLists.txt instead of hardcoding library name…
dscharrer authored
109 find_package(Doxygen)
110 find_package(PythonInterp)
ec98148 @dscharrer Add stub SDL Window and InputBackend and OpenGL Renderer implementati…
dscharrer authored
111 if(ARX_USE_SDL)
1c49525 @SebastienLussier Updated CMakeLists.txt to add 64-bit support under Windows + misc cha…
SebastienLussier authored
112 set(SDL_BUILDING_LIBRARY 1) # Required to avoid linking with SDLmain...
ec98148 @dscharrer Add stub SDL Window and InputBackend and OpenGL Renderer implementati…
dscharrer authored
113 find_package(SDL 1.2 EXACT REQUIRED)
114 endif()
734fab0 @dscharrer Use find_package in CMakeLists.txt instead of hardcoding library name…
dscharrer authored
115
8c6e31b @SebastienLussier Link statically with Boost under msvc
SebastienLussier authored
116 if(MSVC)
117 # Link statically with Boost under Windows
118 set(Boost_USE_STATIC_LIBS ON)
119 endif(MSVC)
b574763 @dscharrer Add a POSIX filesystem implementation that will be used if Boost file…
dscharrer authored
120
4db4d9c @dscharrer Detect user/data directory locations.
dscharrer authored
121 set(BOOST_COMPONENTS program_options filesystem system)
122 find_package(Boost REQUIRED COMPONENTS ${BOOST_COMPONENTS})
734fab0 @dscharrer Use find_package in CMakeLists.txt instead of hardcoding library name…
dscharrer authored
123
124 mark_as_advanced(IL_INCLUDE_DIR)
125 mark_as_advanced(ILUT_LIBRARIES)
126 mark_as_advanced(ILU_LIBRARIES)
127 mark_as_advanced(IL_LIBRARIES)
3e661ac @lubosz options for not buildings tests and tools
lubosz authored
128
7a4b058 @lubosz fixed formatting and include folder
lubosz authored
129 set(SRC_DIR src)
130 set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin)
5c2d73a @SebastienLussier Fixed VC2010 warnings/errors/projects
SebastienLussier authored
131
1c49525 @SebastienLussier Updated CMakeLists.txt to add 64-bit support under Windows + misc cha…
SebastienLussier authored
132 if(MSVC)
5c2d73a @SebastienLussier Fixed VC2010 warnings/errors/projects
SebastienLussier authored
133 # Remove targets we don't really use (RelWithDebInfo, MinSizeRel)
1c49525 @SebastienLussier Updated CMakeLists.txt to add 64-bit support under Windows + misc cha…
SebastienLussier authored
134 # TODO - Does not seem to work...
5c2d73a @SebastienLussier Fixed VC2010 warnings/errors/projects
SebastienLussier authored
135 set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Using only Debug and Release" FORCE)
9c8ee72 Now builds under Windows with MSVC. Removed a lot of warnings, but a …
slussier authored
136
137 # Disable deprecation warnings
90b2db2 @SebastienLussier Updated CMakeLists.txt to generate nicer vs project
SebastienLussier authored
138 add_definitions(-D_CRT_SECURE_NO_WARNINGS)
9c8ee72 Now builds under Windows with MSVC. Removed a lot of warnings, but a …
slussier authored
139 add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
a918ef4 @SebastienLussier Fixed sources groups to fit new folder structure
SebastienLussier authored
140 add_definitions(-D_SCL_SECURE_NO_WARNINGS)
1c49525 @SebastienLussier Updated CMakeLists.txt to add 64-bit support under Windows + misc cha…
SebastienLussier authored
141 add_definitions(/wd4995) # 'func': name was marked as #pragma deprecated
9c8ee72 Now builds under Windows with MSVC. Removed a lot of warnings, but a …
slussier authored
142
d0d4145 @SebastienLussier * Switched to lowercase types (ex: s32 instead of S32)
SebastienLussier authored
143 # TEMP - disable warning caused by the F2L removal
1c49525 @SebastienLussier Updated CMakeLists.txt to add 64-bit support under Windows + misc cha…
SebastienLussier authored
144 add_definitions(/wd4244) # Conversion from 'float' to 'long', possible loss of data
145
146 # TEMP - disable warning caused by conversion from a 64-bit type to a 32-bit one...
147 if(CMAKE_CL_64)
148 add_definitions(/wd4267) # Conversion from 'size_t' to 'xxx', possible loss of data
149 endif()
0a51801 @SebastienLussier msvc - Removed some costly checks when building without ARX_DEBUG_EXTRA
SebastienLussier authored
150
151 if(NOT ARX_DEBUG_EXTRA)
152 add_definitions(-D_HAS_ITERATOR_DEBUGGING=0)
153 add_definitions(-D_SECURE_SCL=0)
154 add_definitions(-D_SECURE_SCL_THROWS=0)
155 add_definitions(-D_ITERATOR_DEBUG_LEVEL=0)
156 endif()
5c2d73a @SebastienLussier Fixed VC2010 warnings/errors/projects
SebastienLussier authored
157
1d0faae @SebastienLussier Disabled exception handling and RTTI
SebastienLussier authored
158 # Disable exceptions & rtti
1c49525 @SebastienLussier Updated CMakeLists.txt to add 64-bit support under Windows + misc cha…
SebastienLussier authored
159 add_definitions(/wd4530) # C++ exception handling was used but /EHsc was not selected.
160 add_definitions(/GR-) # No RTTI
161
162 foreach(flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
163 # Disable exceptions
164 string(REGEX REPLACE "/EHsc" "" ${flag_var} "${${flag_var}}")
5004296 @dscharrer Fix some mingw32 compile issues.
dscharrer authored
165
1c49525 @SebastienLussier Updated CMakeLists.txt to add 64-bit support under Windows + misc cha…
SebastienLussier authored
166 # Change runtime library from "Multi-threaded Debug DLL" to "Multi-threaded DLL"
5004296 @dscharrer Fix some mingw32 compile issues.
dscharrer authored
167 string(REGEX REPLACE "/MDd" "/MD" ${flag_var} "${${flag_var}}")
168
1c49525 @SebastienLussier Updated CMakeLists.txt to add 64-bit support under Windows + misc cha…
SebastienLussier authored
169 # Remove definition of _DEBUG as it might conflict with libs we're linking with
5004296 @dscharrer Fix some mingw32 compile issues.
dscharrer authored
170 string(REGEX REPLACE "/D_DEBUG" "/DNDEBUG" ${flag_var} "${${flag_var}}")
1c49525 @SebastienLussier Updated CMakeLists.txt to add 64-bit support under Windows + misc cha…
SebastienLussier authored
171 endforeach(flag_var)
5004296 @dscharrer Fix some mingw32 compile issues.
dscharrer authored
172
1c49525 @SebastienLussier Updated CMakeLists.txt to add 64-bit support under Windows + misc cha…
SebastienLussier authored
173 # Avoid warning during link
174 set(CMAKE_EXE_LINKER_FLAGS /NODEFAULTLIB:LIBCMT)
175
5004296 @dscharrer Fix some mingw32 compile issues.
dscharrer authored
176 # This is needed to use ZLIB as a DLL
1c49525 @SebastienLussier Updated CMakeLists.txt to add 64-bit support under Windows + misc cha…
SebastienLussier authored
177 add_definitions(-DZLIB_WINAPI)
1d0faae @SebastienLussier Disabled exception handling and RTTI
SebastienLussier authored
178
ab07b50 @dscharrer Use consistent casing in CMakeLists.txt
dscharrer authored
179 else(MSVC)
ec98148 @dscharrer Add stub SDL Window and InputBackend and OpenGL Renderer implementati…
dscharrer authored
180
8449180 @dscharrer Fix compile errors in 64-bit build.
dscharrer authored
181 # Check the dependencies so there won't by cryptic link errors later on when found libraries have the wrong architecture (32- vs. 64-bit)
822c9c0 @dscharrer Fix support for non-wine, non-msvc compilers (like mingw) in CMakeLis…
dscharrer authored
182 if(CMAKE_THREAD_LIBS_INIT)
183 check_link_library(Threads CMAKE_THREAD_LIBS_INIT)
184 endif()
26f3a28 @dscharrer If we cannot link to the exact libraries found by cmake try linking a…
dscharrer authored
185 check_link_library(DevIL IL_LIBRARIES IL)
186 check_link_library(ZLIB ZLIB_LIBRARIES)
187 check_link_library(Freetype FREETYPE_LIBRARIES)
41d57f0 @dscharrer Make building the OpenAL and DirectSound backends optional.
dscharrer authored
188 if(ARX_USE_OPENAL)
189 check_link_library(OpenAL OPENAL_LIBRARY)
190 endif()
c105d07 @dscharrer Make building the OpenGLRenderer optional, disabled by default.
dscharrer authored
191 if(ARX_USE_OPENGL)
192 check_link_library(OpenGL OPENGL_LIBRARIES)
d140a05 @dscharrer Start implementing OpenGLRenderer.
dscharrer authored
193 check_link_library(GLEW GLEW_LIBRARIES)
c105d07 @dscharrer Make building the OpenGLRenderer optional, disabled by default.
dscharrer authored
194 endif()
ec98148 @dscharrer Add stub SDL Window and InputBackend and OpenGL Renderer implementati…
dscharrer authored
195 if(ARX_USE_SDL)
196 check_link_library(SDL SDL_LIBRARY)
197 endif()
734fab0 @dscharrer Use find_package in CMakeLists.txt instead of hardcoding library name…
dscharrer authored
198
7fa9f82 @dscharrer Write configure options to a header instead of passing them on the co…
dscharrer authored
199 set(CMAKE_REQUIRED_DEFINITIONS "-D_POSIX_C_SOURCE=199309")
200 set(CMAKE_REQUIRED_LIBRARIES "-lrt")
a27f5b8 @dscharrer Implement SDLWindow.
dscharrer authored
201 check_symbol_exists(nanosleep "time.h" HAVE_NANOSLEEP_FUNC)
7fa9f82 @dscharrer Write configure options to a header instead of passing them on the co…
dscharrer authored
202 check_symbol_exists(clock_gettime "time.h" HAVE_CLOCK_GETTIME)
203 unset(CMAKE_REQUIRED_DEFINITIONS)
204 unset(CMAKE_REQUIRED_LIBRARIES)
a27f5b8 @dscharrer Implement SDLWindow.
dscharrer authored
205 if(HAVE_NANOSLEEP_FUNC OR HAVE_CLOCK_GETTIME)
7fa9f82 @dscharrer Write configure options to a header instead of passing them on the co…
dscharrer authored
206 set(TIME_LIBRARIES "-lrt")
207 add_definitions(-D_POSIX_C_SOURCE=199309)
208 endif()
209
4db4d9c @dscharrer Detect user/data directory locations.
dscharrer authored
210 check_include_file("wordexp.h" HAVE_WORDEXP_H)
211
3ebc8d6 @dscharrer Fix mingw32 build.
dscharrer authored
212 check_include_files("sys/stat.h;sys/errno.h;dirent.h" HAVE_POSIX_FILESYSTEM)
213
6ea23a6 @dscharrer Fix MinGW32 build, improve the crash handler.
dscharrer authored
214 check_symbol_exists(strsignal "string.h" HAVE_STRSIGNAL)
215 check_symbol_exists(fork "unistd.h" HAVE_FORK)
216 check_symbol_exists(readlink "unistd.h" HAVE_READLINK)
217 check_symbol_exists(dup2 "unistd.h" HAVE_DUP2)
218 check_symbol_exists(execlp "unistd.h" HAVE_EXECLP)
57a38b8 @dscharrer [fs] Make the POSIX implementation if directory_iterator threadsafe.
dscharrer authored
219 check_symbol_exists(fpathconf "unistd.h" HAVE_FPATHCONF)
220 check_symbol_exists(dirfd "dirent.h" HAVE_DIRFD)
69c6305 @dscharrer Fix mingw32 build.
dscharrer authored
221 if(NOT WIN32)
222 check_symbol_exists(isatty "unistd.h" HAVE_ISATTY)
223 endif()
6ea23a6 @dscharrer Fix MinGW32 build, improve the crash handler.
dscharrer authored
224 check_symbol_exists(waitpid "sys/wait.h" HAVE_WAITPID)
225 check_symbol_exists(kill "signal.h" HAVE_KILL)
226 check_symbol_exists(backtrace "execinfo.h" HAVE_BACKTRACE)
227 check_symbol_exists(backtrace_symbols_fd "execinfo.h" HAVE_BACKTRACE_SYMBOLS_FD)
9490540 @dscharrer Add a crash handler that prints very detailed stack traces if gdb is …
dscharrer authored
228
5c954b9 @dscharrer Enable more warnings on gcc.
dscharrer authored
229 # Warning level
13ce969 @dscharrer Check if compiler options are supported in CMakeLists.txt
dscharrer authored
230 add_cxxflag("-Wall")
231 add_cxxflag("-Wextra")
232 add_cxxflag("-Wformat=2")
233 add_cxxflag("-Wundef")
234 add_cxxflag("-Wpointer-arith")
235 add_cxxflag("-Wcast-qual")
236 add_cxxflag("-Woverloaded-virtual")
237 add_cxxflag("-Wlogical-op")
238
239 add_cxxflag("-Wliteral-conversion")
240 add_cxxflag("-Wshift-overflow")
ec867ea @dscharrer Add more warning switches.
dscharrer authored
241 add_cxxflag("-Woverflow")
242 add_cxxflag("-Wbool-conversions")
13ce969 @dscharrer Check if compiler options are supported in CMakeLists.txt
dscharrer authored
243
244 # TODO enable:
245 # add_cxxflag("-Wconversion") # very noisy
246 # add_cxxflag("-Wsign-conversion") # very noisy
247 # add_cxxflag("-Wmissing-declarations") # to catch functions that should be marked as static
248 # add_cxxflag("-Wredundant-decls") # to catch extern definitions in .cpp files (with UNITYBUILD)
7a9b106 @dscharrer Add debug option in CMakeLists.txt
dscharrer authored
249
98d59e9 @lubosz [build] Change debug build behavior
lubosz authored
250 if(CMAKE_BUILD_TYPE STREQUAL Debug)
68f8415 @dscharrer [cmake] Make sure there is always only one -g* compiler option.
dscharrer authored
251
7a9b106 @dscharrer Add debug option in CMakeLists.txt
dscharrer authored
252 #Debug
68f8415 @dscharrer [cmake] Make sure there is always only one -g* compiler option.
dscharrer authored
253 message("Debug Build")
5c2d73a @SebastienLussier Fixed VC2010 warnings/errors/projects
SebastienLussier authored
254 add_definitions(-D_DEBUG)
68f8415 @dscharrer [cmake] Make sure there is always only one -g* compiler option.
dscharrer authored
255
256 check_compiler_flag(RESULT "-g3")
257 if(NOT RESULT STREQUAL "")
258 string(REGEX REPLACE "-g(|[0-9]|gdb)" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
259 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${RESULT}")
260 endif()
261
262 check_compiler_flag(RESULT "-O0")
263 string(REGEX REPLACE "-O[0-9]" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
264 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${RESULT}")
265
7a9b106 @dscharrer Add debug option in CMakeLists.txt
dscharrer authored
266 else()
68f8415 @dscharrer [cmake] Make sure there is always only one -g* compiler option.
dscharrer authored
267
7a9b106 @dscharrer Add debug option in CMakeLists.txt
dscharrer authored
268 #Release
68f8415 @dscharrer [cmake] Make sure there is always only one -g* compiler option.
dscharrer authored
269 message("Release Build")
5c2d73a @SebastienLussier Fixed VC2010 warnings/errors/projects
SebastienLussier authored
270 add_definitions(-D_NDEBUG)
68f8415 @dscharrer [cmake] Make sure there is always only one -g* compiler option.
dscharrer authored
271
7a9b106 @dscharrer Add debug option in CMakeLists.txt
dscharrer authored
272 endif()
f9b122d @lubosz define HAVE_PTHREADS in cmake
lubosz authored
273
a513d90 @dscharrer Add option to enbale GLIBC runtime debug checks.
dscharrer authored
274 if(ARX_DEBUG_EXTRA)
275 add_definitions(-D_GLIBCXX_DEBUG) # Runtime checks for STL containers.
13ce969 @dscharrer Check if compiler options are supported in CMakeLists.txt
dscharrer authored
276 # add_cxxflag("-Wsuggest-attribute=const")
277 # add_cxxflag("-Wsuggest-attribute=pure")
b8f5ed0 @dscharrer Enable more runtime checks for ARX_DEBUG_EXTRA.
dscharrer authored
278 add_cxxflag("-ftrapv") # to add checks for (undefined) signed integer overflow
279 add_cxxflag("-fcatch-undefined-behavior") # (clang)
ec867ea @dscharrer Add more warning switches.
dscharrer authored
280 add_cxxflag("-fbounds-checking")
0c66651 @dscharrer Remove the _WIN32 added by winegcc so that headers of native librarie…
dscharrer authored
281 else()
cfffed9 @dscharrer Disable unitialized variable warnings on normal builds because of fa…
dscharrer authored
282 # -Wuninitialized causes too many false positives
13ce969 @dscharrer Check if compiler options are supported in CMakeLists.txt
dscharrer authored
283 add_cxxflag("-Wno-uninitialized")
7a9b106 @dscharrer Add debug option in CMakeLists.txt
dscharrer authored
284 endif()
bc5eff0 @dscharrer Add -fwhole-program for unity build on gcc.
dscharrer authored
285
13ce969 @dscharrer Check if compiler options are supported in CMakeLists.txt
dscharrer authored
286 if(ARX_USE_UNITYBUILD)
287 add_cxxflag("-fwhole-program")
0f6542a @dscharrer Add an option for link-time optimizations to CMakeLists.txt
dscharrer authored
288 endif()
289
42b09f2 @dscharrer Add workaround for issues with ekopath and -fno-rtti.
dscharrer authored
290 if(CMAKE_CXX_COMPILER_ID STREQUAL "PathScale")
291 # The standard library shipped with ekopath failes to compile with -fno-rtti
292 # See https://github.com/pathscale/stdcxx/issues/3
293 add_definitions(-D_RWSTD_NO_DYNAMIC_CAST)
294 endif()
295
ab07b50 @dscharrer Use consistent casing in CMakeLists.txt
dscharrer authored
296 endif(MSVC)
c058032 @lubosz build debug
lubosz authored
297
4db4d9c @dscharrer Detect user/data directory locations.
dscharrer authored
298 # Define default user and data directories.
299 if(NOT DEFINED DATA_DIR)
300 set(DATA_DIR "arx")
301 endif()
302 if(NOT DEFINED USER_DIR)
303 set(USER_DIR "arx")
304 endif()
305 if(WIN32 AND NOT WINE)
306 if(NOT DEFINED USER_DIR_PREFIXES)
307 set(USER_DIR_PREFIXES "%USERPROFILE%/My Documents/Games")
308 endif()
309 else()
310 if(NOT DEFINED DATA_DIR_PREFIXES)
311 set(DATA_DIR_PREFIXES "${CMAKE_INSTALL_PREFIX}/share:$XDG_DATA_DIRS")
312 endif()
313 if(NOT DEFINED USER_DIR_PREFIXES)
314 set(USER_DIR_PREFIXES "$XDG_DATA_HOME")
315 endif()
316 endif()
317 if(DATA_DIR STREQUAL "")
318 unset(DATA_DIR)
319 endif()
320 if(USER_DIR STREQUAL "")
321 unset(USER_DIR)
322 endif()
323 if(DATA_DIR_PREFIXES STREQUAL "")
324 unset(DATA_DIR_PREFIXES)
325 endif()
326 if(USER_DIR_PREFIXES STREQUAL "")
327 unset(USER_DIR_PREFIXES)
328 endif()
329
7fa9f82 @dscharrer Write configure options to a header instead of passing them on the co…
dscharrer authored
330 # Check that all required functionality is available.
734fab0 @dscharrer Use find_package in CMakeLists.txt instead of hardcoding library name…
dscharrer authored
331 if(CMAKE_USE_PTHREADS_INIT)
7fa9f82 @dscharrer Write configure options to a header instead of passing them on the co…
dscharrer authored
332 set(HAVE_PTHREADS 1)
734fab0 @dscharrer Use find_package in CMakeLists.txt instead of hardcoding library name…
dscharrer authored
333 elseif(NOT CMAKE_USE_WIN32_THREADS_INIT)
334 message(SEND_ERROR "No supported thread libraries found.")
335 endif()
7fa9f82 @dscharrer Write configure options to a header instead of passing them on the co…
dscharrer authored
336 if(NOT ARX_USE_OPENAL AND NOT ARX_USE_DSOUND)
337 message(WARNING "No audio backend enabled.")
338 endif()
66d2e6d @dscharrer Don't add windows.h-specific defines under linux.
dscharrer authored
339 if((NOT HAVE_NANOSLEEP_FUNC OR NOT HAVE_CLOCK_GETTIME) AND NOT HAVE_WINAPI)
7fa9f82 @dscharrer Write configure options to a header instead of passing them on the co…
dscharrer authored
340 message(SEND_ERROR "Need either nanosleep and clock_gettime or WIN32.")
341 endif()
20b0067 @lubosz added mingw as option, removed wine header include for wine gcc, updated
lubosz authored
342
90b2db2 @SebastienLussier Updated CMakeLists.txt to generate nicer vs project
SebastienLussier authored
343 # Preprocessor definitions
66d2e6d @dscharrer Don't add windows.h-specific defines under linux.
dscharrer authored
344 if(HAVE_WINAPI)
345 add_definitions(-DNOMINMAX)
346 add_definitions(-DWIN32_LEAN_AND_MEAN)
347 endif(HAVE_WINAPI)
d86c3fb @dscharrer Enable debug output and fix related errors.
dscharrer authored
348
f748b9d @dscharrer Fix unity build.
dscharrer authored
349 # Sources
350 set(AI_SOURCES
351 src/ai/PathFinder.cpp
352 src/ai/PathFinderManager.cpp
353 src/ai/Paths.cpp
354 )
355
356 set(ANIMATION_SOURCES
357 src/animation/Animation.cpp
358 src/animation/AnimationRender.cpp
359 src/animation/Cinematic.cpp
360 src/animation/CinematicKeyframer.cpp
361 src/animation/Intro.cpp
362 )
363
364 set(AUDIO_SOURCES
365 src/audio/Ambiance.cpp
366 src/audio/Audio.cpp
367 src/audio/AudioEnvironment.cpp
368 src/audio/AudioGlobal.cpp
369 src/audio/AudioResource.cpp
370 src/audio/AudioSource.cpp
371 src/audio/Mixer.cpp
372 src/audio/Sample.cpp
373 src/audio/Stream.cpp
374 src/audio/codec/ADPCM.cpp
375 src/audio/codec/RAW.cpp
376 src/audio/codec/WAV.cpp
377 )
378
379 set(AUDIO_OPENAL_SOURCES
380 src/audio/openal/OpenALBackend.cpp
381 src/audio/openal/OpenALSource.cpp
0cd1d4c @dscharrer Improve OpenAL error messages.
dscharrer authored
382 src/audio/openal/OpenALUtils.cpp
f748b9d @dscharrer Fix unity build.
dscharrer authored
383 )
384
385 set(AUDIO_DSOUND_SOURCES
386 src/audio/dsound/DSoundBackend.cpp
387 src/audio/dsound/DSoundSource.cpp
388 )
389
390 set(CORE_SOURCES
391 src/core/Application.cpp
a97d5de @dscharrer Rename Win32Application.{cpp,h} to ArxGame.{cpp,h}
dscharrer authored
392 src/core/ArxGame.cpp
f748b9d @dscharrer Fix unity build.
dscharrer authored
393 src/core/Config.cpp
394 src/core/Core.cpp
395 src/core/GameTime.cpp
396 src/core/Localisation.cpp
4db4d9c @dscharrer Detect user/data directory locations.
dscharrer authored
397 src/core/Startup.cpp
ec98148 @dscharrer Add stub SDL Window and InputBackend and OpenGL Renderer implementati…
dscharrer authored
398 )
399
f748b9d @dscharrer Fix unity build.
dscharrer authored
400 set(EDITOR_SOURCES
401 src/core/Dialog.cpp
402 src/script/ScriptDebugger.cpp
403 src/script/ScriptDebuggerDialog.cpp
404 )
405
406 set(GAME_SOURCES
407 src/game/Damage.cpp
408 src/game/Equipment.cpp
409 src/game/Inventory.cpp
410 src/game/Levels.cpp
411 src/game/Map.cpp
412 src/game/Missile.cpp
413 src/game/NPC.cpp
414 src/game/Player.cpp
415 src/game/Spells.cpp
416 )
417
418 set(GRAPHICS_SOURCES
419 src/graphics/Draw.cpp
420 src/graphics/GraphicsModes.cpp
421 src/graphics/GraphicsUtility.cpp
422 src/graphics/Math.cpp
423 src/graphics/Renderer.cpp
424 src/graphics/data/CinematicTexture.cpp
425 src/graphics/data/FTL.cpp
426 src/graphics/data/Mesh.cpp
427 src/graphics/data/MeshManipulation.cpp
428 src/graphics/data/Progressive.cpp
429 src/graphics/data/TextureContainer.cpp
430 src/graphics/effects/CinematicEffects.cpp
431 src/graphics/effects/DrawEffects.cpp
432 src/graphics/effects/Fog.cpp
433 src/graphics/effects/SpellEffects.cpp
434 src/graphics/font/Font.cpp
435 src/graphics/font/FontCache.cpp
436 src/graphics/image/Image.cpp
437 src/graphics/particle/Particle.cpp
438 src/graphics/particle/ParticleEffects.cpp
439 src/graphics/particle/ParticleManager.cpp
440 src/graphics/particle/ParticleSystem.cpp
441 src/graphics/spells/Spells01.cpp
442 src/graphics/spells/Spells02.cpp
443 src/graphics/spells/Spells03.cpp
444 src/graphics/spells/Spells04.cpp
445 src/graphics/spells/Spells05.cpp
446 src/graphics/spells/Spells06.cpp
447 src/graphics/spells/Spells07.cpp
448 src/graphics/spells/Spells08.cpp
449 src/graphics/spells/Spells09.cpp
450 src/graphics/spells/Spells10.cpp
451 src/graphics/texture/PackedTexture.cpp
452 src/graphics/texture/Texture.cpp
453 src/graphics/texture/TextureStage.cpp
454 )
a996870 @SebastienLussier [DX7] Removed all dx7 backends (please don't cry)
SebastienLussier authored
455
365d73b @SebastienLussier First working implementation of Arx using DirectX 9 (D3D9 & DInput8)
SebastienLussier authored
456 set(GRAPHICS_D3D9_SOURCES
457 src/graphics/d3d9/D3D9Renderer.cpp
458 src/graphics/d3d9/D3D9Texture2D.cpp
459 src/graphics/d3d9/D3D9TextureStage.cpp
f748b9d @dscharrer Fix unity build.
dscharrer authored
460 )
461 set(GRAPHICS_OPENGL_SOURCES
ec98148 @dscharrer Add stub SDL Window and InputBackend and OpenGL Renderer implementati…
dscharrer authored
462 src/graphics/opengl/GLTexture2D.cpp
463 src/graphics/opengl/GLTextureStage.cpp
f748b9d @dscharrer Fix unity build.
dscharrer authored
464 src/graphics/opengl/OpenGLRenderer.cpp
465 )
466
467 set(GUI_SOURCES
468 src/gui/Credits.cpp
469 src/gui/Interface.cpp
470 src/gui/Menu.cpp
471 src/gui/MenuPublic.cpp
472 src/gui/MenuWidgets.cpp
473 src/gui/MiniMap.cpp
474 src/gui/Speech.cpp
475 src/gui/Text.cpp
476 src/gui/TextManager.cpp
477 )
478
479 set(INPUT_SOURCES src/input/Input.cpp)
365d73b @SebastienLussier First working implementation of Arx using DirectX 9 (D3D9 & DInput8)
SebastienLussier authored
480 set(INPUT_DINPUT8_SOURCES src/input/DInput8Backend.cpp)
ec98148 @dscharrer Add stub SDL Window and InputBackend and OpenGL Renderer implementati…
dscharrer authored
481 set(INPUT_SDL_SOURCES src/input/SDLInputBackend.cpp)
b175ff2 @dscharrer Only build one of FilesystemPOSIX.cpp, FilesystemWindows.cpp, Filesys…
dscharrer authored
482
483 set(IO_SOURCES
484 src/io/Blast.cpp
485 src/io/CinematicLoad.cpp
486 src/io/Implode.cpp
487 src/io/IniReader.cpp
488 src/io/IniSection.cpp
489 src/io/IniWriter.cpp
490 src/io/IO.cpp
491 src/io/SaveBlock.cpp
492 src/io/Screenshot.cpp
f748b9d @dscharrer Fix unity build.
dscharrer authored
493 )
9c928c0 @dscharrer Support log backends, add a file log backend.
dscharrer authored
494 set(IO_LOGGER_SOURCES
495 src/io/log/ConsoleLogger.cpp
496 src/io/log/FileLogger.cpp
52aaad0 @dscharrer [log] Share formatting between ConsoleLogger, FileLogger and MsvcLogger.
dscharrer authored
497 src/io/log/LogBackend.cpp
9c928c0 @dscharrer Support log backends, add a file log backend.
dscharrer authored
498 src/io/log/Logger.cpp
499 )
b69d7b3 @dscharrer Rename fs::path to res::path.
dscharrer authored
500 set(IO_RESOURCE_SOURCES
501 src/io/resource/PakEntry.cpp
502 src/io/resource/PakReader.cpp
503 src/io/resource/ResourcePath.cpp
504 )
9c928c0 @dscharrer Support log backends, add a file log backend.
dscharrer authored
505 set(IO_LOGGER_POSIX_SOURCES src/io/log/ColorLogger.cpp)
506 set(IO_LOGGER_WINDOWS_SOURCES src/io/log/MsvcLogger.cpp)
f67374f @dscharrer Merge tools build into the main CMakeLists.txt and automatically extr…
dscharrer authored
507 set(IO_FILESYSTEM_SOURCES
508 src/io/FileStream.cpp
509 src/io/Filesystem.cpp
510 )
f748b9d @dscharrer Fix unity build.
dscharrer authored
511 set(IO_FILESYSTEM_BOOST_SOURCES src/io/FilesystemBoost.cpp)
512 set(IO_FILESYSTEM_POSIX_SOURCES src/io/FilesystemPOSIX.cpp)
513 set(IO_FILESYSTEM_WINDOWS_SOURCES src/io/FilesystemWindows.cpp)
514
515 set(MATH_SOURCES src/math/Angle.cpp)
516
517 set(PHYSICS_SOURCES
518 src/physics/Anchors.cpp
519 src/physics/Attractors.cpp
520 src/physics/Box.cpp
521 src/physics/Clothes.cpp
522 src/physics/Collisions.cpp
523 src/physics/CollisionShapes.cpp
524 src/physics/Physics.cpp
b175ff2 @dscharrer Only build one of FilesystemPOSIX.cpp, FilesystemWindows.cpp, Filesys…
dscharrer authored
525 )
526
f748b9d @dscharrer Fix unity build.
dscharrer authored
527 set(PLATFORM_SOURCES
9490540 @dscharrer Add a crash handler that prints very detailed stack traces if gdb is …
dscharrer authored
528 src/platform/CrashHandler.cpp
4db4d9c @dscharrer Detect user/data directory locations.
dscharrer authored
529 src/platform/Environment.cpp
f748b9d @dscharrer Fix unity build.
dscharrer authored
530 src/platform/Lock.cpp
531 src/platform/Platform.cpp
532 src/platform/Random.cpp
533 src/platform/String.cpp
534 src/platform/Thread.cpp
535 src/platform/Time.cpp
536 )
9c3e84d @lubosz stubby cmake build
lubosz authored
537
f748b9d @dscharrer Fix unity build.
dscharrer authored
538 set(SCENE_SOURCES
539 src/scene/ChangeLevel.cpp
540 src/scene/CinematicSound.cpp
541 src/scene/GameSound.cpp
542 src/scene/Interactive.cpp
543 src/scene/Light.cpp
544 src/scene/LinkedObject.cpp
545 src/scene/LoadLevel.cpp
546 src/scene/Object.cpp
547 src/scene/Scene.cpp
548 )
549
550 set(SCRIPT_SOURCES
551 src/script/Script.cpp
552 src/script/ScriptedAnimation.cpp
553 src/script/ScriptedCamera.cpp
554 src/script/ScriptedControl.cpp
555 src/script/ScriptedConversation.cpp
556 src/script/ScriptedInterface.cpp
557 src/script/ScriptedInventory.cpp
558 src/script/ScriptedIOControl.cpp
559 src/script/ScriptedIOProperties.cpp
560 src/script/ScriptedItem.cpp
561 src/script/ScriptedLang.cpp
562 src/script/ScriptedNPC.cpp
563 src/script/ScriptedPlayer.cpp
564 src/script/ScriptedVariable.cpp
565 src/script/ScriptEvent.cpp
566 src/script/ScriptUtils.cpp
567 )
9c3e84d @lubosz stubby cmake build
lubosz authored
568
6c9db46 @dscharrer Move windowing code into a separate subdirectory.
dscharrer authored
569 set(WINDOW_SOURCES
570 src/window/RenderWindow.cpp
571 src/window/Window.cpp
572 )
573 set(WINDOW_SDL_SOURCES src/window/SDLWindow.cpp)
574 set(WINDOW_WIN32_SOURCES src/window/Win32Window.cpp)
365d73b @SebastienLussier First working implementation of Arx using DirectX 9 (D3D9 & DInput8)
SebastienLussier authored
575 set(WINDOW_D3D9_SOURCES src/window/D3D9Window.cpp)
6c9db46 @dscharrer Move windowing code into a separate subdirectory.
dscharrer authored
576
f748b9d @dscharrer Fix unity build.
dscharrer authored
577 file(GLOB_RECURSE ALL_INCLUDES ${SRC_DIR}/*.h)
41d57f0 @dscharrer Make building the OpenAL and DirectSound backends optional.
dscharrer authored
578
3837bcb @dscharrer [make style] Fix include warnings.
dscharrer authored
579 include_directories(${SRC_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/tools)
519b7f1 @dscharrer Add Boost as a dependency.
dscharrer authored
580 include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS} ${IL_INCLUDE_DIR} ${FREETYPE_INCLUDE_DIRS} ${Boost_INCLUDE_DIR})
41d57f0 @dscharrer Make building the OpenAL and DirectSound backends optional.
dscharrer authored
581
f67374f @dscharrer Merge tools build into the main CMakeLists.txt and automatically extr…
dscharrer authored
582 set(ARX_LIBRARIES ${FREETYPE_LIBRARIES} ${ZLIB_LIBRARIES} ${IL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})
583 if(TIME_LIBRARIES)
584 list(APPEND ARX_LIBRARIES ${TIME_LIBRARIES})
585 endif()
586 if(HAVE_WINAPI)
587 list(APPEND ARX_LIBRARIES gdi32 shell32 comdlg32 ole32 comctl32)
588 endif()
589
41d57f0 @dscharrer Make building the OpenAL and DirectSound backends optional.
dscharrer authored
590 if(ARX_USE_OPENAL)
6c9db46 @dscharrer Move windowing code into a separate subdirectory.
dscharrer authored
591 list(APPEND AUDIO_SOURCES ${AUDIO_OPENAL_SOURCES})
f67374f @dscharrer Merge tools build into the main CMakeLists.txt and automatically extr…
dscharrer authored
592 list(APPEND ARX_LIBRARIES ${OPENAL_LIBRARY})
b1323e6 @dscharrer Mark include paths of external projects as SYSTEM to disable warnings.
dscharrer authored
593 include_directories(SYSTEM ${OPENAL_INCLUDE_DIR})
7fa9f82 @dscharrer Write configure options to a header instead of passing them on the co…
dscharrer authored
594 set(HAVE_OPENAL 1)
b43b234 @dscharrer Make the OpenAL effect extension optional so we can build against old…
dscharrer authored
595 if(OPENALEFX_FOUND)
b1323e6 @dscharrer Mark include paths of external projects as SYSTEM to disable warnings.
dscharrer authored
596 include_directories(SYSTEM ${OPENAL_EFX_INCLUDE_DIR})
7fa9f82 @dscharrer Write configure options to a header instead of passing them on the co…
dscharrer authored
597 set(HAVE_OPENAL_EFX 1)
b43b234 @dscharrer Make the OpenAL effect extension optional so we can build against old…
dscharrer authored
598 endif()
41d57f0 @dscharrer Make building the OpenAL and DirectSound backends optional.
dscharrer authored
599 endif()
600 if(ARX_USE_DSOUND)
6c9db46 @dscharrer Move windowing code into a separate subdirectory.
dscharrer authored
601 list(APPEND AUDIO_SOURCES ${AUDIO_DSOUND_SOURCES})
7fa9f82 @dscharrer Write configure options to a header instead of passing them on the co…
dscharrer authored
602 set(HAVE_DSOUND 1)
41d57f0 @dscharrer Make building the OpenAL and DirectSound backends optional.
dscharrer authored
603 endif()
f748b9d @dscharrer Fix unity build.
dscharrer authored
604
365d73b @SebastienLussier First working implementation of Arx using DirectX 9 (D3D9 & DInput8)
SebastienLussier authored
605 if(ARX_USE_D3D9)
606 list(APPEND GRAPHICS_SOURCES ${GRAPHICS_D3D9_SOURCES})
607 list(APPEND WINDOW_SOURCES ${WINDOW_WIN32_SOURCES} ${WINDOW_D3D9_SOURCES})
608
4864792 @SebastienLussier Cleaned DirectX libraries inclusion in CMake
SebastienLussier authored
609 list(APPEND ARX_LIBRARIES ${DIRECTX_D3D9_LIBRARY} ${DIRECTX_D3DX9_LIBRARY} ${DIRECTX_D3DCOMPILER_LIBRARY} ${DIRECTX_DXERR9_LIBRARY})
365d73b @SebastienLussier First working implementation of Arx using DirectX 9 (D3D9 & DInput8)
SebastienLussier authored
610 include_directories(SYSTEM ${DIRECTX_INCLUDE_DIR})
611
612 set(HAVE_D3D9 1)
ec98148 @dscharrer Add stub SDL Window and InputBackend and OpenGL Renderer implementati…
dscharrer authored
613 endif()
f748b9d @dscharrer Fix unity build.
dscharrer authored
614
c105d07 @dscharrer Make building the OpenGLRenderer optional, disabled by default.
dscharrer authored
615 if(ARX_USE_OPENGL)
6c9db46 @dscharrer Move windowing code into a separate subdirectory.
dscharrer authored
616 list(APPEND GRAPHICS_SOURCES ${GRAPHICS_OPENGL_SOURCES})
f67374f @dscharrer Merge tools build into the main CMakeLists.txt and automatically extr…
dscharrer authored
617 list(APPEND ARX_LIBRARIES ${OPENGL_LIBRARIES} ${GLEW_LIBRARIES})
d140a05 @dscharrer Start implementing OpenGLRenderer.
dscharrer authored
618 include_directories(SYSTEM ${OPENGL_INCLUDE_DIR} ${GLEW_INCLUDE_DIR})
ec98148 @dscharrer Add stub SDL Window and InputBackend and OpenGL Renderer implementati…
dscharrer authored
619 set(HAVE_OPENGL 1)
d140a05 @dscharrer Start implementing OpenGLRenderer.
dscharrer authored
620 add_definitions(-DGL_GLEXT_PROTOTYPES)
ec98148 @dscharrer Add stub SDL Window and InputBackend and OpenGL Renderer implementati…
dscharrer authored
621 endif()
622
623 if(ARX_USE_SDL)
6c9db46 @dscharrer Move windowing code into a separate subdirectory.
dscharrer authored
624 list(APPEND WINDOW_SOURCES ${WINDOW_SDL_SOURCES})
625 list(APPEND INPUT_SOURCES ${INPUT_SDL_SOURCES})
f67374f @dscharrer Merge tools build into the main CMakeLists.txt and automatically extr…
dscharrer authored
626 list(APPEND ARX_LIBRARIES ${SDL_LIBRARY})
ec98148 @dscharrer Add stub SDL Window and InputBackend and OpenGL Renderer implementati…
dscharrer authored
627 include_directories(SYSTEM ${SDL_INCLUDE_DIR})
628 set(HAVE_SDL 1)
c105d07 @dscharrer Make building the OpenGLRenderer optional, disabled by default.
dscharrer authored
629 endif()
9c3e84d @lubosz stubby cmake build
lubosz authored
630
365d73b @SebastienLussier First working implementation of Arx using DirectX 9 (D3D9 & DInput8)
SebastienLussier authored
631 if(ARX_USE_DINPUT8)
632 list(APPEND INPUT_SOURCES ${INPUT_DINPUT8_SOURCES})
4864792 @SebastienLussier Cleaned DirectX libraries inclusion in CMake
SebastienLussier authored
633 list(APPEND ARX_LIBRARIES ${DIRECTX_DINPUT8_LIBRARY} ${DIRECTX_DXGUID_LIBRARY} ${DIRECTX_DXERR9_LIBRARY})
365d73b @SebastienLussier First working implementation of Arx using DirectX 9 (D3D9 & DInput8)
SebastienLussier authored
634 set(HAVE_DINPUT8 1)
a996870 @SebastienLussier [DX7] Removed all dx7 backends (please don't cry)
SebastienLussier authored
635 if(WINE)
953612b @dscharrer Add a workaround for missing symbols in wine's dinput8.dll.so
dscharrer authored
636 # TODO(broken-wine) work around missing symbols in wine's dinput8
637 list(APPEND ARX_LIBRARIES dinput)
638 endif()
ec98148 @dscharrer Add stub SDL Window and InputBackend and OpenGL Renderer implementati…
dscharrer authored
639 endif()
f748b9d @dscharrer Fix unity build.
dscharrer authored
640
9c928c0 @dscharrer Support log backends, add a file log backend.
dscharrer authored
641 if(HAVE_ISATTY)
642 list(APPEND IO_LOGGER_SOURCES ${IO_LOGGER_POSIX_SOURCES})
643 endif()
644 if(HAVE_WINAPI)
69c6305 @dscharrer Fix mingw32 build.
dscharrer authored
645 list(APPEND IO_LOGGER_SOURCES ${IO_LOGGER_WINDOWS_SOURCES})
9c928c0 @dscharrer Support log backends, add a file log backend.
dscharrer authored
646 endif()
647 list(APPEND IO_SOURCES ${IO_LOGGER_SOURCES})
648
b69d7b3 @dscharrer Rename fs::path to res::path.
dscharrer authored
649 list(APPEND IO_SOURCES ${IO_RESOURCE_SOURCES})
650
f748b9d @dscharrer Fix unity build.
dscharrer authored
651 if(HAVE_POSIX_FILESYSTEM)
f67374f @dscharrer Merge tools build into the main CMakeLists.txt and automatically extr…
dscharrer authored
652 list(APPEND IO_FILESYSTEM_SOURCES ${IO_FILESYSTEM_POSIX_SOURCES})
f748b9d @dscharrer Fix unity build.
dscharrer authored
653 elseif(HAVE_WINAPI)
654 add_definitions(-DHAVE_WINDOWS_FILESYSTEM)
f67374f @dscharrer Merge tools build into the main CMakeLists.txt and automatically extr…
dscharrer authored
655 list(APPEND IO_FILESYSTEM_SOURCES ${IO_FILESYSTEM_WINDOWS_SOURCES})
f748b9d @dscharrer Fix unity build.
dscharrer authored
656 elseif((Boost_MAJOR_VERSION GREATER 1) OR (NOT Boost_MINOR_VERSION LESS 44))
4db4d9c @dscharrer Detect user/data directory locations.
dscharrer authored
657 find_package(Boost 1.44 REQUIRED COMPONENTS ${BOOST_COMPONENTS} filesystem system)
f748b9d @dscharrer Fix unity build.
dscharrer authored
658 set(HAVE_BOOST_FILESYSTEM_V3 1)
659 add_definitions(-DBOOST_FILESYSTEM_VERSION=3)
f67374f @dscharrer Merge tools build into the main CMakeLists.txt and automatically extr…
dscharrer authored
660 list(APPEND IO_FILESYSTEM_SOURCES ${IO_FILESYSTEM_BOOST_SOURCES})
f748b9d @dscharrer Fix unity build.
dscharrer authored
661 else()
662 message(FATAL_ERROR "You need either Boost >= 1.44 or windows api or sys/stat.h, sys/errno.h and dirent.h; Found boost version ${Boost_VERSION}")
663 endif()
f67374f @dscharrer Merge tools build into the main CMakeLists.txt and automatically extr…
dscharrer authored
664 list(APPEND IO_SOURCES ${IO_FILESYSTEM_SOURCES})
f748b9d @dscharrer Fix unity build.
dscharrer authored
665
666 if(NOT MSVC)
667 check_link_library(Boost Boost_LIBRARIES)
668 endif()
669
f67374f @dscharrer Merge tools build into the main CMakeLists.txt and automatically extr…
dscharrer authored
670 set(ARX_SOURCES ${AI_SOURCES} ${ANIMATION_SOURCES} ${AUDIO_SOURCES} ${CORE_SOURCES} ${GAME_SOURCES} ${GRAPHICS_SOURCES} ${GUI_SOURCES} ${INPUT_SOURCES} ${IO_SOURCES} ${MATH_SOURCES} ${PHYSICS_SOURCES} ${PLATFORM_SOURCES} ${SCENE_SOURCES} ${SCRIPT_SOURCES} ${WINDOW_SOURCES})
f748b9d @dscharrer Fix unity build.
dscharrer authored
671
8159cf1 @dscharrer Add an option to not build the editor components.
dscharrer authored
672 if(ARX_BUILD_EDITOR)
f67374f @dscharrer Merge tools build into the main CMakeLists.txt and automatically extr…
dscharrer authored
673 list(APPEND ARX_SOURCES ${EDITOR_SOURCES})
8159cf1 @dscharrer Add an option to not build the editor components.
dscharrer authored
674 set(BUILD_EDITOR 1)
41d57f0 @dscharrer Make building the OpenAL and DirectSound backends optional.
dscharrer authored
675 endif()
05cc8a6 @dscharrer Make building .scn file support optional. (raw unprocessed scenes, no…
dscharrer authored
676 if(ARX_BUILD_EDIT_LOADSAVE)
677 set(BUILD_EDIT_LOADSAVE 1)
678 endif()
9c3e84d @lubosz stubby cmake build
lubosz authored
679
cc565fb @dscharrer Fix compile errors when using older boost versions (tested 1.37 and 1…
dscharrer authored
680 add_definitions(-DBOOST_FILESYSTEM_NO_DEPRECATED)
681
5c2d73a @SebastienLussier Fixed VC2010 warnings/errors/projects
SebastienLussier authored
682 #create source groups
b7b0735 @SebastienLussier [CMake] Changed create_source_groups() to create a hierarchy that rep…
SebastienLussier authored
683 list(APPEND ALL_FILES_FOR_GROUPS ${ALL_INCLUDES} ${ARX_SOURCES})
684 create_source_groups(ALL_FILES_FOR_GROUPS)
5c2d73a @SebastienLussier Fixed VC2010 warnings/errors/projects
SebastienLussier authored
685
1532a01 @dscharrer Work around gcc warning in unity builds about types from an anonymous…
dscharrer authored
686 if(ARX_USE_UNITYBUILD)
687 set(UNITY_BUILD 1)
688 endif()
689
4db4d9c @dscharrer Detect user/data directory locations.
dscharrer authored
690 configure_file("${SRC_DIR}/Configure.h.cmake" "Configure.h" ESCAPE_QUOTES)
7fa9f82 @dscharrer Write configure options to a header instead of passing them on the co…
dscharrer authored
691
1ea3ead @dscharrer Automatically generate a version string at build time.
dscharrer authored
692 version_file("${SRC_DIR}/core/Version.cpp.cmake" "${CMAKE_BINARY_DIR}/Version.cpp" "VERSION" ".git")
693 list(APPEND ARX_SOURCES "${CMAKE_BINARY_DIR}/Version.cpp")
9c3e84d @lubosz stubby cmake build
lubosz authored
694
f67374f @dscharrer Merge tools build into the main CMakeLists.txt and automatically extr…
dscharrer authored
695 # Add executables
696
736121e @SebastienLussier Build Arx as a Win32 application (no more console)
SebastienLussier authored
697 add_executable_shared(arx WIN32 "${ARX_SOURCES}" "${ARX_LIBRARIES}" "${ALL_INCLUDES}")
f67374f @dscharrer Merge tools build into the main CMakeLists.txt and automatically extr…
dscharrer authored
698
699 if(ARX_BUILD_TOOLS)
700
701 set(SAVETOOL_SOURCES
702 ${IO_FILESYSTEM_SOURCES}
9c928c0 @dscharrer Support log backends, add a file log backend.
dscharrer authored
703 ${IO_LOGGER_SOURCES}
b69d7b3 @dscharrer Rename fs::path to res::path.
dscharrer authored
704 ${IO_RESOURCE_SOURCES}
f67374f @dscharrer Merge tools build into the main CMakeLists.txt and automatically extr…
dscharrer authored
705 src/core/Localisation.cpp
706 src/io/Blast.cpp
707 src/io/SaveBlock.cpp
708 src/io/IniReader.cpp
709 src/io/IniSection.cpp
710 src/platform/String.cpp
711 src/platform/Platform.cpp
6e6bfe4 @dscharrer Make the new Logger threadsafe.
dscharrer authored
712 src/platform/Lock.cpp
f67374f @dscharrer Merge tools build into the main CMakeLists.txt and automatically extr…
dscharrer authored
713 tools/savetool/savetool.cpp
714 tools/savetool/SaveFix.cpp
715 tools/savetool/SaveView.cpp
716 )
717
718 set(SAVETOOL_LIBRARIES ${ZLIB_LIBRARIES} ${Boost_LIBRARIES})
719
8d3c0a4 @dscharrer Merge branch 'master' into slussier_misc
dscharrer authored
720 add_executable_shared(arxsavetool "" "${SAVETOOL_SOURCES}" "${SAVETOOL_LIBRARIES}" "")
f67374f @dscharrer Merge tools build into the main CMakeLists.txt and automatically extr…
dscharrer authored
721
722 set(UNPAK_SOURCES
723 ${IO_FILESYSTEM_SOURCES}
9c928c0 @dscharrer Support log backends, add a file log backend.
dscharrer authored
724 ${IO_LOGGER_SOURCES}
b69d7b3 @dscharrer Rename fs::path to res::path.
dscharrer authored
725 ${IO_RESOURCE_SOURCES}
f67374f @dscharrer Merge tools build into the main CMakeLists.txt and automatically extr…
dscharrer authored
726 src/io/Blast.cpp
9c928c0 @dscharrer Support log backends, add a file log backend.
dscharrer authored
727 src/io/log/ColorLogger.cpp
728 src/io/log/ConsoleLogger.cpp
729 src/io/log/Logger.cpp
f67374f @dscharrer Merge tools build into the main CMakeLists.txt and automatically extr…
dscharrer authored
730 src/platform/String.cpp
731 src/platform/Platform.cpp
6e6bfe4 @dscharrer Make the new Logger threadsafe.
dscharrer authored
732 src/platform/Lock.cpp
f67374f @dscharrer Merge tools build into the main CMakeLists.txt and automatically extr…
dscharrer authored
733 tools/unpak/unpak.cpp
734 )
735
736 set(UNPAK_LIBRARIES ${Boost_LIBRARIES})
737
8d3c0a4 @dscharrer Merge branch 'master' into slussier_misc
dscharrer authored
738 add_executable_shared(arxunpak "" "${UNPAK_SOURCES}" "${UNPAK_LIBRARIES}" "")
f67374f @dscharrer Merge tools build into the main CMakeLists.txt and automatically extr…
dscharrer authored
739
c105d07 @dscharrer Make building the OpenGLRenderer optional, disabled by default.
dscharrer authored
740 endif()
f67374f @dscharrer Merge tools build into the main CMakeLists.txt and automatically extr…
dscharrer authored
741
742 # Build and link executables
743
744 if(ARX_USE_UNITYBUILD)
745 unity_build()
746 else()
747 shared_build()
ec98148 @dscharrer Add stub SDL Window and InputBackend and OpenGL Renderer implementati…
dscharrer authored
748 endif()
7c677ae @lubosz added remake flag
lubosz authored
749
f67374f @dscharrer Merge tools build into the main CMakeLists.txt and automatically extr…
dscharrer authored
750
751 # Custom make targets
752
7c677ae @lubosz added remake flag
lubosz authored
753 add_custom_target(remake
7a4b058 @lubosz fixed formatting and include folder
lubosz authored
754 #clean and compile with 1 thread per core
755 COMMAND make clean && rm CMakeCache.txt && cmake ${CMAKE_SOURCE_DIR} -G\"Unix Makefiles\" && make -j`getconf _NPROCESSORS_ONLN`
7c677ae @lubosz added remake flag
lubosz authored
756 )
335f4bf @dscharrer Add tool for PAK file decompression.
dscharrer authored
757
734fab0 @dscharrer Use find_package in CMakeLists.txt instead of hardcoding library name…
dscharrer authored
758 if(DOXYGEN_EXECUTABLE)
759 add_custom_target(doc
760 #build the documentation
ac9fe80 @dscharrer [cmake] Update doxygen configuration.
dscharrer authored
761 COMMAND cd ${CMAKE_SOURCE_DIR}/src && ${DOXYGEN_EXECUTABLE} ${CMAKE_SOURCE_DIR}/doc/Doxyfile
734fab0 @dscharrer Use find_package in CMakeLists.txt instead of hardcoding library name…
dscharrer authored
762 )
763 endif()
766a3e9 @lubosz added doxyfile and doc build to cmake. see readme.
lubosz authored
764
734fab0 @dscharrer Use find_package in CMakeLists.txt instead of hardcoding library name…
dscharrer authored
765 if(PYTHONINTERP_FOUND)
3837bcb @dscharrer [make style] Fix include warnings.
dscharrer authored
766
00ec547 @dscharrer [cmake] The style target should depend on the source files.
dscharrer authored
767 file(GLOB_RECURSE TOOLS_INCLUDES ${CMAKE_SOURCE_DIR}/tools/*.h)
768 set(ALL_SOURCES
769 ${ARX_SOURCES}
770 ${ALL_INCLUDES}
771 ${SAVETOOL_SOURCES}
772 ${UNPAK_SOURCES}
773 ${TOOLS_INCLUDES}
774 )
775
3837bcb @dscharrer [make style] Fix include warnings.
dscharrer authored
776 unset(STYLE_FILTER)
777
778 # Complains about any c-style cast -> too annoying.
779 set(STYLE_FILTER ${STYLE_FILTER},-readability/casting)
780
781 # Insists on including evrything in the .cpp file even if it is included in the header.
782 # This behaviour conflicts with orther tools.
783 set(STYLE_FILTER ${STYLE_FILTER},-build/include_what_you_use)
784
785 # Too many false positives and not very helpful error messages.
786 set(STYLE_FILTER ${STYLE_FILTER},-build/include_order)
787
52c76cf @dscharrer [cmake] Improve style checking.
dscharrer authored
788 # No thanks.
789 set(STYLE_FILTER ${STYLE_FILTER},-readability/streams)
790
791 # Ugh!
792 set(STYLE_FILTER ${STYLE_FILTER},-whitespace/tab)
793
794 # Yes it is!
795 set(STYLE_FILTER ${STYLE_FILTER},-whitespace/blank_line)
796
797 # Suggessts excessive indentation.
798 set(STYLE_FILTER ${STYLE_FILTER},-whitespace/labels)
799
800 # Why?
801 set(STYLE_FILTER ${STYLE_FILTER},-whitespace/todo)
802 set(STYLE_FILTER ${STYLE_FILTER},-readability/todo)
803
804 # "For a static/global string constant, use a C style string"
805 set(STYLE_FILTER ${STYLE_FILTER},-runtime/string)
806
807 # TODO consider enabling these and fixing the warnings
808
809 # Very noisy and perhaps a matter of taste.
810 set(STYLE_FILTER ${STYLE_FILTER},-whitespace/braces)
811 set(STYLE_FILTER ${STYLE_FILTER},-whitespace/parens)
812 set(STYLE_FILTER ${STYLE_FILTER},-whitespace/newline)
813
814 # Complains about using short, long, etc.
815 set(STYLE_FILTER ${STYLE_FILTER},-runtime/int)
816
817 # Complains about non-const references as parameters
818 set(STYLE_FILTER ${STYLE_FILTER},-runtime/references)
819
820 # TODO enable these!
821
822 set(RELAXED_STYLE_FILTER ${STYLE_FILTER})
823
824 # Very noisy but should be fixed.
825 set(RELAXED_STYLE_FILTER ${RELAXED_STYLE_FILTER},-whitespace/operators)
826 set(RELAXED_STYLE_FILTER ${RELAXED_STYLE_FILTER},-whitespace/comma)
827 set(RELAXED_STYLE_FILTER ${RELAXED_STYLE_FILTER},-whitespace/comments)
828 set(RELAXED_STYLE_FILTER ${RELAXED_STYLE_FILTER},-whitespace/end_of_line)
829 set(RELAXED_STYLE_FILTER ${RELAXED_STYLE_FILTER},-whitespace/align_tab)
830 set(RELAXED_STYLE_FILTER ${RELAXED_STYLE_FILTER},-whitespace/line_length)
831 set(RELAXED_STYLE_FILTER ${RELAXED_STYLE_FILTER},-whitespace/semicolon)
832 set(RELAXED_STYLE_FILTER ${RELAXED_STYLE_FILTER},-whitespace/ident_space)
833
834 # Unsafe functions.
835 set(RELAXED_STYLE_FILTER ${RELAXED_STYLE_FILTER},-runtime/printf)
836 set(RELAXED_STYLE_FILTER ${RELAXED_STYLE_FILTER},-runtime/threadsafe_fn)
837
838 # Very much known...
839 set(RELAXED_STYLE_FILTER ${RELAXED_STYLE_FILTER},-readability/fn_size)
840
734fab0 @dscharrer Use find_package in CMakeLists.txt instead of hardcoding library name…
dscharrer authored
841 add_custom_target(style
00ec547 @dscharrer [cmake] The style target should depend on the source files.
dscharrer authored
842 COMMAND cmake -E chdir "${CMAKE_SOURCE_DIR}" "${PYTHON_EXECUTABLE}" "${CMAKE_SOURCE_DIR}/scripts/cpplint.py" "--filter=${RELAXED_STYLE_FILTER}" ${ALL_SOURCES}
843 DEPENDS ${ALL_SOURCES} VERBATIM
52c76cf @dscharrer [cmake] Improve style checking.
dscharrer authored
844 )
845
846 add_custom_target(strict-style
00ec547 @dscharrer [cmake] The style target should depend on the source files.
dscharrer authored
847 COMMAND cmake -E chdir "${CMAKE_SOURCE_DIR}" "${PYTHON_EXECUTABLE}" "${CMAKE_SOURCE_DIR}/scripts/cpplint.py" "--filter=${STYLE_FILTER}" ${ALL_SOURCES}
848 DEPENDS ${ALL_SOURCES} VERBATIM
734fab0 @dscharrer Use find_package in CMakeLists.txt instead of hardcoding library name…
dscharrer authored
849 )
ab07b50 @dscharrer Use consistent casing in CMakeLists.txt
dscharrer authored
850 endif()
e9bb76b @lubosz style check and make target
lubosz authored
851
3e661ac @lubosz options for not buildings tests and tools
lubosz authored
852 if(ARX_BUILD_TESTS)
853 add_subdirectory(tests ${CMAKE_SOURCE_DIR}/bin/tests)
854 endif()
Something went wrong with that request. Please try again.