-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
1648 lines (1528 loc) · 52.7 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
# OpenClonk, http://www.openclonk.org
#
# Copyright (c) 2009-2018, The OpenClonk Team and contributors
#
# Distributed under the terms of the ISC license; see accompanying file
# "COPYING" for details.
#
# "Clonk" is a registered trademark of Matthes Bender, used with permission.
# See accompanying file "TRADEMARK" for details.
#
# To redistribute this file separately, substitute the full license texts
# for the above references.
cmake_minimum_required (VERSION 3.5.1)
# Don't allow people to build "Release" builds because there's no reason to do that.
# Use one of RelWithDebInfo or MinSizeRel instead.
set(CMAKE_CONFIGURATION_TYPES Debug RelWithDebInfo MinSizeRel CACHE STRING "List of supported configuration types." FORCE)
# Set a default build type as the empty build type is without either debug
# symbols or optimizations and thus completely useless.
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo)
endif()
if(POLICY CMP0067)
cmake_policy(SET CMP0067 NEW)
else()
# Wrap try_compile such that it correctly passes the standard flags to the
# compiler on CMake versions below 3.8. Remove when you update the minimum
# required version to 3.8 or later.
macro(try_compile)
set(_tc_langs)
foreach(_tc_lang CXX C)
if(DEFINED CMAKE_${_tc_lang}_STANDARD)
list(APPEND _tc_langs ${_tc_lang})
endif()
endforeach()
foreach(_tc_lang ${_tc_langs})
if (${CMAKE_${_tc_lang}_EXTENSIONS})
set(_tc_ext EXTENSION)
else()
set(_tc_ext STANDARD)
endif()
set(_backup_${_tc_lang}_flags "${CMAKE_${_tc_lang}_FLAGS}")
set(CMAKE_${_tc_lang}_FLAGS "${CMAKE_${_tc_lang}_FLAGS} ${CMAKE_${_tc_lang}${CMAKE_${_tc_lang}_STANDARD}_${_tc_ext}_COMPILE_OPTION}")
endforeach()
_try_compile(${ARGN})
foreach(_tc_lang ${_tc_langs})
set(CMAKE_${_tc_lang}_FLAGS "${_backup_${_tc_lang}_flags}")
endforeach()
endmacro()
endif()
project (openclonk CXX C)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(Version)
if(DEFINED CMAKE_ADDITIONAL_DEPS_PATH)
message(WARNING "CMAKE_ADDITIONAL_DEPS_PATH is deprecated and will be removed in a future version. Set CMAKE_PREFIX_PATH instead.")
set(CMAKE_PREFIX_PATH ${CMAKE_ADDITIONAL_DEPS_PATH})
endif()
############################################################################
# User selectable options
############################################################################
include(CMakeDependentOption)
option(PROJECT_FOLDERS "Put source files into subfolders in project file" ON)
option(DEPLOY_QT_LIBRARIES "Deploy Qt libraries to executable path" OFF)
CMAKE_DEPENDENT_OPTION(USE_COCOA "Use Apple Cocoa widgets." ON "APPLE" OFF)
CMAKE_DEPENDENT_OPTION(USE_WIN32_WINDOWS "Use Microsoft Desktop App User Interface widgets." ON "WIN32" OFF)
CMAKE_DEPENDENT_OPTION(USE_SDL_MAINLOOP "Use SDL to create windows etc. Qt editor." ON "NOT USE_COCOA AND NOT USE_WIN32_WINDOWS AND NOT HEADLESS_ONLY" OFF)
option(WITH_AUTOMATIC_UPDATE "Automatic updates are downloaded from the project website." OFF)
CMAKE_DEPENDENT_OPTION(WITH_APPDIR_INSTALLATION "Install into an AppDir" OFF "UNIX AND NOT APPLE AND WITH_AUTOMATIC_UPDATE" ON)
option(HEADLESS_ONLY "Only build headless parts. Somewhat reduces dependencies. (still needs libpng because that one's small and hard to remove.) Only tested with make/gcc/linux." OFF)
option(C4GROUP_TOOL_ONLY "Only build c4group binary." OFF)
set_property(GLOBAL PROPERTY USE_FOLDERS ${PROJECT_FOLDERS})
############################################################################
# Assemble compiler flags
############################################################################
include(CheckCXXCompilerFlag)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Try to enable link-time optimization / link-time code generation /
# interprocedural optimization for release builds.
if(POLICY CMP0069)
cmake_policy(SET CMP0069 NEW)
include(CheckIPOSupported)
check_ipo_supported(RESULT result OUTPUT output)
if(result)
foreach(_config MINSIZEREL RELWITHDEBINFO RELEASE)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_${_config} TRUE)
endforeach()
else()
message(WARNING "IPO is not supported: ${output}")
endif()
else()
message(WARNING "IPO is not supported because CMake is too old")
endif()
if(MSVC)
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
# Set up some additional flags only if we're using the MS compiler,
# and not the clang-based toolchain
# Disable non-standard conversion from string literal to (nonconst) char*
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:strictStrings")
# Activate edit-and-continue
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /ZI /Gy")
endif()
# Enable multi-core builds
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
# Fix inlining option that CMake overrides per default.
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Ob2")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /Ob2")
# do not link the release CRT in debug builds
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:MSVCRT")
set(HAVE_PRECOMPILED_HEADERS ON CACHE INTERNAL "Compiler supports precompiled headers")
# Suppress warnings about "non-secure" functions
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS)
# Disable warning C4244: 'conversion' conversion from 'type1' to 'type2', possible loss of data
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4244")
# Disable warning C4267: 'var' : conversion from 'size_t' to 'type', possible loss of data (64 bit build only)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267")
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wextra-tokens -Wpointer-arith -Wno-cast-align -Wno-reorder -Wno-unused-parameter -Wnon-virtual-dtor -Woverloaded-virtual")
elseif(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wredundant-decls -Wendif-labels -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Winit-self -Wsign-promo -Wno-reorder -Wno-unused-parameter -Wnon-virtual-dtor -Woverloaded-virtual -Wformat-security")
endif()
# Deleting a pointer to an incomplete type is undefined behavior in almost all cases, so we don't want that to happen
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /we4150")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=delete-incomplete")
endif()
if(WIN32 AND MINGW)
# Activate DEP and ASLR
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--nxcompat -Wl,--dynamicbase")
endif()
if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fobjc-arc")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -headerpad_max_install_names")
endif()
############################################################################
# Check for compiler quirks and features
############################################################################
if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CROSSCOMPILING)
include(HandleGccCrossIncludePaths)
HANDLE_GCC_CROSS_INCLUDE_PATHS(CXX c++)
HANDLE_GCC_CROSS_INCLUDE_PATHS(C c)
endif()
include(CheckCXXSourceCompiles)
include(RequireCXXSourceCompiles)
include(CheckCXXSymbolExists)
REQUIRE_CXX_SOURCE_COMPILES("#include <memory>\nint main() { std::unique_ptr<int> a; std::shared_ptr<int> b; }" HAVE_C11_SMART_PTRS)
REQUIRE_CXX_SOURCE_COMPILES("int main() { static_assert(true, \"\"); }" HAVE_STATIC_ASSERT)
REQUIRE_CXX_SOURCE_COMPILES("#include <memory>\nint main() { auto a = std::make_unique<int>(0); return !!a; }" HAVE_MAKE_UNIQUE)
REQUIRE_CXX_SOURCE_COMPILES("#include <utility>\ntemplate<std::size_t... Is> int foo(std::index_sequence<Is...>) {return 0;} int main() { return foo(std::index_sequence_for<int,int>{}); }" HAVE_INDEX_SEQUENCE)
REQUIRE_CXX_SOURCE_COMPILES("template<class... T> class C; int main() { return 0; }" HAVE_VARIADIC_TEMPLATES)
# g++'s libstdc++ doesn't properly support <regex> until 4.9.
# They ship a header that declares functions, but they don't ship an
# implementation for some things (like std::regex_iterator).
# This needs to test *linking*, not compilation; cmake does both at the same
# time, so the test below works.
REQUIRE_CXX_SOURCE_COMPILES("#include <regex>\nint main() { std::cregex_iterator ri; }" HAVE_WORKING_REGEX " If you are using gcc, please update to gcc 4.9.")
check_cxx_symbol_exists(vasprintf stdio.h HAVE_VASPRINTF)
############################################################################
# Check for required system headers
############################################################################
include(CheckIncludeFileCXX)
include(CheckIncludeFilesCXX)
CHECK_INCLUDE_FILE_CXX(io.h HAVE_IO_H)
CHECK_INCLUDE_FILE_CXX(share.h HAVE_SHARE_H)
CHECK_INCLUDE_FILE_CXX(signal.h HAVE_SIGNAL_H)
CHECK_INCLUDE_FILE_CXX(sys/stat.h HAVE_SYS_STAT_H)
CHECK_INCLUDE_FILE_CXX(sys/types.h HAVE_SYS_TYPES_H)
CHECK_INCLUDE_FILE_CXX(unistd.h HAVE_UNISTD_H)
CHECK_INCLUDE_FILE_CXX(execinfo.h HAVE_EXECINFO_H)
CHECK_INCLUDE_FILE_CXX(poll.h HAVE_POLL_H)
CHECK_INCLUDE_FILE_CXX(sys/inotify.h HAVE_SYS_INOTIFY_H)
CHECK_INCLUDE_FILE_CXX(sys/timerfd.h HAVE_SYS_TIMERFD_H)
CHECK_INCLUDE_FILE_CXX(sys/socket.h HAVE_SYS_SOCKET_H)
CHECK_INCLUDE_FILE_CXX(sys/eventfd.h HAVE_SYS_EVENTFD_H)
CHECK_INCLUDE_FILE_CXX(sys/file.h HAVE_SYS_FILE_H)
CHECK_INCLUDE_FILES_CXX("X11/Xlib.h;X11/extensions/Xrandr.h" HAVE_X11_EXTENSIONS_XRANDR_H)
CHECK_CXX_SOURCE_COMPILES("#include <getopt.h>\nint main(int argc, char * argv[]) { getopt_long(argc, argv, \"\", 0, 0); }" HAVE_GETOPT_H)
############################################################################
# Locate libraries
############################################################################
SET(JPEG_NAMES ${JPEG_NAMES} libjpeg jpeg-static)
if(NOT HEADLESS_ONLY AND NOT C4GROUP_TOOL_ONLY)
find_package(Freetype REQUIRED)
include_directories(
${FREETYPE_INCLUDE_DIRS})
link_directories(
${FREETYPE_LIBRARY_DIRS})
endif()
# Needed for c4group
find_package(ZLIB REQUIRED)
if (NOT C4GROUP_TOOL_ONLY)
find_package(JPEG REQUIRED)
find_package(PNG REQUIRED)
include_directories(
${JPEG_INCLUDE_DIR}
${PNG_INCLUDE_DIR}
${ZLIB_INCLUDE_DIR})
if(CMAKE_SYSTEM MATCHES "Windows")
message(STATUS "Using Win32 threading.")
else()
find_package("Threads" REQUIRED)
SET(HAVE_PTHREAD ${CMAKE_USE_PTHREADS_INIT} CACHE INTERNAL "libpthread available")
endif()
endif()
# FINDLIB works the same as find_library, but also marks the resulting var as
# advanced so it doesn't show in GUIs by default
macro(FINDLIB lib)
find_library(${ARGV})
mark_as_advanced(${lib})
endmacro(FINDLIB)
if(HAVE_EXECINFO_H)
check_cxx_symbol_exists(backtrace execinfo.h HAVE_EXECINFO_WO_LINK)
mark_as_advanced(HAVE_EXECINFO_WO_LINK)
if(NOT HAVE_EXECINFO_WO_LINK)
FINDLIB(EXECINFO_LIBRARY execinfo)
endif()
endif()
if(NOT HAVE_GETOPT_H)
include_directories(SYSTEM thirdparty/getopt)
add_subdirectory(thirdparty/getopt)
set_property(TARGET getopt PROPERTY FOLDER "Third-party libraries")
set(GETOPT_LIBRARIES getopt)
endif()
if (NOT C4GROUP_TOOL_ONLY)
# TinyXML
find_package(TinyXML)
if(NOT TinyXML_FOUND)
add_subdirectory(thirdparty/tinyxml)
set_property(TARGET tinyxml PROPERTY FOLDER "Third-party libraries")
set(TinyXML_INCLUDE_DIRS thirdparty/tinyxml)
set(TinyXML_LIBRARIES tinyxml)
set(TinyXML_FOUND TRUE)
endif()
include_directories(SYSTEM ${TinyXML_INCLUDE_DIRS})
endif()
if(NOT HEADLESS_ONLY AND NOT C4GROUP_TOOL_ONLY)
find_package(OpenGL)
find_package(GLEW REQUIRED)
include_directories(${GLEW_INCLUDE_DIRS})
add_definitions(${GLEW_DEFINITIONS})
# On some platforms, GLEW declares the userParam parameter of
# GLDEBUGPROCARB as const void *, and on other platforms, it's void *.
# Test which one works here.
set(CMAKE_REQUIRED_INCLUDES "${GLEW_INCLUDE_DIRS}")
CHECK_CXX_SOURCE_COMPILES("#include <GL/glew.h>\nvoid GLAPIENTRY OpenGLDebugProc(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const char* message, const void* userParam) {}\nint main() { GLDEBUGPROCARB proc = &OpenGLDebugProc; }" GLDEBUGPROCARB_USERPARAM_IS_CONST)
endif()
if(NOT C4GROUP_TOOL_ONLY)
if(UNIX AND NOT APPLE)
FINDLIB(X11_LIBRARIES X11)
set(Backward_DIR thirdparty/backward-cpp)
find_package(Backward)
if(Backward_FOUND)
set(HAVE_BACKWARD 1)
endif()
if(NOT DEFINED PROC_SELF_EXE)
macro(FIND_PROC_SELF_EXE path)
if(EXISTS ${path})
set(PROC_SELF_EXE ${path} CACHE FILEPATH "Path to /proc/self/exe (Linux) or equivalent")
endif()
endmacro()
FIND_PROC_SELF_EXE(/proc/self/exe) # Linux
FIND_PROC_SELF_EXE(/proc/curproc/file) # FreeBSD
FIND_PROC_SELF_EXE(/proc/curproc/exe) # NetBSD
endif()
endif()
endif()
if (WIN32)
find_package(DbgHelp)
if(DBGHELP_FOUND)
include_directories(${DBGHELP_INCLUDE_DIR})
endif()
set(HAVE_DBGHELP ${DBGHELP_FOUND})
endif()
if(NOT C4GROUP_TOOL_ONLY)
find_package(Upnp)
if(UPNP_FOUND)
include_directories(SYSTEM ${UPNP_INCLUDE_DIR})
endif()
find_package(Readline)
if(READLINE_FOUND)
include_directories(SYSTEM ${READLINE_INCLUDE_DIR})
endif()
SET(HAVE_LIBREADLINE ${READLINE_FOUND} CACHE INTERNAL "libreadline available")
find_package(GTK3 COMPONENTS gthread gio gobject glib OPTIONAL_COMPONENTS gtksourceview)
# Select an audio library
find_package("Audio")
if(Audio_FOUND)
include_directories(${Audio_INCLUDE_DIRS})
endif()
# SDL
if(USE_SDL_MAINLOOP)
find_package(SDL2 REQUIRED)
else()
# for gamepads
find_package(SDL2)
endif()
set(HAVE_SDL ${SDL2_FOUND})
include_directories(SYSTEM ${SDL2_INCLUDE_DIRS})
# Qt5 for editor
find_package(Qt5 5.4 CONFIG COMPONENTS Core Widgets)
if(TARGET Qt5::Core)
SET(WITH_QT_EDITOR ON "Qt editor dialogues available")
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
# As moc files are generated in the binary dir, tell CMake
# to always look for includes there:
set(CMAKE_INCLUDE_CURRENT_DIR ON)
else()
message("Qt5Widgets not found. Building openclonk without editor.")
UNSET(WITH_QT_EDITOR)
endif()
endif()
############################################################################
# generated source files
############################################################################
if(NOT C4GROUP_TOOL_ONLY)
find_program(GLIB_COMPILE_RESOURCES glib-compile-resources)
add_custom_command(
OUTPUT mape-resource.c
COMMAND
${GLIB_COMPILE_RESOURCES} "--internal" "--generate"
"--target" "mape-resource.c"
"--sourcedir" ${CMAKE_CURRENT_SOURCE_DIR}/src/res
"${CMAKE_CURRENT_SOURCE_DIR}/src/res/mape.xml"
MAIN_DEPENDENCY src/res/mape.xml
DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/src/res/ocd.ico
${CMAKE_CURRENT_SOURCE_DIR}/src/res/ocf.ico
${CMAKE_CURRENT_SOURCE_DIR}/src/res/ocg.ico
${CMAKE_CURRENT_SOURCE_DIR}/src/res/ocm.ico
${CMAKE_CURRENT_SOURCE_DIR}/src/res/ocs.ico
VERBATIM
)
endif()
############################################################################
# Mac OS bundle setup
############################################################################
if(APPLE)
list(APPEND OC_BUNDLE_RESOURCES
src/res/oc.icns
src/res/ocd.icns src/res/ocf.icns src/res/ocg.icns
src/res/C4P.icns src/res/ocs.icns src/res/ocu.icns
src/res/Mouse_Trans.png
src/res/Cursor_Trans.png
src/res/Brush_Trans.png
src/res/Play_Trans.png
src/res/Halt_Trans.png
src/res/Dynamic_Trans.png
src/res/Static_Trans.png
src/res/Exact_Trans.png
src/res/Line_Trans.png
src/res/Rect_Trans.png
src/res/Fill_Trans.png
src/res/Picker_Trans.png
)
if (CMAKE_GENERATOR STREQUAL Xcode)
list(APPEND OC_BUNDLE_RESOURCES
src/res/MainMenu.xib
src/res/FullScreen.xib
src/res/EditorGUIWindow.xib
src/res/EditorViewport.xib
src/res/Editor.xib
)
else()
list(APPEND OC_BUNDLE_RESOURCES
src/res/nib/MainMenu.nib
src/res/nib/FullScreen.nib
src/res/nib/EditorGUIWindow.nib
src/res/nib/EditorViewport.nib
src/res/nib/Editor.nib
)
endif()
# Add icon resources
set_source_files_properties(
${OC_BUNDLE_RESOURCES}
PROPERTIES MACOSX_PACKAGE_LOCATION Resources
)
endif()
############################################################################
# List target source files. Don't directly create a target since we condi-
# tionally add more sources depending on configuration options later.
############################################################################
# OC_CLONK_SOURCES: Sources for OpenClonk that are needed by every build.
# OC_SYSTEM_SOURCES: Sources for OpenClonk that are only needed by specific
# platforms.
# OC_GUI_SOURCES: Sources that are only needed by GUI applications.
set(OC_CLONK_SOURCES
src/C4Globals.cpp
src/c4group/C4Components.h
src/c4group/C4Language.cpp
src/c4group/C4Language.h
src/C4Include.cpp
src/C4Include.h
src/C4Prototypes.h
src/C4Version.h
src/config/C4Config.cpp
src/config/C4Config.h
src/config/C4Constants.h
src/config/C4Reloc.cpp
src/config/C4Reloc.h
src/control/C4Control.cpp
src/control/C4Control.h
src/control/C4GameControl.cpp
src/control/C4GameControl.h
src/control/C4GameParameters.cpp
src/control/C4GameParameters.h
src/control/C4GameSave.cpp
src/control/C4GameSave.h
src/control/C4PlayerControl.cpp
src/control/C4PlayerControl.h
src/control/C4PlayerInfo.cpp
src/control/C4PlayerInfo.h
src/control/C4Record.cpp
src/control/C4Record.h
src/control/C4RoundResults.cpp
src/control/C4RoundResults.h
src/control/C4Teams.cpp
src/control/C4Teams.h
src/editor/C4Console.cpp
src/editor/C4ConsoleGUICommon.h
src/editor/C4ConsoleGUI.h
src/editor/C4Console.h
src/editor/C4EditCursor.cpp
src/editor/C4EditCursor.h
src/editor/C4ObjectListDlg.cpp
src/editor/C4ObjectListDlg.h
src/editor/C4ToolsDlg.cpp
src/editor/C4ToolsDlg.h
src/editor/C4ViewportWindow.cpp
src/editor/C4ViewportWindow.h
src/game/C4Application.cpp
src/game/C4Application.h
src/game/C4FullScreen.cpp
src/game/C4FullScreen.h
src/game/C4Game.cpp
src/game/C4Game.h
src/game/C4GameScript.cpp
src/game/C4GameScript.h
src/game/C4GameVersion.h
src/game/C4GraphicsSystem.cpp
src/game/C4GraphicsSystem.h
src/game/C4Physics.h
src/game/C4Viewport.cpp
src/game/C4Viewport.h
src/graphics/C4Draw.cpp
src/graphics/C4DrawGL.cpp
src/graphics/C4DrawGLCtx.cpp
src/graphics/C4DrawGL.h
src/graphics/C4DrawMeshGL.cpp
src/graphics/C4DrawT.cpp
src/graphics/C4DrawT.h
src/graphics/C4Draw.h
src/graphics/C4Facet.cpp
src/graphics/C4FacetEx.cpp
src/graphics/C4FacetEx.h
src/graphics/C4Facet.h
src/graphics/C4FontLoader.cpp
src/graphics/C4FontLoader.h
src/graphics/C4GraphicsResource.cpp
src/graphics/C4GraphicsResource.h
src/graphics/C4Shader.cpp
src/graphics/C4Shader.h
src/graphics/C4Surface.cpp
src/graphics/C4Surface.h
src/graphics/C4SurfaceLoaders.cpp
src/gui/C4ChatDlg.cpp
src/gui/C4ChatDlg.h
src/gui/C4DownloadDlg.cpp
src/gui/C4DownloadDlg.h
src/gui/C4FileSelDlg.cpp
src/gui/C4FileSelDlg.h
src/gui/C4GameDialogs.cpp
src/gui/C4GameDialogs.h
src/gui/C4GameLobby.cpp
src/gui/C4GameLobby.h
src/gui/C4GameMessage.cpp
src/gui/C4GameMessage.h
src/gui/C4GameOptions.cpp
src/gui/C4GameOptions.h
src/gui/C4GameOverDlg.cpp
src/gui/C4GameOverDlg.h
src/gui/C4GfxErrorDlg.cpp
src/gui/C4GfxErrorDlg.h
src/gui/C4GuiButton.cpp
src/gui/C4GuiCheckBox.cpp
src/gui/C4GuiComboBox.cpp
src/gui/C4GuiContainers.cpp
src/gui/C4Gui.cpp
src/gui/C4GuiDialogs.cpp
src/gui/C4GuiEdit.cpp
src/gui/C4Gui.h
src/gui/C4GuiLabels.cpp
src/gui/C4GuiListBox.cpp
src/gui/C4GuiMenu.cpp
src/gui/C4GuiTabular.cpp
src/gui/C4ScriptGuiWindow.cpp
src/gui/C4KeyboardInput.cpp
src/gui/C4KeyboardInput.h
src/gui/C4LoaderScreen.cpp
src/gui/C4LoaderScreen.h
src/gui/C4MainMenu.cpp
src/gui/C4MainMenu.h
src/gui/C4Menu.cpp
src/gui/C4Menu.h
src/gui/C4MessageBoard.cpp
src/gui/C4MessageBoard.h
src/gui/C4MessageInput.cpp
src/gui/C4MessageInput.h
src/gui/C4MouseControl.cpp
src/gui/C4MouseControl.h
src/gui/C4PlayerInfoListBox.cpp
src/gui/C4PlayerInfoListBox.h
src/gui/C4Scoreboard.cpp
src/gui/C4Scoreboard.h
src/gui/C4ScriptGuiWindow.cpp
src/gui/C4ScriptGuiWindow.h
src/gui/C4StartupAboutDlg.cpp
src/gui/C4StartupAboutDlg.h
src/gui/C4Startup.cpp
src/gui/C4Startup.h
src/gui/C4StartupMainDlg.cpp
src/gui/C4StartupMainDlg.h
src/gui/C4StartupNetDlg.cpp
src/gui/C4StartupNetDlg.h
src/gui/C4StartupOptionsDlg.cpp
src/gui/C4StartupOptionsDlg.h
src/gui/C4StartupPlrSelDlg.cpp
src/gui/C4StartupPlrSelDlg.h
src/gui/C4StartupScenSelDlg.cpp
src/gui/C4StartupScenSelDlg.h
src/gui/C4UpperBoard.cpp
src/gui/C4UpperBoard.h
src/landscape/fow/C4FoW.cpp
src/landscape/fow/C4FoW.h
src/landscape/fow/C4FoWAmbient.cpp
src/landscape/fow/C4FoWAmbient.h
src/landscape/fow/C4FoWBeam.cpp
src/landscape/fow/C4FoWBeam.h
src/landscape/fow/C4FoWLight.cpp
src/landscape/fow/C4FoWLight.h
src/landscape/fow/C4FoWLightSection.cpp
src/landscape/fow/C4FoWLightSection.h
src/landscape/fow/C4FoWRegion.cpp
src/landscape/fow/C4FoWRegion.h
src/landscape/fow/C4FoWDrawStrategy.cpp
src/landscape/fow/C4FoWDrawStrategy.h
src/landscape/fow/C4FoWBeamTriangle.h
src/landscape/C4Landscape.cpp
src/landscape/C4Landscape.h
src/landscape/C4LandscapeRender.cpp
src/landscape/C4LandscapeRender.h
src/landscape/C4Map.cpp
src/landscape/C4MapCreatorS2.cpp
src/landscape/C4MapCreatorS2.h
src/landscape/C4Map.h
src/landscape/C4MapScript.cpp
src/landscape/C4MapScript.h
src/landscape/C4Material.cpp
src/landscape/C4Material.h
src/landscape/C4Particles.cpp
src/landscape/C4Particles.h
src/landscape/C4PathFinder.cpp
src/landscape/C4PathFinder.h
src/landscape/C4PXS.cpp
src/landscape/C4PXS.h
src/landscape/C4Sky.cpp
src/landscape/C4Sky.h
src/landscape/C4SolidMask.cpp
src/landscape/C4SolidMask.h
src/landscape/C4Texture.cpp
src/landscape/C4Texture.h
src/landscape/C4TransferZone.cpp
src/landscape/C4TransferZone.h
src/landscape/C4Weather.cpp
src/landscape/C4Weather.h
src/lib/C4Rect.cpp
src/lib/C4Rect.h
src/lib/StdAdaptors.h
src/lib/StdColors.h
src/lib/StdMesh.cpp
src/lib/StdMesh.h
src/lib/StdMeshLoaderBinaryChunks.cpp
src/lib/StdMeshLoaderBinaryChunks.h
src/lib/StdMeshLoaderBinary.cpp
src/lib/StdMeshLoaderDataStream.h
src/lib/StdMeshLoader.cpp
src/lib/StdMeshLoader.h
src/lib/StdMeshLoaderXml.cpp
src/lib/StdMeshMaterial.cpp
src/lib/StdMeshMaterial.h
src/lib/StdMeshUpdate.cpp
src/lib/StdMeshUpdate.h
src/network/C4Client.cpp
src/network/C4Client.h
src/network/C4GameControlNetwork.cpp
src/network/C4GameControlNetwork.h
src/network/C4InteractiveThread.cpp
src/network/C4InteractiveThread.h
src/network/C4League.cpp
src/network/C4League.h
src/network/C4Network2Client.cpp
src/network/C4Network2Client.h
src/network/C4Network2.cpp
src/network/C4Network2Dialogs.cpp
src/network/C4Network2Dialogs.h
src/network/C4Network2.h
src/network/C4Network2IO.cpp
src/network/C4Network2IO.h
src/network/C4Network2IRC.cpp
src/network/C4Network2IRC.h
src/network/C4Network2Players.cpp
src/network/C4Network2Players.h
src/network/C4Network2Reference.cpp
src/network/C4Network2Reference.h
src/network/C4Network2Res.cpp
src/network/C4Network2ResDlg.cpp
src/network/C4Network2Res.h
src/network/C4Network2Stats.cpp
src/network/C4Network2Stats.h
src/network/C4Network2UPnP.h
src/network/C4Packet2.cpp
src/network/C4PacketBase.h
src/object/C4Command.cpp
src/object/C4Command.h
src/object/C4Def.cpp
src/object/C4DefGraphics.cpp
src/object/C4DefGraphics.h
src/object/C4Def.h
src/object/C4DefList.cpp
src/object/C4DefList.h
src/object/C4GameObjects.cpp
src/object/C4GameObjects.h
src/object/C4IDList.cpp
src/object/C4IDList.h
src/object/C4MeshAnimation.cpp
src/object/C4MeshAnimation.h
src/object/C4MeshDenumerator.cpp
src/object/C4MeshDenumerator.h
src/object/C4ObjectCom.cpp
src/object/C4ObjectCom.h
src/object/C4ObjectCommand.cpp
src/object/C4ObjectContents.cpp
src/object/C4Object.cpp
src/object/C4Object.h
src/object/C4ObjectAction.cpp
src/object/C4ObjectGraphics.cpp
src/object/C4ObjectInfo.cpp
src/object/C4ObjectInfo.h
src/object/C4ObjectInfoList.cpp
src/object/C4ObjectInfoList.h
src/object/C4ObjectList.cpp
src/object/C4ObjectList.h
src/object/C4ObjectMenu.cpp
src/object/C4ObjectMenu.h
src/object/C4ObjectMenuLogic.cpp
src/object/C4ObjectOCF.cpp
src/object/C4ObjectPhysics.cpp
src/object/C4ObjectRank.cpp
src/object/C4ObjectScript.cpp
src/object/C4ObjectVisibility.cpp
src/platform/C4App.cpp
src/platform/C4App.h
src/platform/C4AppWin32Impl.h
src/platform/C4FileMonitor.cpp
src/platform/C4FileMonitor.h
src/platform/C4GamePadCon.cpp
src/platform/C4GamePadCon.h
src/platform/C4MusicFile.cpp
src/platform/C4MusicFile.h
src/platform/C4MusicSystem.cpp
src/platform/C4MusicSystem.h
src/platform/C4SoundLoaders.cpp
src/platform/C4SoundLoaders.h
src/platform/C4SoundIncludes.h
src/platform/C4SoundInstance.cpp
src/platform/C4SoundInstance.h
src/platform/C4SoundModifiers.cpp
src/platform/C4SoundModifiers.h
src/platform/C4SoundSystem.cpp
src/platform/C4SoundSystem.h
src/platform/C4Window.h
src/platform/C4windowswrapper.h
src/platform/PlatformAbstraction.cpp
src/platform/PlatformAbstraction.h
src/platform/StdSync.h
src/player/C4Achievement.cpp
src/player/C4Achievement.h
src/player/C4Player.cpp
src/player/C4Player.h
src/player/C4PlayerList.cpp
src/player/C4PlayerList.h
src/player/C4RankSystem.cpp
src/player/C4RankSystem.h
src/player/C4ScenarioParameters.cpp
src/player/C4ScenarioParameters.h
src/script/C4AulDebug.cpp
src/script/C4AulDebug.h
thirdparty/timsort/sort.h
src/lib/C4LogBuf.cpp
src/lib/C4LogBuf.h
src/lib/C4Log.cpp
src/lib/C4Log.h
)
if(WITH_QT_EDITOR)
qt5_add_resources(qt_editor_resources "src/editor/resource.qrc")
set(QT_EDITOR_SOURCES
src/editor/C4PropertyPath.cpp
src/editor/C4PropertyPath.h
src/editor/C4ConsoleQt.cpp
src/editor/C4ConsoleQt.h
src/editor/C4ConsoleQtState.cpp
src/editor/C4ConsoleQtState.h
src/editor/C4ConsoleQtShapes.cpp
src/editor/C4ConsoleQtShapes.h
src/editor/C4ConsoleQtPropListViewer.cpp
src/editor/C4ConsoleQtPropListViewer.h
src/editor/C4ConsoleQtObjectListViewer.cpp
src/editor/C4ConsoleQtObjectListViewer.h
src/editor/C4ConsoleQtDefinitionListViewer.cpp
src/editor/C4ConsoleQtDefinitionListViewer.h
src/editor/C4ConsoleQtViewport.cpp
src/editor/C4ConsoleQtViewport.h
src/editor/C4ConsoleQtNewScenario.cpp
src/editor/C4ConsoleQtNewScenario.h
src/editor/C4ConsoleQtNewScenario.ui
src/editor/C4ConsoleQtLocalizeString.cpp
src/editor/C4ConsoleQtLocalizeString.h
src/editor/C4ConsoleQtLocalizeString.ui
src/editor/C4ConsoleQtLocalizeOverview.cpp
src/editor/C4ConsoleQtLocalizeOverview.h
src/editor/C4ConsoleQtLocalizeOverview.ui
src/editor/C4ConsoleQtMainWindow.ui
src/editor/resource.qrc
${qt_editor_resources}
)
endif()
set(MAPE_BASE_SOURCES
src/C4Include.cpp
src/landscape/C4MapCreatorS2.cpp
src/landscape/C4MapCreatorS2.h
src/landscape/C4MapScriptAlgo.cpp
src/landscape/C4MapScript.cpp
src/landscape/C4MapScript.h
src/landscape/C4Material.cpp
src/landscape/C4Material.h
src/landscape/C4Texture.cpp
src/landscape/C4Texture.h
src/landscape/C4Scenario.cpp
src/landscape/C4Scenario.h
src/graphics/Bitmap256.cpp
src/graphics/Bitmap256.h
src/graphics/CSurface8.cpp
src/graphics/CSurface8.h
src/lib/C4NameList.cpp
src/lib/C4NameList.h
src/lib/C4Rect.cpp
src/lib/C4Rect.h
src/object/C4Id.cpp
src/object/C4Id.h
src/script/C4ScriptStandaloneStubs.cpp
)
set(MAPE_SOURCES
src/mape/cpp-handles/c4def-handle.cpp
src/mape/cpp-handles/group-handle.h
src/mape/cpp-handles/group-handle.cpp
src/mape/cpp-handles/landscape-handle.cpp
src/mape/cpp-handles/log-handle.h
src/mape/cpp-handles/log-handle.cpp
src/mape/cpp-handles/mapgen-handle.h
src/mape/cpp-handles/mapgen-handle.cpp
src/mape/cpp-handles/material-handle.h
src/mape/cpp-handles/material-handle.cpp
src/mape/cpp-handles/random-handle.h
src/mape/cpp-handles/random-handle.cpp
src/mape/cpp-handles/texture-handle.h
src/mape/cpp-handles/texture-handle.cpp
src/mape/cpp-handles/version-handle.h
src/mape/cpp-handles/version-handle.cpp
src/mape/cpp-handles/stub-handle.cpp
src/mape/configfile.c
src/mape/configfile.h
src/mape/diskview.c
src/mape/diskview.h
src/mape/editview.c
src/mape/editview.h
src/mape/fileicon.c
src/mape/fileicon.h
src/mape/forward.h
src/mape/group.c
src/mape/group.h
src/mape/header.c
src/mape/header.h
src/mape/iconview.c
src/mape/iconview.h
src/mape/mape.c
src/mape/mapgen.c
src/mape/mapgen.h
src/mape/material.c
src/mape/material.h
src/mape/mattexview.c
src/mape/mattexview.h
src/mape/preferences.c
src/mape/preferences.h
src/mape/preferencesdialog.c
src/mape/preferencesdialog.h
src/mape/preview.c
src/mape/preview.h
src/mape/random.c
src/mape/random.h
src/mape/statusbar.c
src/mape/statusbar.h
src/mape/texture.c
src/mape/texture.h
src/mape/window.c
src/mape/window.h
mape-resource.c
)
set_property(SOURCE mape-resource.c PROPERTY SKIP_AUTOGEN ON)
# source files specific to an operating system
if(APPLE)
list(APPEND OC_SYSTEM_SOURCES
src/platform/C4AppMac.mm
src/platform/C4FileMonitorMac.mm
src/platform/C4AppDelegate.h
src/platform/C4AppDelegate.mm
src/platform/ObjectiveCAssociated.h
)
list(APPEND OC_GUI_SOURCES ${OC_BUNDLE_RESOURCES})
else()
list(APPEND OC_SYSTEM_SOURCES
src/game/ClonkMain.cpp
)
endif()
if(WIN32)
list(APPEND OC_SYSTEM_SOURCES
src/platform/C4CrashHandlerWin32.cpp
)
list(APPEND OC_GUI_SOURCES
src/res/engine.rc
src/res/resource.h
)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/res/openclonk.manifest" "${CMAKE_CURRENT_BINARY_DIR}/openclonk.manifest" COPYONLY)
endif()
if(NOT UPNP_FOUND)
list(APPEND OC_SYSTEM_SOURCES
src/network/C4Network2UPnPDummy.cpp
)
elseif(UPNP_STYLE STREQUAL "Win32")
list(APPEND OC_SYSTEM_SOURCES
src/network/C4Network2UPnPWin32.cpp
)
elseif(UPNP_STYLE STREQUAL "miniupnpc")
list(APPEND OC_SYSTEM_SOURCES
src/network/C4Network2UPnPLinux.cpp
)
endif()
# source files specific to a GUI library
if(USE_SDL_MAINLOOP)
list(APPEND OC_GUI_SOURCES
src/platform/C4AppSDL.cpp
src/platform/C4WindowSDL.cpp
)
if(WITH_QT_EDITOR)
list(APPEND OC_GUI_SOURCES ${QT_EDITOR_SOURCES})
endif()
elseif(USE_WIN32_WINDOWS)
if(WITH_QT_EDITOR)
list(APPEND OC_GUI_SOURCES ${QT_EDITOR_SOURCES})
else()
list(APPEND OC_GUI_SOURCES
src/editor/C4ConsoleWin32.cpp
)
endif()
list(APPEND OC_GUI_SOURCES
src/platform/C4WindowWin32.cpp
)
elseif(USE_COCOA)
list(APPEND OC_GUI_SOURCES
src/platform/C4WindowMac.mm
src/platform/C4AppDelegate+MainMenuActions.h
src/platform/C4AppDelegate+MainMenuActions.mm
src/graphics/C4DrawGLMac.h
src/graphics/C4DrawGLMac.mm
src/platform/C4WindowController.h
src/platform/C4WindowController.mm
src/platform/CocoaKeycodeMap.h
)
if(WITH_QT_EDITOR)
list(APPEND OC_GUI_SOURCES ${QT_EDITOR_SOURCES})
endif()
endif()
if(WITH_AUTOMATIC_UPDATE)
list(APPEND OC_GUI_SOURCES
src/gui/C4UpdateDlg.cpp
src/gui/C4UpdateDlg.h
)
endif()
if(PROJECT_FOLDERS)
source_group("Core" src/.*)
source_group("Platform abstraction" src/platform/.*)
source_group("Utility" src/lib/.*)
source_group("C4Group" src/c4group/.*)
source_group("Graphics" src/graphics/.*)
source_group("GUI" src/gui/.*)
source_group("Network" src/network/.*)
source_group("Object" src/object/.*)
source_group("Landscape" src/landscape/.*)
source_group("Player" src/player/.*)
source_group("Script" REGULAR_EXPRESSION .*script/.*)
source_group("Config" src/config/.*)
source_group("Control" src/control/.*)
source_group("Editing" src/editor/.*)
source_group("Mape" src/mape/.*)
endif()
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/src
)
# Mark thirdparty as system headers so we don't get warnings from them
include_directories(SYSTEM
${CMAKE_CURRENT_SOURCE_DIR}/thirdparty
)
############################################################################
# Generate output files
############################################################################
add_definitions(-DHAVE_CONFIG_H)
add_library(libmisc STATIC
src/C4Include.cpp
src/c4group/C4Group.cpp
src/c4group/C4Group.h
src/c4group/C4Update.cpp