File: CMakeLists.txt

package info (click to toggle)
fife 0.4.2-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 24,708 kB
  • sloc: cpp: 42,641; xml: 18,881; python: 13,555; makefile: 22
file content (1071 lines) | stat: -rw-r--r-- 50,328 bytes parent folder | download
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
#------------------------------------------------------------------------------
#                                 Fifengine                                          
#------------------------------------------------------------------------------

cmake_minimum_required(VERSION 3.2.2)

project(fifengine C CXX)

#------------------------------------------------------------------------------
#                                 Version                                          
#------------------------------------------------------------------------------

set(FIFE_MAJOR_VERSION 0)
set(FIFE_MINOR_VERSION 4)
set(FIFE_PATCH_VERSION 2)
set(FIFE_VERSION_SHORT ${FIFE_MAJOR_VERSION}.${FIFE_MINOR_VERSION}.${FIFE_PATCH_VERSION})

# check if "git" is installed
find_program(GIT_TOOL git DOC "Git version control")
mark_as_advanced(GIT_TOOL)

# get git commit hash, if source folder is a git repository
find_file(GIT_DIR NAMES .git PATHS ${CMAKE_SOURCE_DIR} NO_DEFAULT_PATH)

if(GIT_TOOL AND GIT_DIR)
  execute_process(
    COMMAND git rev-parse --short=7 HEAD
    WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
    OUTPUT_VARIABLE GIT_COMMIT_HASH
    OUTPUT_STRIP_TRAILING_WHITESPACE
  )
  set(FIFE_GIT_HASH ${GIT_COMMIT_HASH})
  unset(GIT_DIR)
else()
  # not a git repo, possibly a source download
  set(FIFE_GIT_HASH "")
endif()

if(GIT_COMMIT_HASH)
  set(FIFE_VERSION ${FIFE_VERSION_SHORT}+build.${FIFE_GIT_HASH})
else()
  set(FIFE_VERSION ${FIFE_VERSION_SHORT})
endif()

message("== Updating version.h with version information and git meta data.")

configure_file (
  "${PROJECT_SOURCE_DIR}/engine/core/version.h.in"
  "${PROJECT_SOURCE_DIR}/engine/core/version.h"
)

#------------------------------------------------------------------------------
#                                 Options                                          
#------------------------------------------------------------------------------

option(opengl           "Enable OpenGL support"                                 ON)
option(fifechan         "Enable Fifechan GUI subsystem"                         ON)
option(librocket        "Enable Librocket GUI subsystem"                        OFF)
option(cegui            "Enable Crazy Eddie's GUI subsystem"                    OFF)
option(logging          "Enable logging"                                        ON)
option(build-python     "Build the python extension module"                     ON)
option(build-library    "Build and install files to directly develop with c++"  OFF)

#------------------------------------------------------------------------------
#                                 Configure                                          
#------------------------------------------------------------------------------

# set path to our custom CMAKE scripts
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")

# Create a "Release" build by default.
if(NOT CMAKE_BUILD_TYPE)
  set(CMAKE_BUILD_TYPE "Release" CACHE STRING
    "Select build type. Options are: 'Debug', 'Release', 'RelWithDebInfo' and 'MinSizeRel'."
    FORCE
  )
  message(STATUS "Set CMAKE_BUILD_TYPE to default '${CMAKE_BUILD_TYPE}'.")
endif(NOT CMAKE_BUILD_TYPE)

# if building a C++ library is enabled, then build a shared library by default
# if you need a static library, set "-Dbuild-library=ON -DBUILD_SHARED_LIBS=OFF"
if(build-library)
  set(BUILD_SHARED_LIBS ON CACHE BOOL "Build a shared or static library")
endif(build-library)

# Do not allow an in-source-tree build, request an out-of-source-tree build.
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
  message(FATAL_ERROR "#Please build outside of the source tree!\n                        
                       Make an out-of-source-tree folder for building and run CMake there:\n
                       mkdir ../_build; cd ../_build; cmake ../fifengine\n
                       Before that, cleanup:\nrm -rf CMakeCache.txt CMakeFiles")
endif()

# Disable in-source builds and modifications to the source tree.
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)

# organize targets into folders
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

#------------------------------------------------------------------------------
#                                 Compiler Options                                         
#------------------------------------------------------------------------------

# MSVC compiler options
if(WIN32 AND MSVC)
  # build on all cores
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /nologo")

  if(CMAKE_BUILD_TYPE STREQUAL "Release")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W0 /O2")   
  else()
    # warning level: /W<level 0 to 4> or /Wall
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /Od")   
  endif()
  
  # ensure we use minimal "windows.h" lib without the crazy min max macros    
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"WIN32_LEAN_AND_MEAN\"")
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"NOMINMAX\"")

  # avoid "C1128: number of sections exceeded object file format limit: compile with /bigobj"
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")

  # disable SAFESEH - to avoid "LNK2026: module unsafe" on "OpenAL32.lib"
  set(CMAKE_CXX_FLAGS           "${CMAKE_CXX_FLAGS} /D /SAFESEH:NO")
  set(CMAKE_EXE_LINKER_FLAGS    "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO")
  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO")
  set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /SAFESEH:NO")

  # use static libs - to avoid "LNK1104: cannot open file 'libboost_filesystem-vc140-mt-1_59.lib'"
  set(Boost_USE_STATIC_LIBS ON)     
  set(Boost_USE_MULTITHREADED ON)

  # Note: c++11 is implicitly enabled on MSVC >=2013
endif()

# GCC and Clang compiler options
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
  set(CMAKE_CXX_FLAGS "-std=c++11 -fPIC ${CMAKE_CXX_FLAGS}")  

  if(CMAKE_BUILD_TYPE STREQUAL "Release")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -Wno-error")    
  else()
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g2 -Wall -Wextra -Wunused")
  endif()
endif()

#------------------------------------------------------------------------------
#                                 Defines                                        
#------------------------------------------------------------------------------

# define for using TinyXML with Standard Template Library (STL) support enabled
add_definitions(-DTIXML_USE_STL)

if(logging)
  add_definitions(-DLOG_ENABLED)
endif(logging)

if(opengl)  
  add_definitions(-DHAVE_OPENGL)
endif(opengl)

if(cegui)
  add_definitions(-DHAVE_CEGUI)
endif(cegui)

#------------------------------------------------------------------------------
#                                 Display Status                                         
#------------------------------------------------------------------------------

message("")
message("== Building FIFE version ${FIFE_VERSION} using build type '${CMAKE_BUILD_TYPE}'.")
message(STATUS "    Source directory is '${PROJECT_SOURCE_DIR}'.")
message(STATUS "    Build  directory is '${PROJECT_BINARY_DIR}'.")
message(STATUS "    Installation path is '${CMAKE_INSTALL_PREFIX}' (set -DCMAKE_INSTALL_PREFIX=<path> to change).")
message(STATUS "    Dependencies folder: '${PROJECT_SOURCE_DIR}/../fifengine-dependencies'.")
message("")
message(STATUS "    CMake version is '${CMAKE_VERSION}'.")
message(STATUS "    CXX Compiler ID: '${CMAKE_CXX_COMPILER_ID}'.")
message(STATUS "    CXX Compiler Flags: '${CMAKE_CXX_FLAGS}'.")
message("")

