/
CMakeLists.txt
executable file
·1065 lines (902 loc) · 31.1 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
project(ArxLibertatis)
if(MSVC)
# CMake 2.8.5 or newer is needed for CMAKE_LIBRARY_ARCHITECTURE support.
cmake_minimum_required(VERSION 2.8.5)
# Change CMAKE_LIBRARY_ARCHITECTURE to ensure the right libs are used
if(CMAKE_CL_64)
set(CMAKE_LIBRARY_ARCHITECTURE "x64")
else()
set(CMAKE_LIBRARY_ARCHITECTURE "x86")
endif(CMAKE_CL_64)
else()
cmake_minimum_required(VERSION 2.8)
endif()
# For custom cmake modules.
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
include(CheckTypeSize)
include(CheckSymbolExists)
include(CheckCXXSourceCompiles)
include(BuildSystem)
include(CompileCheck)
include(VersionString)
include(StyleCheck)
include(PrintConfiguration)
include(CreateSourceGroups)
##############################################################################
option(BUILD_TESTS "Build tests" OFF)
option(BUILD_TOOLS "Build tools" ON)
option(BUILD_CRASHREPORTER "Build the crash reporter" ON)
option(BUILD_EDITOR "Build editor" OFF)
option(BUILD_EDIT_LOADSAVE "Build save/load functions only used by the editor" ON)
option(UNITY_BUILD "Unity build" OFF)
option(DEBUG_EXTRA "Expensive debug options" OFF)
option(USE_OPENAL "Build the OpenAL audio backend." ON)
option(USE_DSOUND "Build the DirectSound audio backend." ON)
option(USE_OPENGL "Build the OpenGL renderer backend." ON)
option(USE_D3D9 "Build the Direct3D 9 renderer backend." ON)
option(USE_SDL "Build the SDL windowing backend." ON)
option(USE_DINPUT8 "Build the DirectInput 8 input backend." ON)
option(USE_NATIVE_FS "Use the native (POSIX / Win32) filesystem backend instead of boost." ON)
if((NOT LAST_CMAKE_CXX_FLAGS STREQUAL CMAKE_CXX_FLAGS) OR (NOT LAST_CMAKE_CXX_COMPILER STREQUAL CMAKE_CXX_COMPILER))
force_recheck_library(DevIL IL)
force_recheck_library(ZLIB)
force_recheck_library(Freetype)
force_recheck_library(Threads)
force_recheck_library(OpenAL)
force_recheck_library(OpenGL)
force_recheck_library(GLEW)
force_recheck_library(Boost)
force_recheck_library(QtCore QT_QTCORE)
force_recheck_library(QtGui QT_QTGUI)
force_recheck_library(QtNetwork QT_QTNETWORK)
unset(Boost_INCLUDE_DIR CACHE)
set(LAST_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE INTERNAL "The last C++ compiler flags.")
set(LAST_CMAKE_CXX_COMPILER "${CMAKE_CXX_COMPILER}" CACHE INTERNAL "The last C++ compiler.")
endif()
if(WINE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -U_WIN32 -U__CYGWIN__ -U__WIN32__ -UWIN32")
set(HAVE_WINAPI 1)
elseif(WIN32)
if(NOT MSVC)
# We need to define WINVER for MinGW32 when requiring anything newer than Win95 / WinNT
add_definitions(-DWINVER=0x0500) # Require at least Windows 2000
endif()
set(HAVE_WINAPI 1)
else()
set(HAVE_WINAPI 0)
endif()
if(NOT HAVE_WINAPI)
# The is no DirectX under linux
set(USE_D3D9 OFF)
set(USE_DSOUND OFF)
set(USE_DINPUT8 OFF)
else()
if(USE_D3D9 OR USE_DINPUT8)
find_package(DirectX REQUIRED)
endif()
endif()
find_package(Freetype REQUIRED)
find_package(DevIL REQUIRED)
find_package(ZLIB REQUIRED)
set(CMAKE_THREAD_PREFER_PTHREAD 1)
find_package(Threads REQUIRED)
if(USE_OPENGL)
find_package(OpenGL)
find_package(GLEW)
endif()
if(USE_OPENAL)
find_package(OpenAL 1.1)
find_package(OpenALEFX)
endif()
find_package(Doxygen)
find_package(PythonInterp)
if(USE_SDL)
if(NOT APPLE)
# Required to avoid linking with SDLmain except for OS X where it is necessary
# due to the need to have NSApplication correctly setup by SDLmain.
set(SDL_BUILDING_LIBRARY 1)
endif()
find_package(SDL 1.2 EXACT)
endif()
if(MSVC)
# Link statically with Boost under Windows
set(Boost_USE_STATIC_LIBS ON)
endif(MSVC)
set(BOOST_COMPONENTS program_options)
find_package(Boost 1.39 REQUIRED COMPONENTS ${BOOST_COMPONENTS})
set(HAVE_CRASHREPORTER 0)
if(BUILD_CRASHREPORTER)
# Needed by the crash reporter
add_definitions(-DQT_NO_DEBUG)
find_package(Qt4 COMPONENTS QtCore QtGui QtNetwork)
if(QT_FOUND)
if(MSVC)
find_package(DbgHelp)
if(DBGHELP_FOUND)
set(HAVE_CRASHREPORTER 1)
endif()
else()
set(HAVE_CRASHREPORTER 1)
endif()
endif()
remove_definitions(-DQT_DEBUG)
if(HAVE_CRASHREPORTER)
include(${QT_USE_FILE})
endif()
endif()
mark_as_advanced(IL_INCLUDE_DIR)
mark_as_advanced(ILUT_LIBRARIES)
mark_as_advanced(ILU_LIBRARIES)
mark_as_advanced(IL_LIBRARIES)
set(SRC_DIR src)
if(MSVC)
# Disable deprecation warnings
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
add_definitions(/wd4995) # 'func': name was marked as #pragma deprecated
# TEMP - disable warning caused by the F2L removal
add_definitions(/wd4244) # Conversion from 'float' to 'long', possible loss of data
# TEMP - disable warning caused by conversion from a 64-bit type to a 32-bit one...
if(CMAKE_CL_64)
add_definitions(/wd4267) # Conversion from 'size_t' to 'xxx', possible loss of data
endif()
add_definitions(/wd4127) # warning C4127: conditional expression is constant
add_definitions(/wd4201) # warning C4201: nonstandard extension used : nameless struct/union
add_definitions(/wd4503) # warning C4503: 'xxx' : decorated name length exceeded, name was truncated
if(NOT DEBUG_EXTRA)
add_definitions(-D_HAS_ITERATOR_DEBUGGING=0)
add_definitions(-D_SECURE_SCL=0)
add_definitions(-D_SECURE_SCL_THROWS=0)
add_definitions(-D_ITERATOR_DEBUG_LEVEL=0)
endif()
# Disable exceptions & rtti
add_definitions(/GR-) # No RTTI
# Enable multiprocess build
add_definitions(/MP)
# Ensure we aren't using functionalities not found under Window XP SP1
add_definitions(-D_WIN32_WINNT=0x0502)
foreach(flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE)
# Disable Run time checks
string(REGEX REPLACE "/RTC1" "" ${flag_var} "${${flag_var}}")
# Change runtime library from "Multi-threaded Debug DLL" to "Multi-threaded DLL"
string(REGEX REPLACE "/MDd" "/MD" ${flag_var} "${${flag_var}}")
# Remove definition of _DEBUG as it might conflict with libs we're linking with
string(REGEX REPLACE "/D_DEBUG" "/DNDEBUG" ${flag_var} "${${flag_var}}")
# Force to always compile with warning level 3
string(REGEX REPLACE "/W[0-4]" "/W3" ${flag_var} "${${flag_var}}")
endforeach(flag_var)
# Avoid warning during link
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:LIBCMT")
# Disable randomized base address (for better callstack matching)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DYNAMICBASE:NO")
# Always generate a PDB file
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DEBUG")
# Enable compiler optimization in release
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Ox /Oi /Ot /GL /arch:SSE2 /GS- /fp:fast")
# Always build with debug information
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zi")
# Enable linker optimization in release
# /OPT:REF Eliminate unreferenced code
# /OPT:ICF COMDAT folding (merge functions generating the same code)
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /OPT:REF /OPT:ICF /LTCG")
# This is needed to use ZLIB
add_definitions(-DZLIB_WINAPI)
else(MSVC)
# Check the dependencies so there won't by cryptic link errors later on when found libraries have the wrong architecture (32- vs. 64-bit)
if(CMAKE_THREAD_LIBS_INIT)
check_link_library(Threads CMAKE_THREAD_LIBS_INIT)
endif()
check_link_library(DevIL IL_LIBRARIES IL)
check_link_library(ZLIB ZLIB_LIBRARIES)
check_link_library(Freetype FREETYPE_LIBRARIES)
if(USE_OPENAL AND OPENAL_FOUND)
check_link_library(OpenAL OPENAL_LIBRARY)
endif()
if(USE_OPENGL AND OPENGL_FOUND)
check_link_library(OpenGL OPENGL_gl_LIBRARY)
check_link_library(GLEW GLEW_LIBRARIES)
endif()
if(USE_SDL AND SDL_FOUND)
check_link_library(SDL SDL_LIBRARY)
endif()
if(HAVE_CRASHREPORTER)
check_link_library(QtCore QT_QTCORE_LIBRARY_RELEASE QT_QTCORE)
check_link_library(QtGui QT_QTGUI_LIBRARY_RELEASE QT_QTGUI)
check_link_library(QtNetwork QT_QTNETWORK_LIBRARY_RELEASE QT_QTNETWORK)
endif()
set(CMAKE_REQUIRED_DEFINITIONS "-D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=600")
add_definitions(-D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=600)
check_symbol_exists(nanosleep "time.h" HAVE_NANOSLEEP_FUNC)
check_symbol_exists(pthread_setname_np "pthread.h" HAVE_PTHREAD_SETNAME_NP)
check_symbol_exists(pthread_set_name_np "pthread.h" HAVE_PTHREAD_SET_NAME_NP)
check_symbol_exists(prctl "sys/prctl.h" HAVE_PRCTL)
check_symbol_exists(PR_SET_NAME "linux/prctl.h" HAVE_PR_SET_NAME)
check_symbol_exists(uname "sys/utsname.h" HAVE_UNAME)
check_symbol_exists(getrusage "sys/resource.h" HAVE_GETRUSAGE)
check_symbol_exists(popen "stdio.h" HAVE_POPEN)
check_symbol_exists(pclose "stdio.h" HAVE_PCLOSE)
set(CMAKE_REQUIRED_LIBRARIES "-lrt")
check_symbol_exists(clock_gettime "time.h" HAVE_CLOCK_GETTIME)
unset(CMAKE_REQUIRED_LIBRARIES)
if(HAVE_CLOCK_GETTIME)
set(TIME_LIBRARIES "-lrt")
elseif(NOT HAVE_WINAPI)
check_include_files("mach/clock.h;mach/clock_types.h;mach/mach_host.h" HAVE_MACH_CLOCK)
endif()
check_include_file("wordexp.h" HAVE_WORDEXP_H)
check_symbol_exists(fork "unistd.h" HAVE_FORK)
check_symbol_exists(readlink "unistd.h" HAVE_READLINK)
check_symbol_exists(dup2 "unistd.h" HAVE_DUP2)
check_symbol_exists(execl "unistd.h" HAVE_EXECL)
check_symbol_exists(execlp "unistd.h" HAVE_EXECLP)
if(NOT WIN32)
check_symbol_exists(isatty "unistd.h" HAVE_ISATTY)
endif()
check_symbol_exists(sched_getscheduler "sched.h" HAVE_SCHED_GETSCHEDULER)
check_symbol_exists(kill "signal.h" HAVE_KILL)
check_symbol_exists(backtrace "execinfo.h" HAVE_BACKTRACE)
check_include_file("sys/types.h" HAVE_SYS_TYPES_H)
check_symbol_exists(getpid "unistd.h" HAVE_GETPID)
check_symbol_exists(sysconf "unistd.h" HAVE_SYSCONF)
check_symbol_exists(sigaction "signal.h" HAVE_SIGACTION)
if(USE_NATIVE_FS)
check_include_file("sys/stat.h" HAVE_SYS_STAT_H)
check_include_file("sys/errno.h" HAVE_SYS_ERRNO_H)
check_include_file("dirent.h" HAVE_DIRENT_H)
check_symbol_exists(fpathconf "unistd.h" HAVE_FPATHCONF)
check_symbol_exists(_PC_NAME_MAX "unistd.h" HAVE_PC_NAME_MAX)
check_symbol_exists(dirfd "dirent.h" HAVE_DIRFD)
check_symbol_exists(fstatat "sys/stat.h" HAVE_FSTATAT)
check_symbol_exists(NAME_MAX "dirent.h" HAVE_NAME_MAX)
if(HAVE_DIRFD AND HAVE_SYS_STAT_H AND HAVE_SYS_ERRNO_H AND HAVE_DIRENT_H AND HAVE_FSTATAT)
if((HAVE_FPATHCONF AND HAVE_PC_NAME_MAX) OR (HAVE_NAME_MAX))
set(HAVE_POSIX_FILESYSTEM 1)
endif()
endif()
endif()
# Warning level
add_cxxflag("-Wall")
add_cxxflag("-Wextra")
add_cxxflag("-Wformat=2")
add_cxxflag("-Wundef")
add_cxxflag("-Wpointer-arith")
add_cxxflag("-Wcast-qual")
add_cxxflag("-Woverloaded-virtual")
add_cxxflag("-Wlogical-op")
add_cxxflag("-Wliteral-conversion")
add_cxxflag("-Wshift-overflow")
add_cxxflag("-Woverflow")
add_cxxflag("-Wbool-conversions")
# TODO enable:
# add_cxxflag("-Wconversion") # very noisy
# add_cxxflag("-Wsign-conversion") # very noisy
# add_cxxflag("-Wmissing-declarations") # to catch functions that should be marked as static
# add_cxxflag("-Wredundant-decls") # to catch extern definitions in .cpp files (with UNITYBUILD)
if(CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE "Release")
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
#Debug
add_definitions(-D_DEBUG)
check_compiler_flag(RESULT "-g3")
if(NOT RESULT STREQUAL "")
string(REGEX REPLACE "-g(|[0-9]|gdb)" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${RESULT}")
endif()
check_compiler_flag(RESULT "-O0")
string(REGEX REPLACE "-O[0-9]" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${RESULT}")
endif()
if(DEBUG_EXTRA)
add_cxxflag("-ftrapv") # to add checks for (undefined) signed integer overflow
add_cxxflag("-fbounds-checking")
add_cxxflag("-fcatch-undefined-behavior")
add_cxxflag("-Wstrict-aliasing=1")
else()
# -Wuninitialized causes too many false positives
add_cxxflag("-Wno-uninitialized")
# (clang only) Conflicts with using const variables for configuration.
add_cxxflag("-Wno-constant-logical-operand")
endif()
if(UNITY_BUILD)
add_cxxflag("-fwhole-program")
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "PathScale")
# The standard library shipped with ekopath failes to compile with -fno-rtti
# See https://github.com/pathscale/stdcxx/issues/3
add_definitions(-D_RWSTD_NO_DYNAMIC_CAST)
endif()
endif(MSVC)
if(WIN32 AND NOT WINE)
# Define default user and data directories.
if(NOT DEFINED DATA_DIR)
set(DATA_DIR "Arx Libertatis")
endif()
if(NOT DEFINED USER_DIR)
set(USER_DIR "Arx Libertatis")
endif()
if(NOT DEFINED USER_DIR_PREFIXES)
set(USER_DIR_PREFIXES "%FOLDERID_SavedGames%")
endif()
else()
# Define default user and data directories.
if(NOT DEFINED DATA_DIR)
set(DATA_DIR "arx")
endif()
if(NOT DEFINED USER_DIR)
set(USER_DIR "arx")
endif()
if(NOT DEFINED DATA_DIR_PREFIXES)
set(DATA_DIR_PREFIXES "${CMAKE_INSTALL_PREFIX}/share:$XDG_DATA_DIRS")
endif()
if(NOT DEFINED USER_DIR_PREFIXES)
set(USER_DIR_PREFIXES "$XDG_DATA_HOME")
endif()
endif()
if(DATA_DIR STREQUAL "")
unset(DATA_DIR)
endif()
if(USER_DIR STREQUAL "")
unset(USER_DIR)
endif()
if(DATA_DIR_PREFIXES STREQUAL "")
unset(DATA_DIR_PREFIXES)
endif()
if(USER_DIR_PREFIXES STREQUAL "")
unset(USER_DIR_PREFIXES)
endif()
# Check that all required functionality is available.
if(CMAKE_USE_PTHREADS_INIT AND HAVE_SYS_TYPES_H AND HAVE_GETPID)
set(HAVE_PTHREADS 1)
endif()
# Preprocessor definitions
if(HAVE_WINAPI)
add_definitions(-DNOMINMAX)
add_definitions(-DWIN32_LEAN_AND_MEAN)
endif(HAVE_WINAPI)
# Sources
set(AI_SOURCES
src/ai/PathFinder.cpp
src/ai/PathFinderManager.cpp
src/ai/Paths.cpp
)
set(ANIMATION_SOURCES
src/animation/Animation.cpp
src/animation/AnimationRender.cpp
src/animation/Cinematic.cpp
src/animation/CinematicKeyframer.cpp
src/animation/Intro.cpp
)
set(AUDIO_SOURCES
src/audio/Ambiance.cpp
src/audio/Audio.cpp
src/audio/AudioEnvironment.cpp
src/audio/AudioGlobal.cpp
src/audio/AudioResource.cpp
src/audio/AudioSource.cpp
src/audio/Mixer.cpp
src/audio/Sample.cpp
src/audio/Stream.cpp
src/audio/codec/ADPCM.cpp
src/audio/codec/RAW.cpp
src/audio/codec/WAV.cpp
)
set(AUDIO_OPENAL_SOURCES
src/audio/openal/OpenALBackend.cpp
src/audio/openal/OpenALSource.cpp
src/audio/openal/OpenALUtils.cpp
)
set(AUDIO_DSOUND_SOURCES
src/audio/dsound/DSoundBackend.cpp
src/audio/dsound/DSoundSource.cpp
)
set(CORE_SOURCES
src/core/Application.cpp
src/core/ArxGame.cpp
src/core/Config.cpp
src/core/Core.cpp
src/core/GameTime.cpp
src/core/Localisation.cpp
src/core/SaveGame.cpp
src/core/Startup.cpp
)
set(EDITOR_SOURCES
src/core/Dialog.cpp
src/script/ScriptDebugger.cpp
src/script/ScriptDebuggerDialog.cpp
)
set(GAME_SOURCES
src/game/Damage.cpp
src/game/Equipment.cpp
src/game/Inventory.cpp
src/game/Levels.cpp
src/game/Map.cpp
src/game/Missile.cpp
src/game/NPC.cpp
src/game/Player.cpp
src/game/Spells.cpp
)
set(GRAPHICS_SOURCES
src/graphics/Draw.cpp
src/graphics/GraphicsModes.cpp
src/graphics/GraphicsUtility.cpp
src/graphics/Math.cpp
src/graphics/Renderer.cpp
src/graphics/data/CinematicTexture.cpp
src/graphics/data/FTL.cpp
src/graphics/data/Mesh.cpp
src/graphics/data/MeshManipulation.cpp
src/graphics/data/Progressive.cpp
src/graphics/data/TextureContainer.cpp
src/graphics/effects/CinematicEffects.cpp
src/graphics/effects/DrawEffects.cpp
src/graphics/effects/Fog.cpp
src/graphics/effects/SpellEffects.cpp
src/graphics/font/Font.cpp
src/graphics/font/FontCache.cpp
src/graphics/image/Image.cpp
src/graphics/particle/Particle.cpp
src/graphics/particle/ParticleEffects.cpp
src/graphics/particle/ParticleManager.cpp
src/graphics/particle/ParticleSystem.cpp
src/graphics/spells/Spells01.cpp
src/graphics/spells/Spells02.cpp
src/graphics/spells/Spells03.cpp
src/graphics/spells/Spells04.cpp
src/graphics/spells/Spells05.cpp
src/graphics/spells/Spells06.cpp
src/graphics/spells/Spells07.cpp
src/graphics/spells/Spells08.cpp
src/graphics/spells/Spells09.cpp
src/graphics/spells/Spells10.cpp
src/graphics/texture/PackedTexture.cpp
src/graphics/texture/Texture.cpp
src/graphics/texture/TextureStage.cpp
)
set(GRAPHICS_D3D9_SOURCES
src/graphics/d3d9/D3D9Renderer.cpp
src/graphics/d3d9/D3D9Texture2D.cpp
src/graphics/d3d9/D3D9TextureStage.cpp
)
set(GRAPHICS_OPENGL_SOURCES
src/graphics/opengl/GLTexture2D.cpp
src/graphics/opengl/GLTextureStage.cpp
src/graphics/opengl/OpenGLRenderer.cpp
)
set(GUI_SOURCES
src/gui/Credits.cpp
src/gui/Interface.cpp
src/gui/Menu.cpp
src/gui/MenuPublic.cpp
src/gui/MenuWidgets.cpp
src/gui/MiniMap.cpp
src/gui/Note.cpp
src/gui/Speech.cpp
src/gui/Text.cpp
src/gui/TextManager.cpp
)
set(INPUT_SOURCES src/input/Input.cpp)
set(INPUT_DINPUT8_SOURCES src/input/DInput8Backend.cpp)
set(INPUT_SDL_SOURCES src/input/SDLInputBackend.cpp)
set(IO_SOURCES
src/io/Blast.cpp
src/io/CinematicLoad.cpp
src/io/Implode.cpp
src/io/IniReader.cpp
src/io/IniSection.cpp
src/io/IniWriter.cpp
src/io/IO.cpp
src/io/SaveBlock.cpp
src/io/Screenshot.cpp
)
set(IO_LOGGER_SOURCES
src/io/log/ConsoleLogger.cpp
src/io/log/FileLogger.cpp
src/io/log/LogBackend.cpp
src/io/log/Logger.cpp
)
set(IO_RESOURCE_SOURCES
src/io/resource/PakEntry.cpp
src/io/resource/PakReader.cpp
src/io/resource/ResourcePath.cpp
)
set(IO_LOGGER_POSIX_SOURCES src/io/log/ColorLogger.cpp)
set(IO_LOGGER_WINDOWS_SOURCES src/io/log/MsvcLogger.cpp)
set(IO_FILESYSTEM_SOURCES
src/io/fs/FilePath.cpp
src/io/fs/FileStream.cpp
src/io/fs/Filesystem.cpp
)
set(IO_FILESYSTEM_BOOST_SOURCES src/io/fs/FilesystemBoost.cpp)
set(IO_FILESYSTEM_POSIX_SOURCES src/io/fs/FilesystemPOSIX.cpp)
set(IO_FILESYSTEM_WINDOWS_SOURCES src/io/fs/FilesystemWindows.cpp)
set(MATH_SOURCES
src/math/Angle.cpp
src/math/Random.cpp
)
set(PHYSICS_SOURCES
src/physics/Anchors.cpp
src/physics/Attractors.cpp
src/physics/Box.cpp
src/physics/Clothes.cpp
src/physics/Collisions.cpp
src/physics/CollisionShapes.cpp
src/physics/Physics.cpp
)
set(PLATFORM_SOURCES
src/platform/CrashHandler.cpp
src/platform/Environment.cpp
src/platform/Lock.cpp
src/platform/Platform.cpp
src/platform/String.cpp
src/platform/Thread.cpp
src/platform/Time.cpp
src/platform/crashhandler/CrashHandlerImpl.cpp
)
set(PLATFORM_CRASHHANDLER_POSIX_SOURCES src/platform/crashhandler/CrashHandlerPOSIX.cpp)
set(PLATFORM_CRASHHANDLER_WINDOWS_SOURCES src/platform/crashhandler/CrashHandlerWindows.cpp)
set(SCENE_SOURCES
src/scene/ChangeLevel.cpp
src/scene/CinematicSound.cpp
src/scene/GameSound.cpp
src/scene/Interactive.cpp
src/scene/Light.cpp
src/scene/LinkedObject.cpp
src/scene/LoadLevel.cpp
src/scene/Object.cpp
src/scene/Scene.cpp
)
set(SCRIPT_SOURCES
src/script/Script.cpp
src/script/ScriptedAnimation.cpp
src/script/ScriptedCamera.cpp
src/script/ScriptedControl.cpp
src/script/ScriptedConversation.cpp
src/script/ScriptedInterface.cpp
src/script/ScriptedInventory.cpp
src/script/ScriptedIOControl.cpp
src/script/ScriptedIOProperties.cpp
src/script/ScriptedItem.cpp
src/script/ScriptedLang.cpp
src/script/ScriptedNPC.cpp
src/script/ScriptedPlayer.cpp
src/script/ScriptedVariable.cpp
src/script/ScriptEvent.cpp
src/script/ScriptUtils.cpp
)
set(WINDOW_SOURCES
src/window/RenderWindow.cpp
src/window/Window.cpp
)
set(WINDOW_SDL_SOURCES src/window/SDLWindow.cpp)
set(WINDOW_WIN32_SOURCES src/window/Win32Window.cpp)
set(WINDOW_D3D9_SOURCES src/window/D3D9Window.cpp)
file(GLOB_RECURSE ALL_INCLUDES ${SRC_DIR}/*.h)
include_directories(${SRC_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/tools)
include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS} ${IL_INCLUDE_DIR} ${FREETYPE_INCLUDE_DIRS} ${Boost_INCLUDE_DIR})
# Setting the BOOST_ROOT will result in linking failures on Visual Studio as found release and debug
# libs get mixed up. On windows we will empty out the Boost_LIBRARIES list and count on the
# auto-linking feature boost provides. http://www.boost.org/doc/libs/1_47_0/more/getting_started/windows.html#auto-linking
if (MSVC)
# Reset libraries list so VC will perform auto-linking.
set (Boost_LIBRARIES "")
# Not needed anymore as BOOST_ROOT finds these properly.
# Didnt remove yet eiher so nothing breaks, added empty checks instead to not add duplicated.
if ("${Boost_INCLUDE_DIRS}" STREQUAL "")
set (Boost_INCLUDE_DIRS ${Boost_INCLUDE_DIRS} $ENV{BOOST_ROOT}/include)
endif ()
if ("${Boost_LIBRARY_DIRS}" STREQUAL "")
set (Boost_LIBRARY_DIRS ${Boost_LIBRARY_DIRS} $ENV{BOOST_ROOT}/lib)
endif ()
# Add boost lib directory to the list of libraries paths
link_directories(${Boost_LIBRARY_DIRS})
endif ()
set(ARX_LIBRARIES ${FREETYPE_LIBRARIES} ${ZLIB_LIBRARIES} ${IL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})
if(TIME_LIBRARIES)
list(APPEND ARX_LIBRARIES ${TIME_LIBRARIES})
endif()
if(HAVE_WINAPI)
list(APPEND ARX_LIBRARIES gdi32 shell32 comdlg32 ole32 comctl32)
endif()
if(USE_OPENAL AND OPENAL_FOUND)
list(APPEND AUDIO_SOURCES ${AUDIO_OPENAL_SOURCES})
list(APPEND ARX_LIBRARIES ${OPENAL_LIBRARY})
include_directories(SYSTEM ${OPENAL_INCLUDE_DIR})
set(HAVE_OPENAL 1)
if(OPENALEFX_FOUND)
include_directories(SYSTEM ${OPENAL_EFX_INCLUDE_DIR})
set(HAVE_OPENAL_EFX 1)
endif()
endif()
if(USE_DSOUND)
# TODO does this need DIRECTX_FOUND? if so, the find_package(DirectX) should also be run if USE_DSOUND is set but USE_D3D9 isn't
list(APPEND AUDIO_SOURCES ${AUDIO_DSOUND_SOURCES})
set(HAVE_DSOUND 1)
endif()
if(USE_D3D9 AND DIRECTX_FOUND)
list(APPEND GRAPHICS_SOURCES ${GRAPHICS_D3D9_SOURCES})
list(APPEND WINDOW_SOURCES ${WINDOW_WIN32_SOURCES} ${WINDOW_D3D9_SOURCES})
list(APPEND ARX_LIBRARIES ${DIRECTX_D3D9_LIBRARY} ${DIRECTX_D3DX9_LIBRARY} ${DIRECTX_D3DCOMPILER_LIBRARY} ${DIRECTX_DXERR9_LIBRARY})
include_directories(SYSTEM ${DIRECTX_INCLUDE_DIR})
set(HAVE_D3D9 1)
endif()
if(USE_OPENGL AND OPENGL_FOUND AND GLEW_FOUND)
list(APPEND GRAPHICS_SOURCES ${GRAPHICS_OPENGL_SOURCES})
list(APPEND ARX_LIBRARIES ${OPENGL_gl_LIBRARY} ${GLEW_LIBRARIES})
include_directories(SYSTEM ${OPENGL_INCLUDE_DIR} ${GLEW_INCLUDE_DIR})
set(HAVE_OPENGL 1)
add_definitions(-DGL_GLEXT_PROTOTYPES)
endif()
if(USE_SDL AND HAVE_OPENGL AND SDL_FOUND)
list(APPEND WINDOW_SOURCES ${WINDOW_SDL_SOURCES})
list(APPEND INPUT_SOURCES ${INPUT_SDL_SOURCES})
list(APPEND ARX_LIBRARIES ${SDL_LIBRARY})
include_directories(SYSTEM ${SDL_INCLUDE_DIR})
set(HAVE_SDL 1)
endif()
if(USE_DINPUT8 AND DIRECTX_FOUND)
list(APPEND INPUT_SOURCES ${INPUT_DINPUT8_SOURCES})
list(APPEND ARX_LIBRARIES ${DIRECTX_DINPUT8_LIBRARY} ${DIRECTX_DXGUID_LIBRARY} ${DIRECTX_DXERR9_LIBRARY})
set(HAVE_DINPUT8 1)
if(WINE)
# TODO(broken-wine) work around missing symbols in wine's dinput8
list(APPEND ARX_LIBRARIES dinput)
endif()
endif()
if(HAVE_ISATTY)
list(APPEND IO_LOGGER_SOURCES ${IO_LOGGER_POSIX_SOURCES})
endif()
if(HAVE_WINAPI)
list(APPEND IO_LOGGER_SOURCES ${IO_LOGGER_WINDOWS_SOURCES})
endif()
list(APPEND IO_SOURCES ${IO_LOGGER_SOURCES})
list(APPEND IO_SOURCES ${IO_RESOURCE_SOURCES})
if(HAVE_POSIX_FILESYSTEM)
list(APPEND IO_FILESYSTEM_SOURCES ${IO_FILESYSTEM_POSIX_SOURCES})
elseif(USE_NATIVE_FS AND HAVE_WINAPI)
add_definitions(-DHAVE_WINDOWS_FILESYSTEM)
list(APPEND IO_FILESYSTEM_SOURCES ${IO_FILESYSTEM_WINDOWS_SOURCES})
set(HAVE_WIN32_FILESYSTEM 1)
elseif((Boost_MAJOR_VERSION GREATER 1) OR (NOT Boost_MINOR_VERSION LESS 44))
find_package(Boost 1.44 REQUIRED COMPONENTS ${BOOST_COMPONENTS} filesystem system)
set(HAVE_BOOST_FILESYSTEM_V3 1)
add_definitions(-DBOOST_FILESYSTEM_VERSION=3)
list(APPEND IO_FILESYSTEM_SOURCES ${IO_FILESYSTEM_BOOST_SOURCES})
list(APPEND ARX_LIBRARIES ${Boost_LIBRARIES})
else()
message(FATAL_ERROR "You need either Boost >= 1.44 or Windows API or enough POSIX functionality; Found boost version ${Boost_VERSION}")
endif()
list(APPEND IO_SOURCES ${IO_FILESYSTEM_SOURCES})
if(HAVE_CRASHREPORTER)
if((HAVE_EXECLP OR HAVE_EXECL) AND HAVE_FORK AND HAVE_KILL)
list(APPEND PLATFORM_SOURCES ${PLATFORM_CRASHHANDLER_POSIX_SOURCES})
set(HAVE_CRASHHANDLER_POSIX 1)
elseif(MSVC)
list(APPEND PLATFORM_SOURCES ${PLATFORM_CRASHHANDLER_WINDOWS_SOURCES})
set(HAVE_CRASHHANDLER_WINDOWS 1)
list(APPEND ARX_LIBRARIES ${DBGHELP_LIBRARIES})
include_directories(SYSTEM ${DBGHELP_INCLUDE_DIR})
else()
# Don't bother building arxcrashreporter if it will never be used.
#unset(HAVE_CRASHREPORTER)
endif()
endif()
if(NOT MSVC)
check_link_library(Boost Boost_LIBRARIES)
endif()
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})
# Set the icon for the Windows executable by adding this resource file to the sources
if(MSVC)
SET(ARX_SOURCES ${ARX_SOURCES} data/icons/arx-libertatis.rc)
endif()
if(BUILD_EDITOR)
list(APPEND ARX_SOURCES ${EDITOR_SOURCES})
endif()
add_definitions(-DBOOST_FILESYSTEM_NO_DEPRECATED)
#create source groups
list(APPEND ALL_FILES_FOR_GROUPS ${ALL_INCLUDES} ${ARX_SOURCES})
create_source_groups(ALL_FILES_FOR_GROUPS)
configure_file("${SRC_DIR}/Configure.h.cmake" "Configure.h" ESCAPE_QUOTES)
set(VERSION_FILE "${CMAKE_BINARY_DIR}/Version.cpp")
version_file("${SRC_DIR}/core/Version.cpp.cmake" "${VERSION_FILE}" "VERSION" ".git")
list(APPEND ARX_SOURCES "${VERSION_FILE}")
# Add executables
add_executable_shared(arx WIN32 "${ARX_SOURCES}" "${ARX_LIBRARIES}" "${ALL_INCLUDES}")
if(HAVE_CRASHREPORTER)
set(arxcrashreporter_SOURCES
tools/crashreporter/CrashReporter.cpp
tools/crashreporter/ErrorReport.h
tools/crashreporter/ErrorReport.cpp
tools/crashreporter/qhexedit/Commands.h
tools/crashreporter/qhexedit/Commands.cpp
tools/crashreporter/qhexedit/QHexEdit.h
tools/crashreporter/qhexedit/QHexEdit.cpp
tools/crashreporter/qhexedit/QHexEditPrivate.h
tools/crashreporter/qhexedit/QHexEditPrivate.cpp
tools/crashreporter/qhexedit/XByteArray.h
tools/crashreporter/qhexedit/XByteArray.cpp
tools/crashreporter/tbg/TBG.h
tools/crashreporter/tbg/TBG.cpp
tools/crashreporter/ui/ErrorReportDialog.h
tools/crashreporter/ui/ErrorReportDialog.cpp
${PLATFORM_SOURCES}
${IO_FILESYSTEM_SOURCES}
${IO_LOGGER_SOURCES}
"${VERSION_FILE}"
)
if(HAVE_WINAPI)
list(APPEND arxcrashreporter_SOURCES
tools/crashreporter/Win32Utilities.h
tools/crashreporter/Win32Utilities.cpp
)
endif()
set(arxcrashreporter_UIs
tools/crashreporter/ui/ErrorReportDialog.ui
)
set(arxcrashreporter_MOC_HEADERS
tools/crashreporter/ui/ErrorReportDialog.h
tools/crashreporter/qhexedit/QHexEdit.h
tools/crashreporter/qhexedit/QHexEditPrivate.h
)
set(arxcrashreporter_RESOURCES
tools/crashreporter/resources/CrashReporter.qrc
)
set(arxcrashreporter_MANUAL_SOURCES "${arxcrashreporter_SOURCES}")
qt4_wrap_ui(arxcrashreporter_SOURCES ${arxcrashreporter_UIs})
qt4_wrap_cpp(arxcrashreporter_SOURCES ${arxcrashreporter_MOC_HEADERS})
qt4_add_resources(arxcrashreporter_SOURCES ${arxcrashreporter_RESOURCES})
set(SRC_DIR tools/crashreporter/)
create_source_groups(arxcrashreporter_SOURCES)
set(arxcrashreporter_LIBRARIES
${QT_QTCORE_LIBRARY_RELEASE}
${QT_QTGUI_LIBRARY_RELEASE}
${QT_QTNETWORK_LIBRARY_RELEASE}
${Boost_LIBRARIES}
)
if(MSVC)
list(APPEND arxcrashreporter_LIBRARIES winmm psapi imm32)
list(APPEND arxcrashreporter_LIBRARIES ${DBGHELP_LIBRARIES})
include_directories(SYSTEM ${DBGHELP_INCLUDE_DIR})
endif()
add_executable_shared(arxcrashreporter WIN32 "${arxcrashreporter_SOURCES}"
"${arxcrashreporter_LIBRARIES}" "")
endif()
if(BUILD_TOOLS)
set(arxsavetool_SOURCES
${IO_FILESYSTEM_SOURCES}
${IO_LOGGER_SOURCES}
${IO_RESOURCE_SOURCES}
src/core/Localisation.cpp
src/io/Blast.cpp
src/io/SaveBlock.cpp
src/io/IniReader.cpp
src/io/IniSection.cpp
src/platform/String.cpp
src/platform/Platform.cpp
src/platform/Lock.cpp
tools/savetool/SaveFix.cpp
tools/savetool/SaveTool.cpp
tools/savetool/SaveView.cpp
)
set(arxsavetool_LIBRARIES ${ZLIB_LIBRARIES} ${Boost_LIBRARIES})
add_executable_shared(arxsavetool "" "${arxsavetool_SOURCES}" "${arxsavetool_LIBRARIES}" "")
set(arxunpak_SOURCES
${IO_FILESYSTEM_SOURCES}
${IO_LOGGER_SOURCES}
${IO_RESOURCE_SOURCES}
src/io/Blast.cpp
src/io/log/ColorLogger.cpp
src/io/log/ConsoleLogger.cpp
src/io/log/Logger.cpp
src/platform/String.cpp
src/platform/Platform.cpp
src/platform/Lock.cpp
tools/unpak/UnPak.cpp
)
set(arxunpak_LIBRARIES ${Boost_LIBRARIES})
add_executable_shared(arxunpak "" "${arxunpak_SOURCES}" "${arxunpak_LIBRARIES}" "")
endif()
# Build and link executables
if(UNITY_BUILD)
unity_build()
else()
shared_build()
endif()
# Custom make targets
add_custom_target(remake
#clean and compile with 1 thread per core
COMMAND make clean && rm CMakeCache.txt && cmake ${CMAKE_SOURCE_DIR} -G\"Unix Makefiles\" && make -j`getconf _NPROCESSORS_ONLN`
)
if(DOXYGEN_EXECUTABLE)
add_custom_target(doc
#build the documentation
COMMAND cd ${CMAKE_SOURCE_DIR}/src && ${DOXYGEN_EXECUTABLE} ${CMAKE_SOURCE_DIR}/doc/Doxyfile
)
endif()
file(GLOB_RECURSE TOOLS_INCLUDES ${CMAKE_SOURCE_DIR}/tools/*.h)
set(STYLE_CHECKED_SOURCES
${ARX_SOURCES}
${arxsavetool_SOURCES}
${arxunpak_SOURCES}
${arxcrashreporter_MANUAL_SOURCES}
)
set(STYLE_CHECKED_INCLUDES
${ALL_INCLUDES}
${TOOLS_INCLUDES}
)
add_style_check_target(style "${STYLE_CHECKED_SOURCES}" "${STYLE_CHECKED_INCLUDES}")
if(BUILD_TESTS)
add_subdirectory(tests ${CMAKE_SOURCE_DIR}/bin/tests)
endif()
# Print a configuration summary
message("")
message("Configuration:")
if(NOT MSVC)
if(UNITY_BUILD)
set(BUILD_TYPE_SUFFIX " (unity build)")
else()
set(BUILD_TYPE_SUFFIX "")
endif()