#------------------------------------------------------------------------------
#                           Find Dependencies - Windows                                        
#------------------------------------------------------------------------------

# Tell CMake where to search for binaries (dlls), includes and libs on Windows
if(WIN32)
  set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH}

    # help to find dependencies on Appveyor

    "${PROJECT_SOURCE_DIR}/../fifengine-dependencies/build-tools/swig"
    "${PROJECT_SOURCE_DIR}/../fifengine-dependencies/includes/bin"
    "${PROJECT_SOURCE_DIR}/../fifengine-dependencies/includes/include"
    "${PROJECT_SOURCE_DIR}/../fifengine-dependencies/includes/include/SDL2"
    "${PROJECT_SOURCE_DIR}/../fifengine-dependencies/includes/include/AL"
    "${PROJECT_SOURCE_DIR}/../fifengine-dependencies/includes/lib/x86"
    "${PROJECT_SOURCE_DIR}/../fifengine-dependencies/includes/lib"

    # help to find dependencies on your local env (FifeSDK)

    "${PROJECT_SOURCE_DIR}/../swig"
    "${PROJECT_SOURCE_DIR}/../python"
    "${PROJECT_SOURCE_DIR}/../fifengine-dependencies/bin"
    "${PROJECT_SOURCE_DIR}/../fifengine-dependencies/include"
    "${PROJECT_SOURCE_DIR}/../fifengine-dependencies/include/boost"
    "${PROJECT_SOURCE_DIR}/../fifengine-dependencies/lib"
    "${PROJECT_SOURCE_DIR}/../fifengine-dependencies/lib/boost"
    "${PROJECT_SOURCE_DIR}/../fifengine-dependencies/lib/x86"
    "${PROJECT_SOURCE_DIR}/../fifengine-dependencies/include/SDL2"
    "${PROJECT_SOURCE_DIR}/../fifengine-dependencies/include/AL"
    "${PROJECT_SOURCE_DIR}/../fifengine-dependencies/include/lib/x86"
    "${PROJECT_SOURCE_DIR}/../fifengine-dependencies/include/lib"
    
  )
endif(WIN32)

#------------------------------------------------------------------------------
#                                 Source Files                                         
#------------------------------------------------------------------------------

# tell compiler to search in the following folders for include files
include_directories("${PROJECT_BINARY_DIR}")
include_directories("${PROJECT_SOURCE_DIR}/engine/core")
include_directories("${PROJECT_SOURCE_DIR}")

# Core
set(FIFE_CORE_SRC
  ${PROJECT_SOURCE_DIR}/engine/core/audio/actionaudio.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/audio/soundclip.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/audio/soundclipmanager.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/audio/soundemitter.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/audio/soundmanager.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/audio/soundsource.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/audio/effects/soundeffect.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/audio/effects/soundeffectmanager.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/audio/effects/soundfilter.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/controller/engine.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/controller/enginesettings.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/eventchannel/eventmanager.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/eventchannel/joystick/joystick.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/eventchannel/joystick/joystickmanager.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/loaders/native/audio/ogg_loader.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/loaders/native/audio/sounddecoder_ogg.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/loaders/native/input/controllermappingloader.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/loaders/native/map/animationloader.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/loaders/native/map/atlasloader.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/loaders/native/map/maploader.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/loaders/native/map/objectloader.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/loaders/native/map/percentdonelistener.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/loaders/native/video/imageloader.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/loaders/native/video/resourceanimationloader.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/model/model.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/model/metamodel/action.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/model/metamodel/object.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/model/metamodel/timeprovider.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/model/metamodel/grids/cellgrid.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/model/metamodel/grids/hexgrid.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/model/metamodel/grids/squaregrid.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/model/structures/cell.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/model/structures/cellcache.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/model/structures/instance.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/model/structures/instancetree.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/model/structures/layer.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/model/structures/location.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/model/structures/map.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/model/structures/renderernode.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/model/structures/trigger.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/model/structures/triggercontroller.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/pathfinder/route.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/pathfinder/routepather/multilayersearch.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/pathfinder/routepather/routepather.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/pathfinder/routepather/routepathersearch.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/pathfinder/routepather/singlelayersearch.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/savers/native/input/controllermappingsaver.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/savers/native/map/mapsaver.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/util/base/exception.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/util/base/fifeclass.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/util/base/stringutils.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/util/log/logger.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/util/math/angles.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/util/resource/resource.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/util/time/timeevent.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/util/time/timemanager.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/util/time/timer.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/vfs/directoryprovider.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/vfs/fife_boost_filesystem.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/vfs/vfs.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/vfs/vfsdirectory.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/vfs/vfssource.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/vfs/vfssourceprovider.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/vfs/dat/dat1.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/vfs/dat/dat2.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/vfs/dat/lzssdecoder.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/vfs/dat/rawdatadat1.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/vfs/dat/rawdatadat2.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/vfs/raw/rawdata.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/vfs/raw/rawdatafile.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/vfs/raw/rawdatamemsource.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/vfs/raw/rawdatasource.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/vfs/zip/zipfilesource.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/vfs/zip/zipnode.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/vfs/zip/zipprovider.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/vfs/zip/zipsource.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/vfs/zip/ziptree.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/video/animation.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/video/animationmanager.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/video/atlasbook.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/video/color.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/video/cursor.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/video/devicecaps.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/video/image.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/video/imagemanager.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/video/renderbackend.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/video/fonts/fontbase.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/video/fonts/imagefontbase.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/video/fonts/subimagefont.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/video/fonts/textrenderpool.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/video/fonts/truetypefont.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/video/opengl/glimage.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/video/opengl/renderbackendopengl.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/video/sdl/renderbackendsdl.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/video/sdl/sdlblendingfunctions.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/video/sdl/sdlimage.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/view/camera.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/view/layercache.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/view/rendererbase.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/view/renderitem.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/view/visual.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/view/renderers/blockinginforenderer.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/view/renderers/cellrenderer.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/view/renderers/cellselectionrenderer.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/view/renderers/coordinaterenderer.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/view/renderers/floatingtextrenderer.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/view/renderers/genericrenderer.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/view/renderers/gridrenderer.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/view/renderers/instancerenderer.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/view/renderers/lightrenderer.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/view/renderers/offrenderer.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/view/renderers/quadtreerenderer.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/view/renderers/targetrenderer.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/gui/hybrid/hybridguimanager.cpp
)

# CEGUI v0.8.0+
set(FIFE_CEGUI_SRC
  ${PROJECT_SOURCE_DIR}/engine/core/gui/cegui/ceguimanager.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/gui/cegui/base/ceguiinputprocessor.cpp
)

# FIFECHAN
set(FIFE_FCHAN_SRC
  ${PROJECT_SOURCE_DIR}/engine/core/gui/fifechan/fifechanmanager.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/gui/fifechan/base/gui_font.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/gui/fifechan/base/gui_image.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/gui/fifechan/base/gui_imageloader.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/gui/fifechan/base/opengl/opengl_gui_graphics.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/gui/fifechan/base/sdl/sdl_gui_graphics.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/gui/fifechan/console/commandline.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/gui/fifechan/console/console.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/gui/fifechan/util/utf8/utf8stringeditor.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/gui/fifechan/widgets/animationicon.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/gui/fifechan/widgets/clicklabel.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/gui/fifechan/widgets/dockarea.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/gui/fifechan/widgets/panel.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/gui/fifechan/widgets/percentagebar.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/gui/fifechan/widgets/resizablewindow.cpp
)

# LIBROCKET
set(FIFE_LROCKET_SRC
  ${PROJECT_SOURCE_DIR}/engine/core/gui/librocket/librocketmanager.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/gui/librocket/base/librocketinputprocessor.cpp
  ${PROJECT_SOURCE_DIR}/engine/core/gui/librocket/base/librocketrenderinterface.cpp
)

#------------------------------------------------------------------------------
#                         Source Groups for Source Files                                    
#------------------------------------------------------------------------------

source_group("fife.core"                FILES ${FIFE_CORE_SRC})
source_group("fife.core.gui.cegui"      FILES ${FIFE_CEGUI_SRC})
source_group("fife.core.gui.fifechan"   FILES ${FIFE_FCHAN_SRC})
source_group("fife.core.gui.librocket"  FILES ${FIFE_LROCKET_SRC})

#------------------------------------------------------------------------------
#                                 Header Files                                         
#------------------------------------------------------------------------------

# Core
set(FIFE_CORE_HDR
  ${PROJECT_SOURCE_DIR}/engine/core/export.h
  ${PROJECT_SOURCE_DIR}/engine/core/modules.h
  ${PROJECT_SOURCE_DIR}/engine/core/audio/actionaudio.h
  ${PROJECT_SOURCE_DIR}/engine/core/audio/fife_openal.h
  ${PROJECT_SOURCE_DIR}/engine/core/audio/soundclip.h
  ${PROJECT_SOURCE_DIR}/engine/core/audio/soundclipmanager.h
  ${PROJECT_SOURCE_DIR}/engine/core/audio/soundconfig.h
  ${PROJECT_SOURCE_DIR}/engine/core/audio/sounddecoder.h
  ${PROJECT_SOURCE_DIR}/engine/core/audio/soundemitter.h
  ${PROJECT_SOURCE_DIR}/engine/core/audio/soundmanager.h
  ${PROJECT_SOURCE_DIR}/engine/core/audio/soundsource.h
  ${PROJECT_SOURCE_DIR}/engine/core/audio/effects/soundeffect.h
  ${PROJECT_SOURCE_DIR}/engine/core/audio/effects/soundeffectmanager.h
  ${PROJECT_SOURCE_DIR}/engine/core/audio/effects/soundfilter.h
  ${PROJECT_SOURCE_DIR}/engine/core/controller/engine.h
  ${PROJECT_SOURCE_DIR}/engine/core/controller/enginesettings.h
  ${PROJECT_SOURCE_DIR}/engine/core/eventchannel/eventmanager.h
  ${PROJECT_SOURCE_DIR}/engine/core/eventchannel/base/event.h
  ${PROJECT_SOURCE_DIR}/engine/core/eventchannel/base/ilistener.h
  ${PROJECT_SOURCE_DIR}/engine/core/eventchannel/base/inputevent.h
  ${PROJECT_SOURCE_DIR}/engine/core/eventchannel/command/command.h
  ${PROJECT_SOURCE_DIR}/engine/core/eventchannel/command/commandids.h
  ${PROJECT_SOURCE_DIR}/engine/core/eventchannel/command/icommandcontroller.h
  ${PROJECT_SOURCE_DIR}/engine/core/eventchannel/command/icommandlistener.h
  ${PROJECT_SOURCE_DIR}/engine/core/eventchannel/drop/dropevent.h
  ${PROJECT_SOURCE_DIR}/engine/core/eventchannel/drop/idropcontroller.h
  ${PROJECT_SOURCE_DIR}/engine/core/eventchannel/drop/idroplistener.h
  ${PROJECT_SOURCE_DIR}/engine/core/eventchannel/joystick/ijoystickcontroller.h
  ${PROJECT_SOURCE_DIR}/engine/core/eventchannel/joystick/ijoysticklistener.h
  ${PROJECT_SOURCE_DIR}/engine/core/eventchannel/joystick/joystick.h
  ${PROJECT_SOURCE_DIR}/engine/core/eventchannel/joystick/joystickevent.h
  ${PROJECT_SOURCE_DIR}/engine/core/eventchannel/joystick/joystickmanager.h
  ${PROJECT_SOURCE_DIR}/engine/core/eventchannel/key/ikeycontroller.h
  ${PROJECT_SOURCE_DIR}/engine/core/eventchannel/key/ikeyfilter.h
  ${PROJECT_SOURCE_DIR}/engine/core/eventchannel/key/ikeylistener.h
  ${PROJECT_SOURCE_DIR}/engine/core/eventchannel/key/key.h
  ${PROJECT_SOURCE_DIR}/engine/core/eventchannel/key/keyevent.h
  ${PROJECT_SOURCE_DIR}/engine/core/eventchannel/mouse/imousecontroller.h
  ${PROJECT_SOURCE_DIR}/engine/core/eventchannel/mouse/imouselistener.h
  ${PROJECT_SOURCE_DIR}/engine/core/eventchannel/mouse/mouseevent.h
  ${PROJECT_SOURCE_DIR}/engine/core/eventchannel/sdl/isdleventcontroller.h
  ${PROJECT_SOURCE_DIR}/engine/core/eventchannel/sdl/isdleventlistener.h
  ${PROJECT_SOURCE_DIR}/engine/core/eventchannel/source/eventsourcetypes.h
  ${PROJECT_SOURCE_DIR}/engine/core/eventchannel/source/ieventsource.h
  ${PROJECT_SOURCE_DIR}/engine/core/eventchannel/text/itextcontroller.h
  ${PROJECT_SOURCE_DIR}/engine/core/eventchannel/text/itextlistener.h
  ${PROJECT_SOURCE_DIR}/engine/core/eventchannel/text/text.h
  ${PROJECT_SOURCE_DIR}/engine/core/eventchannel/text/textevent.h
  ${PROJECT_SOURCE_DIR}/engine/core/loaders/native/audio/ogg_loader.h
  ${PROJECT_SOURCE_DIR}/engine/core/loaders/native/audio/sounddecoder_ogg.h
  ${PROJECT_SOURCE_DIR}/engine/core/loaders/native/input/controllermappingloader.h
  ${PROJECT_SOURCE_DIR}/engine/core/loaders/native/map/animationloader.h
  ${PROJECT_SOURCE_DIR}/engine/core/loaders/native/map/atlasloader.h
  ${PROJECT_SOURCE_DIR}/engine/core/loaders/native/map/ianimationloader.h
  ${PROJECT_SOURCE_DIR}/engine/core/loaders/native/map/iatlasloader.h
  ${PROJECT_SOURCE_DIR}/engine/core/loaders/native/map/imaploader.h
  ${PROJECT_SOURCE_DIR}/engine/core/loaders/native/map/iobjectloader.h
  ${PROJECT_SOURCE_DIR}/engine/core/loaders/native/map/maploader.h
  ${PROJECT_SOURCE_DIR}/engine/core/loaders/native/map/objectloader.h
  ${PROJECT_SOURCE_DIR}/engine/core/loaders/native/map/percentdonelistener.h
  ${PROJECT_SOURCE_DIR}/engine/core/loaders/native/video/imageloader.h
  ${PROJECT_SOURCE_DIR}/engine/core/loaders/native/video/resourceanimationloader.h
  ${PROJECT_SOURCE_DIR}/engine/core/model/model.h
  ${PROJECT_SOURCE_DIR}/engine/core/model/metamodel/action.h
  ${PROJECT_SOURCE_DIR}/engine/core/model/metamodel/ipather.h
  ${PROJECT_SOURCE_DIR}/engine/core/model/metamodel/ivisual.h
  ${PROJECT_SOURCE_DIR}/engine/core/model/metamodel/modelcoords.h
  ${PROJECT_SOURCE_DIR}/engine/core/model/metamodel/object.h
  ${PROJECT_SOURCE_DIR}/engine/core/model/metamodel/timeprovider.h
  ${PROJECT_SOURCE_DIR}/engine/core/model/metamodel/grids/cellgrid.h
  ${PROJECT_SOURCE_DIR}/engine/core/model/metamodel/grids/hexgrid.h
  ${PROJECT_SOURCE_DIR}/engine/core/model/metamodel/grids/squaregrid.h
  ${PROJECT_SOURCE_DIR}/engine/core/model/structures/cell.h
  ${PROJECT_SOURCE_DIR}/engine/core/model/structures/cellcache.h
  ${PROJECT_SOURCE_DIR}/engine/core/model/structures/instance.h
  ${PROJECT_SOURCE_DIR}/engine/core/model/structures/instancetree.h
  ${PROJECT_SOURCE_DIR}/engine/core/model/structures/layer.h
  ${PROJECT_SOURCE_DIR}/engine/core/model/structures/location.h
  ${PROJECT_SOURCE_DIR}/engine/core/model/structures/map.h
  ${PROJECT_SOURCE_DIR}/engine/core/model/structures/renderernode.h
  ${PROJECT_SOURCE_DIR}/engine/core/model/structures/trigger.h
  ${PROJECT_SOURCE_DIR}/engine/core/model/structures/triggercontroller.h
  ${PROJECT_SOURCE_DIR}/engine/core/pathfinder/route.h
  ${PROJECT_SOURCE_DIR}/engine/core/pathfinder/routepather/multilayersearch.h
  ${PROJECT_SOURCE_DIR}/engine/core/pathfinder/routepather/routepather.h
  ${PROJECT_SOURCE_DIR}/engine/core/pathfinder/routepather/routepathersearch.h
  ${PROJECT_SOURCE_DIR}/engine/core/pathfinder/routepather/singlelayersearch.h
  ${PROJECT_SOURCE_DIR}/engine/core/savers/native/input/controllermappingsaver.h
  ${PROJECT_SOURCE_DIR}/engine/core/savers/native/map/ianimationsaver.h
  ${PROJECT_SOURCE_DIR}/engine/core/savers/native/map/iatlassaver.h
  ${PROJECT_SOURCE_DIR}/engine/core/savers/native/map/imapsaver.h
  ${PROJECT_SOURCE_DIR}/engine/core/savers/native/map/iobjectsaver.h
  ${PROJECT_SOURCE_DIR}/engine/core/savers/native/map/mapsaver.h
  ${PROJECT_SOURCE_DIR}/engine/core/util/base/exception.h
  ${PROJECT_SOURCE_DIR}/engine/core/util/base/fifeclass.h
  ${PROJECT_SOURCE_DIR}/engine/core/util/base/fife_stdint.h
  ${PROJECT_SOURCE_DIR}/engine/core/util/base/sharedptr.h
  ${PROJECT_SOURCE_DIR}/engine/core/util/base/singleton.h
  ${PROJECT_SOURCE_DIR}/engine/core/util/base/stringutils.h
  ${PROJECT_SOURCE_DIR}/engine/core/util/log/logger.h
  ${PROJECT_SOURCE_DIR}/engine/core/util/math/angles.h
  ${PROJECT_SOURCE_DIR}/engine/core/util/math/fife_math.h
  ${PROJECT_SOURCE_DIR}/engine/core/util/math/matrix.h
  ${PROJECT_SOURCE_DIR}/engine/core/util/resource/resource.h
  ${PROJECT_SOURCE_DIR}/engine/core/util/resource/resourcemanager.h
  ${PROJECT_SOURCE_DIR}/engine/core/util/structures/point.h
  ${PROJECT_SOURCE_DIR}/engine/core/util/structures/priorityqueue.h
  ${PROJECT_SOURCE_DIR}/engine/core/util/structures/purge.h
  ${PROJECT_SOURCE_DIR}/engine/core/util/structures/quadtree.h
  ${PROJECT_SOURCE_DIR}/engine/core/util/structures/rect.h
  ${PROJECT_SOURCE_DIR}/engine/core/util/time/timeevent.h
  ${PROJECT_SOURCE_DIR}/engine/core/util/time/timemanager.h
  ${PROJECT_SOURCE_DIR}/engine/core/util/time/timer.h
  ${PROJECT_SOURCE_DIR}/engine/core/util/utf8/utf8.h
  ${PROJECT_SOURCE_DIR}/engine/core/util/utf8/utf8/checked.h
  ${PROJECT_SOURCE_DIR}/engine/core/util/utf8/utf8/core.h
  ${PROJECT_SOURCE_DIR}/engine/core/util/utf8/utf8/unchecked.h
  ${PROJECT_SOURCE_DIR}/engine/core/vfs/directoryprovider.h
  ${PROJECT_SOURCE_DIR}/engine/core/vfs/fife_boost_filesystem.h
  ${PROJECT_SOURCE_DIR}/engine/core/vfs/vfs.h
  ${PROJECT_SOURCE_DIR}/engine/core/vfs/vfsdirectory.h
  ${PROJECT_SOURCE_DIR}/engine/core/vfs/vfssource.h
  ${PROJECT_SOURCE_DIR}/engine/core/vfs/vfssourceprovider.h
  ${PROJECT_SOURCE_DIR}/engine/core/vfs/dat/dat1.h
  ${PROJECT_SOURCE_DIR}/engine/core/vfs/dat/dat2.h
  ${PROJECT_SOURCE_DIR}/engine/core/vfs/dat/lzssdecoder.h
  ${PROJECT_SOURCE_DIR}/engine/core/vfs/dat/rawdatadat1.h
  ${PROJECT_SOURCE_DIR}/engine/core/vfs/dat/rawdatadat2.h
  ${PROJECT_SOURCE_DIR}/engine/core/vfs/raw/rawdata.h
  ${PROJECT_SOURCE_DIR}/engine/core/vfs/raw/rawdatafile.h
  ${PROJECT_SOURCE_DIR}/engine/core/vfs/raw/rawdatamemsource.h
  ${PROJECT_SOURCE_DIR}/engine/core/vfs/raw/rawdatasource.h
  ${PROJECT_SOURCE_DIR}/engine/core/vfs/zip/zipfilesource.h
  ${PROJECT_SOURCE_DIR}/engine/core/vfs/zip/zipnode.h
  ${PROJECT_SOURCE_DIR}/engine/core/vfs/zip/zipprovider.h
  ${PROJECT_SOURCE_DIR}/engine/core/vfs/zip/zipsource.h
  ${PROJECT_SOURCE_DIR}/engine/core/vfs/zip/ziptree.h
  ${PROJECT_SOURCE_DIR}/engine/core/video/animation.h
  ${PROJECT_SOURCE_DIR}/engine/core/video/animationmanager.h
  ${PROJECT_SOURCE_DIR}/engine/core/video/atlasbook.h
  ${PROJECT_SOURCE_DIR}/engine/core/video/color.h
  ${PROJECT_SOURCE_DIR}/engine/core/video/cursor.h
  ${PROJECT_SOURCE_DIR}/engine/core/video/devicecaps.h
  ${PROJECT_SOURCE_DIR}/engine/core/video/image.h
  ${PROJECT_SOURCE_DIR}/engine/core/video/imagemanager.h
  ${PROJECT_SOURCE_DIR}/engine/core/video/renderbackend.h
  ${PROJECT_SOURCE_DIR}/engine/core/video/fonts/fontbase.h
  ${PROJECT_SOURCE_DIR}/engine/core/video/fonts/ifont.h
  ${PROJECT_SOURCE_DIR}/engine/core/video/fonts/imagefontbase.h
  ${PROJECT_SOURCE_DIR}/engine/core/video/fonts/subimagefont.h
  ${PROJECT_SOURCE_DIR}/engine/core/video/fonts/textrenderpool.h
  ${PROJECT_SOURCE_DIR}/engine/core/video/fonts/truetypefont.h
  ${PROJECT_SOURCE_DIR}/engine/core/video/opengl/fife_opengl.h
  ${PROJECT_SOURCE_DIR}/engine/core/video/opengl/glimage.h
  ${PROJECT_SOURCE_DIR}/engine/core/video/opengl/renderbackendopengl.h
  ${PROJECT_SOURCE_DIR}/engine/core/video/sdl/renderbackendsdl.h
  ${PROJECT_SOURCE_DIR}/engine/core/video/sdl/sdlblendingfunctions.h
  ${PROJECT_SOURCE_DIR}/engine/core/video/sdl/sdlimage.h
  ${PROJECT_SOURCE_DIR}/engine/core/view/camera.h
  ${PROJECT_SOURCE_DIR}/engine/core/view/layercache.h
  ${PROJECT_SOURCE_DIR}/engine/core/view/rendererbase.h
  ${PROJECT_SOURCE_DIR}/engine/core/view/renderitem.h
  ${PROJECT_SOURCE_DIR}/engine/core/view/visual.h
  ${PROJECT_SOURCE_DIR}/engine/core/view/renderers/blockinginforenderer.h
  ${PROJECT_SOURCE_DIR}/engine/core/view/renderers/cellrenderer.h
  ${PROJECT_SOURCE_DIR}/engine/core/view/renderers/cellselectionrenderer.h
  ${PROJECT_SOURCE_DIR}/engine/core/view/renderers/coordinaterenderer.h
  ${PROJECT_SOURCE_DIR}/engine/core/view/renderers/floatingtextrenderer.h
  ${PROJECT_SOURCE_DIR}/engine/core/view/renderers/genericrenderer.h
  ${PROJECT_SOURCE_DIR}/engine/core/view/renderers/gridrenderer.h
  ${PROJECT_SOURCE_DIR}/engine/core/view/renderers/instancerenderer.h
  ${PROJECT_SOURCE_DIR}/engine/core/view/renderers/lightrenderer.h
  ${PROJECT_SOURCE_DIR}/engine/core/view/renderers/offrenderer.h
  ${PROJECT_SOURCE_DIR}/engine/core/view/renderers/quadtreerenderer.h
  ${PROJECT_SOURCE_DIR}/engine/core/view/renderers/targetrenderer.h
  ${PROJECT_SOURCE_DIR}/engine/core/gui/guimanager.h
  ${PROJECT_SOURCE_DIR}/engine/core/gui/hybrid/hybridguimanager.h
)

# CEGUI
set(FIFE_CEGUI_HDR
  ${PROJECT_SOURCE_DIR}/engine/core/gui/cegui/ceguimanager.h
  ${PROJECT_SOURCE_DIR}/engine/core/gui/cegui/base/ceguiinputprocessor.h
)

# Fifechan
set(FIFE_FCHAN_HDR
  ${PROJECT_SOURCE_DIR}/engine/core/gui/fifechan/fifechanmanager.h
  ${PROJECT_SOURCE_DIR}/engine/core/gui/fifechan/base/gui_font.h
  ${PROJECT_SOURCE_DIR}/engine/core/gui/fifechan/base/gui_image.h
  ${PROJECT_SOURCE_DIR}/engine/core/gui/fifechan/base/gui_imageloader.h
  ${PROJECT_SOURCE_DIR}/engine/core/gui/fifechan/base/opengl/opengl_gui_graphics.h
  ${PROJECT_SOURCE_DIR}/engine/core/gui/fifechan/base/sdl/sdl_gui_graphics.h
  ${PROJECT_SOURCE_DIR}/engine/core/gui/fifechan/console/commandline.h
  ${PROJECT_SOURCE_DIR}/engine/core/gui/fifechan/console/console.h
  ${PROJECT_SOURCE_DIR}/engine/core/gui/fifechan/util/utf8/utf8stringeditor.h
  ${PROJECT_SOURCE_DIR}/engine/core/gui/fifechan/widgets/animationicon.h
  ${PROJECT_SOURCE_DIR}/engine/core/gui/fifechan/widgets/clicklabel.h
  ${PROJECT_SOURCE_DIR}/engine/core/gui/fifechan/widgets/dockarea.h
  ${PROJECT_SOURCE_DIR}/engine/core/gui/fifechan/widgets/panel.h
  ${PROJECT_SOURCE_DIR}/engine/core/gui/fifechan/widgets/percentagebar.h
  ${PROJECT_SOURCE_DIR}/engine/core/gui/fifechan/widgets/resizablewindow.h
)

# Librocket
set(FIFE_LROCKET_HDR
  ${PROJECT_SOURCE_DIR}/engine/core/gui/librocket/librocketmanager.h
  ${PROJECT_SOURCE_DIR}/engine/core/gui/librocket/base/librocketinputprocessor.h
  ${PROJECT_SOURCE_DIR}/engine/core/gui/librocket/base/librocketrenderinterface.h
)

#------------------------------------------------------------------------------
#                      Source Groups for Header Files                                    
#------------------------------------------------------------------------------

source_group("fife.core"                FILES ${FIFE_CORE_HDR})
source_group("fife.core.gui.cegui"      FILES ${FIFE_CEGUI_HDR})
source_group("fife.core.gui.fifechan"   FILES ${FIFE_FCHAN_HDR})
source_group("fife.core.gui.librocket"  FILES ${FIFE_LROCKET_HDR})

add_custom_target(fife.headers SOURCES ${FIFE_CORE_HDR} ${FIFE_CEGUI_HDR} ${FIFE_FCHAN_HDR} ${FIFE_LROCKET_HDR})

#------------------------------------------------------------------------------
#                                 SWIG Files                                         
#------------------------------------------------------------------------------

# Core
set(FIFE_CORE_SWIG
  version.i
  audio/effects/soundeffect.i
  audio/effects/soundfilter.i
  audio/soundclip.i
  audio/soundclipmanager.i
  audio/soundemitter.i
  audio/soundmanager.i
  controller/engine.i
  eventchannel/eventchannel.i
  loaders/native/map/ianimationloader.i
  loaders/native/map/iatlasloader.i
  loaders/native/map/imaploader.i
  loaders/native/map/iobjectloader.i
  loaders/native/map/maploader.i
  loaders/native/map/percentdonelistener.i
  model/metamodel/action.i
  model/metamodel/ipather.i
  model/metamodel/ivisual.i
  model/metamodel/modelcoords.i
  model/metamodel/object.i
  model/metamodel/timeprovider.i
  model/metamodel/grids/cellgrids.i
  model/structures/cell.i
  model/structures/cellcache.i
  model/structures/instance.i
  model/structures/layer.i
  model/structures/location.i
  model/structures/map.i
  model/structures/renderernode.i
  model/structures/trigger.i
  model/model.i
  pathfinder/route.i
  pathfinder/routepather/routepather.i
  savers/native/map/ianimationsaver.i
  savers/native/map/iatlassaver.i
  savers/native/map/imapsaver.i
  savers/native/map/iobjectsaver.i
  savers/native/map/mapsaver.i
  util/base/utilbase.i
  util/log/logger.i
  util/math/math.i
  util/resource/resource.i
  util/structures/utilstructures.i
  util/time/timeevent.i
  util/time/timemanager.i
  vfs/vfs.i
  vfs/raw/rawdata.i
  video/video.i
  video/fonts/fonts.i
  view/camera.i
  view/rendererbase.i
  view/visual.i
  view/renderers/blockinginforenderer.i
  view/renderers/cellrenderer.i
  view/renderers/cellselectionrenderer.i
  view/renderers/coordinaterenderer.i
  view/renderers/floatingtextrenderer.i
  view/renderers/genericrenderer.i
  view/renderers/gridrenderer.i
  view/renderers/instancerenderer.i
  view/renderers/lightrenderer.i
  view/renderers/offrenderer.i
  view/renderers/targetrenderer.i
  gui/guimanager.i
  gui/hybrid/hybridguimanager.i
)

# CEGUI
set(FIFE_CEGUI_SWIG
  gui/cegui/ceguimanager.i
)

# FIFECHAN
set(FIFE_FCHAN_SWIG_LIB
  gui/fifechan/lib/fifechanlistener.i
  gui/fifechan/lib/widgets.i
)

set(FIFE_FCHAN_SWIG
  gui/fifechan/base/gui_font.i
  gui/fifechan/base/gui_image.i
  gui/fifechan/console/console.i
  gui/fifechan/fifechanmanager.i
  gui/fifechan/widgets/widgets.i
)

# LIBROCKET
set(FIFE_LROCKET_SWIG
  gui/librocket/librocketmanager.i
)

#------------------------------------------------------------------------------
#                      Source Groups for SWIG Files                                    
#------------------------------------------------------------------------------

source_group("fife.core"                    FILES ${FIFE_CORE_SWIG})
source_group("fife.core.gui.cegui"          FILES ${FIFE_CEGUI_SWIG})
source_group("fife.core.gui.fifechan.lib"   FILES ${FIFE_FCHAN_SWIG_LIB})
source_group("fife.core.gui.fifechan"       FILES ${FIFE_FCHAN_SWIG})
source_group("fife.core.gui.librocket"      FILES ${FIFE_LROCKET_SWIG})

# TODO some files for this source_group are not found
#add_custom_target(fife.swig SOURCES ${FIFE_CORE_SWIG} ${FIFE_CEGUI_SWIG} ${FIFE_FCHAN_SWIG_LIB} ${FIFE_FCHAN_SWIG} ${FIFE_LROCKET_SWIG})

#------------------------------------------------------------------------------
#                                 SWIG WRAPPER Files                                         
#------------------------------------------------------------------------------

# SWIG WRAPPERS FOR PYTHON
SET(FIFE_SWIGWRAPPERS_PYTHON
  ${PROJECT_SOURCE_DIR}/engine/swigwrappers/python/extensions.i.templ
  ${PROJECT_SOURCE_DIR}/engine/swigwrappers/python/fife.i.templ
  ${PROJECT_SOURCE_DIR}/engine/swigwrappers/python/fife.i.templ.cm
  ${PROJECT_SOURCE_DIR}/engine/swigwrappers/python/fifechan.i.templ
  ${PROJECT_SOURCE_DIR}/engine/swigwrappers/python/fifechan.i.templ.cm
  ${PROJECT_SOURCE_DIR}/engine/swigwrappers/python/librocket.i.templ
)

#------------------------------------------------------------------------------
#                      Source Groups for SWIG WRAPPER Files                                    
#------------------------------------------------------------------------------

source_group("fife.swigwrappers.python" FILES ${FIFE_SWIGWRAPPERS_PYTHON})

add_custom_target(fife.swig-wrappers SOURCES ${FIFE_SWIGWRAPPERS_PYTHON})

#------------------------------------------------------------------------------
#                                 Find Packages                                         
#------------------------------------------------------------------------------

find_package(SDL2 REQUIRED)
find_package(SDL2_image REQUIRED)
find_package(SDL2_ttf REQUIRED)
find_package(Boost 1.33.1 COMPONENTS system filesystem)
find_package(PNG REQUIRED)
find_package(OpenALSoft REQUIRED)
find_package(TinyXML REQUIRED)
find_package(OGG REQUIRED)
find_package(VORBIS REQUIRED)

if(opengl)
  find_package(OpenGL REQUIRED)
  include_directories(${OPENGL_INCLUDE_DIR})  
  find_package(GLEW REQUIRED)
  include_directories(${GLEW_INCLUDE_DIR})  
endif(opengl)

if(cegui)
  find_package(CEGUI REQUIRED)

  if(NOT CEGUI_OpenGLRenderer_FOUND)
    message(FATAL_ERROR "FIFE needs CEGUI with the OpenGLRenderer enabled.")
  endif(NOT CEGUI_OpenGLRenderer_FOUND)

  if(NOT opengl)
    message(FATAL_ERROR "OpenGL cannot be disabled, when CEGUI is enabled.")
  endif(NOT opengl)

  include_directories(${CEGUI_INCLUDE_DIR})

  message("Using CEGUI v0.8+")
  set(CEGUI TRUE)
  set(FIFE_CORE_SRC ${FIFE_CORE_SRC} ${FIFE_CEGUI_SRC})
endif(cegui)

if(build-python)
  # Setting up SWIG files
  set(SWIG_MODULE_fife_EXTRA_DEPS)
  set(CMAKE_SWIG_IMPORTS "")
  set(CMAKE_SWIG_INCLUSIONS "")
  set(CMAKE_SWIG_IMPORTS_FCHAN "")
  set(CMAKE_SWIG_INCLUSIONS_FCHAN "")

  # Find python library and add include path for python headers
  find_package (PythonInterp)
  set(PYTHON_LIBRARY "PYTHON_LIBRARY-NOTFOUND")
  set(PYTHON_INCLUDE_DIR "PYTHON_INCLUDE_DIR-NOTFOUND")
  find_package (PythonLibs)
  
  foreach(filename ${FIFE_CORE_SWIG})
    list(APPEND SWIG_MODULE_fife_EXTRA_DEPS "${PROJECT_SOURCE_DIR}/engine/core/${filename}")
    set(CMAKE_SWIG_INCLUSIONS "${CMAKE_SWIG_INCLUSIONS}%include ${filename}\n")
  endforeach(filename ${FIFE_CORE_SWIG})
endif(build-python)

if(fifechan)

  find_package(FifeChan COMPONENTS sdl REQUIRED)
  if(opengl)
    find_package(FifeChan COMPONENTS opengl REQUIRED)
  endif(opengl)
 
  if(build-python)    
    set(SWIG_MODULE_fifechan_EXTRA_DEPS)
    foreach(filename ${FIFE_FCHAN_SWIG_LIB})
      list(APPEND SWIG_MODULE_fife_EXTRA_DEPS "${PROJECT_SOURCE_DIR}/engine/core/${filename}")
      list(APPEND SWIG_MODULE_fifechan_EXTRA_DEPS "${PROJECT_SOURCE_DIR}/engine/core/${filename}")
      set(CMAKE_SWIG_INCLUSIONS_FCHAN "${CMAKE_SWIG_INCLUSIONS_FCHAN}%include ${filename}\n")
    endforeach(filename ${FIFE_FCHAN_SWIG_LIB})
    
    foreach(filename ${FIFE_FCHAN_SWIG})
      list(APPEND SWIG_MODULE_fife_EXTRA_DEPS "${PROJECT_SOURCE_DIR}/engine/core/${filename}")
      list(APPEND SWIG_MODULE_fifechan_EXTRA_DEPS "${PROJECT_SOURCE_DIR}/engine/core/${filename}")
      set(CMAKE_SWIG_INCLUSIONS "${CMAKE_SWIG_INCLUSIONS}%include ${filename}\n")
    endforeach(filename ${FIFE_FCHAN_SWIG})
    if (PYTHON_VERSION_MAJOR LESS 3)
      set(CMAKE_SWIG_IMPORTS "${CMAKE_SWIG_IMPORTS}%import ${PROJECT_BINARY_DIR}/fifechan.i")
    else (PYTHON_VERSION_MAJOR LESS 3)
      set(CMAKE_SWIG_IMPORTS "${CMAKE_SWIG_IMPORTS}%import(module=\"fife.fifechan\") ${PROJECT_BINARY_DIR}/fifechan.i")
    endif (PYTHON_VERSION_MAJOR LESS 3)


    configure_file(
      "${PROJECT_SOURCE_DIR}/engine/swigwrappers/python/fifechan.i.templ.cm"
      "${PROJECT_BINARY_DIR}/fifechan.i"
    )
  endif(build-python)

  include_directories(${FIFECHAN_INCLUDE_DIR})

endif(fifechan)

if(cegui)  
  if(build-python)
    foreach(filename ${FIFE_CEGUI_SWIG})
      list(APPEND SWIG_MODULE_fife_EXTRA_DEPS "${PROJECT_SOURCE_DIR}/engine/core/${filename}")
      set(CMAKE_SWIG_INCLUSIONS "${CMAKE_SWIG_INCLUSIONS}%include ${filename}\n")
    endforeach(filename ${FIFE_CEGUI_SWIG})    
   endif(build-python)
endif(cegui)

if(build-python)

  configure_file(
    "${PROJECT_SOURCE_DIR}/engine/swigwrappers/python/fife.i.templ.cm"
    "${PROJECT_BINARY_DIR}/fife.i"
  )

  # find SWIG 
  find_package(SWIG REQUIRED)

  # protect user from working with Swig v3.0.8, which is broken
  if("${SWIG_VERSION}" VERSION_EQUAL "3.0.8")
    message(FATAL_ERROR "You are using SWIG v3.0.8.\n 
                         This version doesn't work with fifengine.\n 
                         Please upgrade SWIG.")
  endif()

  # include the use swig file
  include(${SWIG_USE_FILE})

endif(build-python)

include_directories(${SDL2_INCLUDE_DIR}
                    ${SDL2_IMAGE_INCLUDE_DIR}
                    ${SDL2_TTF_INCLUDE_DIR})
include_directories(${Boost_INCLUDE_DIRS})
include_directories(${PNG_INCLUDE_DIRS})
include_directories(${OPENALSOFT_INCLUDE_DIR})
include_directories(${OGG_INCLUDE_DIRS})
include_directories(${VORBIS_INCLUDE_DIRS})
include_directories(${TinyXML_INCLUDE_DIRS})

add_definitions(${PNG_DEFINITIONS})
add_definitions(${Boost_LIB_DIAGNOSTIC_DEFINITIONS})

#------------------------------------------------------------------------------
#                  Build fifengine as a Python extension module                                       
#------------------------------------------------------------------------------

if(build-python)
  # Find python library and add include path for python headers
  find_package (PythonInterp)
  set(PYTHON_LIBRARY "PYTHON_LIBRARY-NOTFOUND")
  set(PYTHON_INCLUDE_DIR "PYTHON_INCLUDE_DIR-NOTFOUND")

  find_package(PythonLibs ${PYTHON_VERSION_STRING} EXACT)
  include_directories(${PYTHON_INCLUDE_PATH})

  set(CMAKE_SWIG_FLAGS -modern -fastdispatch -dirvtable -nosafecstrings -noproxydel -fastproxy -fastinit -fastunpack -fastquery -modernargs -nobuildnone -keyword -w511 -w473 -w404 -w314)

  set_source_files_properties("${PROJECT_BINARY_DIR}/fife.i" PROPERTIES CPLUSPLUS ON)
  set(FIFE_SOURCES ${FIFE_CORE_SRC})
  if(fifechan)
    set(FIFE_SOURCES ${FIFE_SOURCES} ${FIFE_FCHAN_SRC})
  endif(fifechan)
  # CMake 3.8: swig_add_module is deprecated, use swig_add_library instead.
  if(${CMAKE_VERSION} VERSION_LESS 3.8)
    swig_add_module(fife python "${PROJECT_BINARY_DIR}/fife.i" ${FIFE_SOURCES})
  else(${CMAKE_VERSION} VERSION_LESS 3.8)
    swig_add_library(fife LANGUAGE python SOURCES "${PROJECT_BINARY_DIR}/fife.i" ${FIFE_SOURCES})
  endif(${CMAKE_VERSION} VERSION_LESS 3.8)

  if(APPLE)
    set(APPLE_DYNAMIC_LOOKUP_FLAG "-undefined dynamic_lookup")
    swig_link_libraries(fife ${APPLE_DYNAMIC_LOOKUP_FLAG} )
  else(APPLE)
    swig_link_libraries(fife ${PYTHON_LIBRARIES})
  endif(APPLE)
  swig_link_libraries(fife ${SDL2_LIBRARY}
                           ${SDL2_IMAGE_LIBRARIES}
                           ${SDL2_TTF_LIBRARIES}
                           ${OPENALSOFT_LIBRARY})
  swig_link_libraries(fife ${Boost_LIBRARIES})
  swig_link_libraries(fife ${PNG_LIBRARIES})
  swig_link_libraries(fife ${VORBISFILE_LIBRARY})
  swig_link_libraries(fife ${VORBIS_LIBRARY})
  swig_link_libraries(fife ${OGG_LIBRARIES})
  swig_link_libraries(fife ${TinyXML_LIBRARIES})

  if(opengl)
    swig_link_libraries(fife ${OPENGL_gl_LIBRARY})
    swig_link_libraries(fife ${GLEW_LIBRARY})    
  endif(opengl)

  if(fifechan)
    set_source_files_properties("${PROJECT_BINARY_DIR}/fifechan.i" PROPERTIES CPLUSPLUS ON)

    # CMake 3.8: swig_add_module is deprecated, use swig_add_library instead.
    if(${CMAKE_VERSION} VERSION_LESS 3.8)
      swig_add_module(fifechan python "${PROJECT_BINARY_DIR}/fifechan.i")
    else(${CMAKE_VERSION} VERSION_LESS 3.8)
      swig_add_library(fifechan LANGUAGE python SOURCES "${PROJECT_BINARY_DIR}/fifechan.i")
    endif(${CMAKE_VERSION} VERSION_LESS 3.8)

    if(APPLE)
      swig_link_libraries(fifechan ${APPLE_DYNAMIC_LOOKUP_FLAG})
    else(APPLE)
      swig_link_libraries(fifechan ${PYTHON_LIBRARIES})
    endif(APPLE)
    swig_link_libraries(fifechan ${FIFECHAN_LIBRARIES})
    swig_link_libraries(fife ${FIFECHAN_LIBRARIES})
  endif(fifechan)

  if(cegui)
    swig_link_libraries(fife ${CEGUI_LIBRARIES})
    swig_link_libraries(fife ${CEGUI_OpenGLRenderer_LIBRARIES})
  endif(cegui)

   #---------------------------------------------------------------------------------
   # Install Python package locally, e.g. into "C:\Python27\Lib\site-packages\fife" #---------------------------------------------------------------------------------
 
   if(NOT DEFINED PYTHON_SITE_PACKAGES)  
    # get path to your local python site packages folder 
    execute_process(
      COMMAND  ${PYTHON_EXECUTABLE} -c "import sys; from distutils.sysconfig import get_python_lib; sys.stdout.write(get_python_lib(True))"
      OUTPUT_VARIABLE PYTHON_SITE_PACKAGES
    )
    # Slash-Fix: Cmake would create a warning, when using the variable in FILES or DIRECTORY without changing it.
    file(TO_CMAKE_PATH ${PYTHON_SITE_PACKAGES} PYTHON_SITE_PACKAGES)
  endif(NOT DEFINED PYTHON_SITE_PACKAGES)

  message(STATUS "    Python install directory is '${PYTHON_SITE_PACKAGES}/fife'.")

  # install pythonized fife
  install(TARGETS     _fife															DESTINATION ${PYTHON_SITE_PACKAGES}/fife)
  install(FILES       ${PROJECT_BINARY_DIR}/fife.py									DESTINATION ${PYTHON_SITE_PACKAGES}/fife)
  install(FILES       ${CMAKE_SOURCE_DIR}/engine/python/fife/__init__.py			DESTINATION ${PYTHON_SITE_PACKAGES}/fife)
  
  # copy all files/folders from the extension folder
  # but exclude extension folders of the optional dependencies: cegui, librocket, pychan
  install(DIRECTORY   ${CMAKE_SOURCE_DIR}/engine/python/fife/extensions/			DESTINATION ${PYTHON_SITE_PACKAGES}/fife/extensions
	PATTERN "extensions/cegui"	   EXCLUDE
	PATTERN "extensions/librocket" EXCLUDE
	PATTERN "extensions/pychan"    EXCLUDE
    PATTERN "extensions/*"	
  )  

  if(cegui) 
    # install fife's extension for cegui   
	install(DIRECTORY ${CMAKE_SOURCE_DIR}/engine/python/fife/extensions/cegui/		DESTINATION ${PYTHON_SITE_PACKAGES}/fife/extensions/cegui)
  endif(cegui)

  if(librocket)
    # install fife's extension for librocket
	install(DIRECTORY ${CMAKE_SOURCE_DIR}/engine/python/fife/extensions/librocket/	DESTINATION ${PYTHON_SITE_PACKAGES}/fife/extensions/librocket)
  endif(librocket)

  if(fifechan)
    # install pychan - fife's extension for fifechan 
	install(DIRECTORY ${CMAKE_SOURCE_DIR}/engine/python/fife/extensions/pychan/		DESTINATION ${PYTHON_SITE_PACKAGES}/fife/extensions/pychan)

    # install pythonized fifechan
    install(TARGETS   _fifechan                           DESTINATION ${PYTHON_SITE_PACKAGES}/fife)
    install(FILES     ${PROJECT_BINARY_DIR}/fifechan.py   DESTINATION ${PYTHON_SITE_PACKAGES}/fife)
  endif(fifechan)
endif(build-python)

#------------------------------------------------------------------------------
#                       Build fifengine as a library                                        
#------------------------------------------------------------------------------

if(build-library)
  set(FIFE_SOURCES ${FIFE_CORE_SRC})
  if(fifechan)
    set(FIFE_SOURCES ${FIFE_SOURCES} ${FIFE_FCHAN_SRC})
  endif(fifechan)

  add_library(fife ${FIFE_SOURCES})
  set_target_properties(fife PROPERTIES SOVERSION ${FIFE_VERSION})

  target_link_libraries(fife ${SDL2_LIBRARY}
                             ${SDL2_IMAGE_LIBRARIES}
                             ${SDL2_TTF_LIBRARIES}
                             ${OPENALSOFT_LIBRARY})
  target_link_libraries(fife ${Boost_LIBRARIES})
  target_link_libraries(fife ${PNG_LIBRARIES})
  target_link_libraries(fife ${VORBISFILE_LIBRARY})
  target_link_libraries(fife ${VORBIS_LIBRARY})
  target_link_libraries(fife ${OGG_LIBRARIES})
  target_link_libraries(fife ${TinyXML_LIBRARIES})
  if(opengl)
    target_link_libraries(fife ${OPENGL_gl_LIBRARY})
    target_link_libraries(fife ${GLEW_LIBRARY})   
  endif(opengl)  
  if(fifechan)
    target_link_libraries(fife ${FIFECHAN_LIBRARIES})
  endif(fifechan)
  if(cegui)
    target_link_libraries(fife ${CEGUI_LIBRARIES})
    target_link_libraries(fife ${CEGUI_OpenGLRenderer_LIBRARIES})
  endif(cegui)
  
  # include support for GNU / multiarch path names
  # https://www.gnu.org/prep/standards/html_node/Directory-Variables.html
  include(GNUInstallDirs)
  
  install(TARGETS fife DESTINATION ${CMAKE_INSTALL_LIBDIR})
  install(FILES ${PROJECT_SOURCE_DIR}/engine/core/version.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/fife/core/)
  
  MACRO(INSTALL_HEADERS_WITH_DIRECTORY HEADER_LIST)
  
      FOREACH(HEADER ${${HEADER_LIST}})
          get_filename_component(DIR ${HEADER} DIRECTORY)
          string(REPLACE ${CMAKE_CURRENT_LIST_DIR}/engine "" DIR ${DIR})
          INSTALL(FILES ${HEADER} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/fife/${DIR})
      ENDFOREACH(HEADER)

  ENDMACRO(INSTALL_HEADERS_WITH_DIRECTORY)
  
  INSTALL_HEADERS_WITH_DIRECTORY(FIFE_CORE_HDR)
  if(fifechan)
    INSTALL_HEADERS_WITH_DIRECTORY(FIFE_FCHAN_HDR)
  endif(fifechan)
  if(cegui)
    INSTALL_HEADERS_WITH_DIRECTORY(FIFE_CEGUI_HDR)
  endif(cegui)
  if(librocket)
    INSTALL_HEADERS_WITH_DIRECTORY(FIFE_LROCKET_HDR)
  endif(librocket)
endif(build-library)