-
Notifications
You must be signed in to change notification settings - Fork 933
/
CMakeLists.txt
720 lines (626 loc) · 18.8 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
project (Components)
if(APPLE)
set(BUNDLE_RESOURCES_DIR "${APP_BUNDLE_DIR}/Contents/Resources")
set(OPENMW_RESOURCES_ROOT ${BUNDLE_RESOURCES_DIR})
endif(APPLE)
# Version file
set (VERSION_RESOURCE_FILE_IN "${OpenMW_SOURCE_DIR}/files/version.in")
set (VERSION_RESOURCE_FILE_RELATIVE "resources/version")
set (VERSION_CPP_FILE "components/version/version.cpp")
if (GIT_CHECKOUT)
get_generator_is_multi_config(multi_config)
add_custom_target (get-version
BYPRODUCTS "${OpenMW_BINARY_DIR}/${VERSION_CPP_FILE}"
DEPENDS "${OpenMW_SOURCE_DIR}/${VERSION_CPP_FILE}.in"
COMMAND ${CMAKE_COMMAND}
-DGIT_EXECUTABLE=${GIT_EXECUTABLE}
-DOpenMW_SOURCE_DIR=${OpenMW_SOURCE_DIR}
-DOpenMW_BINARY_DIR=${OpenMW_BINARY_DIR}
-DVERSION_RESOURCE_FILE_IN=${VERSION_RESOURCE_FILE_IN}
-DVERSION_RESOURCE_FILE_RELATIVE=${VERSION_RESOURCE_FILE_RELATIVE}
-DVERSION_CPP_FILE_IN=${OpenMW_SOURCE_DIR}/${VERSION_CPP_FILE}.in
-DVERSION_CPP_FILE_OUT=${OpenMW_BINARY_DIR}/${VERSION_CPP_FILE}.out
-DOPENMW_VERSION_MAJOR=${OPENMW_VERSION_MAJOR}
-DOPENMW_VERSION_MINOR=${OPENMW_VERSION_MINOR}
-DOPENMW_VERSION_RELEASE=${OPENMW_VERSION_RELEASE}
-DOPENMW_LUA_API_REVISION=${OPENMW_LUA_API_REVISION}
-DOPENMW_POSTPROCESSING_API_REVISION=${OPENMW_POSTPROCESSING_API_REVISION}
-DOPENMW_VERSION=${OPENMW_VERSION}
-DOPENMW_DOC_BASEURL=${OPENMW_DOC_BASEURL}
-DMACROSFILE=${CMAKE_SOURCE_DIR}/cmake/OpenMWMacros.cmake
"-DCMAKE_CONFIGURATION_TYPES=${CMAKE_CONFIGURATION_TYPES}"
-Dgenerator_is_multi_config_var=${multi_config}
-P ${CMAKE_CURRENT_SOURCE_DIR}/../cmake/GitVersion.cmake
COMMAND ${CMAKE_COMMAND}
-E copy_if_different ${OpenMW_BINARY_DIR}/${VERSION_CPP_FILE}.out ${OpenMW_BINARY_DIR}/${VERSION_CPP_FILE}
VERBATIM)
else (GIT_CHECKOUT)
configure_resource_file(${VERSION_RESOURCE_FILE_IN} ${OpenMW_BINARY_DIR} ${VERSION_RESOURCE_FILE_RELATIVE})
configure_file("${OpenMW_SOURCE_DIR}/${VERSION_CPP_FILE}.in" "${OpenMW_BINARY_DIR}/${VERSION_CPP_FILE}")
endif (GIT_CHECKOUT)
list (APPEND COMPONENT_FILES "${OpenMW_BINARY_DIR}/${VERSION_CPP_FILE}")
# OSG plugin checker
# Helpfully, OSG doesn't export this to its CMake config as it doesn't have one
list(TRANSFORM USED_OSG_PLUGINS REPLACE "^osgdb_" "" OUTPUT_VARIABLE USED_OSG_PLUGIN_NAMES)
list(TRANSFORM USED_OSG_PLUGIN_NAMES PREPEND "\"" OUTPUT_VARIABLE USED_OSG_PLUGIN_NAMES_FORMATTED)
list(TRANSFORM USED_OSG_PLUGIN_NAMES_FORMATTED APPEND "\"")
list(JOIN USED_OSG_PLUGIN_NAMES_FORMATTED ", " USED_OSG_PLUGIN_NAMES_FORMATTED)
set(OSG_PLUGIN_CHECKER_CPP_FILE "components/misc/osgpluginchecker.cpp")
configure_file("${OpenMW_SOURCE_DIR}/${OSG_PLUGIN_CHECKER_CPP_FILE}.in" "${OpenMW_BINARY_DIR}/${OSG_PLUGIN_CHECKER_CPP_FILE}")
list(APPEND COMPONENT_FILES "${OpenMW_BINARY_DIR}/${OSG_PLUGIN_CHECKER_CPP_FILE}")
# source files
add_component_dir (lua
luastate scriptscontainer asyncpackage utilpackage serialization configuration l10n storage utf8
shapes/box inputactions yamlloader
)
add_component_dir (l10n
messagebundles manager
)
add_component_dir (settings
categories
categories/camera
categories/cells
categories/fog
categories/game
categories/general
categories/groundcover
categories/gui
categories/hud
categories/input
categories/lua
categories/map
categories/models
categories/navigator
categories/physics
categories/postprocessing
categories/saves
categories/shaders
categories/shadows
categories/sound
categories/stereo
categories/stereoview
categories/terrain
categories/video
categories/water
categories/windows
gyroscopeaxis
hrtfmode
navmeshrendermode
parser
sanitizer
sanitizerimpl
settings
settingvalue
shadermanager
values
windowmode
)
add_component_dir (bgsm
stream file
)
add_component_dir (bsa
bsa_file compressedbsafile ba2gnrlfile ba2dx10file ba2file memorystream
)
add_component_dir (bullethelpers
collisionobject
heightfield
operators
processtrianglecallback
transformboundingbox
)
add_component_dir (vfs
manager archive bsaarchive filesystemarchive pathutil registerarchives
)
add_component_dir (resource
scenemanager keyframemanager imagemanager animblendrulesmanager bulletshapemanager bulletshape niffilemanager objectcache multiobjectcache resourcesystem
resourcemanager stats animation foreachbulletobject errormarker cachestats bgsmfilemanager
)
add_component_dir (shader
shadermanager shadervisitor removedalphafunc
)
add_component_dir (sceneutil
clone attach visitor util statesetupdater controller skeleton riggeometry morphgeometry lightcontroller
lightmanager lightutil positionattitudetransform workqueue pathgridutil waterutil writescene serialize optimizer
detourdebugdraw navmesh agentpath animblendrules shadow mwshadowtechnique recastmesh shadowsbin osgacontroller rtt
screencapture depth color riggeometryosgaextension extradata unrefqueue lightcommon lightingmethod clearcolor
cullsafeboundsvisitor keyframe nodecallback textkeymap glextensions
)
add_component_dir (nif
base controller data effect extra niffile nifkey nifstream niftypes node parent particle physics property record recordptr texture
)
add_component_dir (nifosg
nifloader controller particle matrixtransform fog
)
add_component_dir (nifbullet
bulletnifloader
)
add_component_dir (to_utf8
tables_gen
to_utf8
)
add_component_dir(esm attr common defs esmcommon records util luascripts format refid esmbridge esmterrain
formid
fourcc
stringrefid
generatedrefid
indexrefid
serializerefid
esm3exteriorcellrefid
quaternion
vector3
exteriorcelllocation
)
add_component_dir(fx pass technique lexer lexer_types parse_constants widgets stateupdater)
add_component_dir(std140 ubo)
add_component_dir (esm3
esmreader esmwriter loadacti loadalch loadappa loadarmo loadbody loadbook loadbsgn loadcell
loadclas loadclot loadcont loadcrea loaddial loaddoor loadench loadfact loadglob loadgmst
loadinfo loadingr loadland loadlevlist loadligh loadlock loadprob loadrepa loadltex loadmgef loadmisc
loadnpc loadpgrd loadrace loadregn loadscpt loadskil loadsndg loadsoun loadspel loadsscr loadstat
loadweap aipackage effectlist spelllist variant variantimp loadtes3 cellref filter
savedgame journalentry queststate locals globalscript player objectstate cellid cellstate globalmap
inventorystate containerstate npcstate creaturestate dialoguestate statstate npcstats creaturestats
weatherstate quickkeys fogstate spellstate activespells creaturelevliststate doorstate projectilestate debugprofile
aisequence magiceffects custommarkerstate stolenitems transport animationstate controlsstate mappings readerscache
infoorder timestamp formatversion landrecorddata selectiongroup dialoguecondition
refnum
)
add_component_dir (esmterrain
gridsampling
storage
)
add_component_dir (esm4
actor
cellgrid
common
dialogue
effect
grid
grouptype
inventory
lighting
loadachr
loadacti
loadalch
loadaloc
loadammo
loadanio
loadappa
loadarma
loadarmo
loadaspc
loadbook
loadbptd
loadcell
loadclas
loadclfm
loadclot
loadcont
loadcrea
loaddial
loaddobj
loaddoor
loadeyes
loadflor
loadflst
loadfurn
loadglob
loadgmst
loadgras
loadgrup
loadhair
loadhdpt
loadidle
loadidlm
loadimod
loadinfo
loadingr
loadkeym
loadland
loadlgtm
loadligh
loadltex
loadlvlc
loadlvli
loadlvln
loadmato
loadmisc
loadmset
loadmstt
loadmusc
loadnavi
loadnavm
loadnote
loadnpc
loadotft
loadpack
loadpgrd
loadpgre
loadpwat
loadqust
loadrace
loadrefr
loadregn
loadroad
loadsbsp
loadscol
loadscpt
loadscrl
loadsgst
loadslgm
loadsndr
loadsoun
loadstat
loadtact
loadterm
loadtes4
loadtree
loadtxst
loadweap
loadwrld
magiceffectid
reader
readerutils
reference
script
typetraits
vertex
)
add_component_dir (misc
barrier budgetmeasurement color compression constants convert coordinateconverter display endianness float16 frameratelimiter
guarded math mathutil messageformatparser notnullptr objectpool osgpluginchecker osguservalues progressreporter resourcehelpers
rng strongtypedef thread timeconvert timer tuplehelpers tuplemeta utf8stream weakcache windows
)
add_component_dir (misc/strings
algorithm conversion format lower
)
add_component_dir (stereo
frustum multiview stereomanager types
)
add_component_dir (debug
debugging debuglog gldebug debugdraw writeflags
)
add_definitions(-DMYGUI_DONT_USE_OBSOLETE=ON)
IF(NOT WIN32 AND NOT APPLE)
add_definitions(-DGLOBAL_DATA_PATH="${GLOBAL_DATA_PATH}")
add_definitions(-DGLOBAL_CONFIG_PATH="${GLOBAL_CONFIG_PATH}")
ENDIF()
add_component_dir (files
linuxpath androidpath windowspath macospath fixedpath multidircollection collections configurationmanager
constrainedfilestream memorystream hash configfileparser openfile constrainedfilestreambuf conversion
istreamptr streamwithbuffer
)
add_component_dir (compiler
context controlparser errorhandler exception exprparser extensions fileparser generator
lineparser literals locals output parser scanner scriptparser skipparser streamerrorhandler
stringparser tokenloc nullerrorhandler opcodes extensions0 declarationparser
quickfileparser discardparser junkparser
)
add_component_dir (interpreter
context controlopcodes genericopcodes installopcodes interpreter localopcodes mathopcodes
miscopcodes opcodes program runtime types defines
)
add_component_dir (translation
translation
)
add_component_dir (terrain
storage world buffercache defs terraingrid material terraindrawable texturemanager chunkmanager compositemaprenderer
quadtreeworld quadtreenode viewdata cellborder view heightcull
)
add_component_dir (loadinglistener
loadinglistener asynclistener
)
add_component_dir (myguiplatform
myguirendermanager myguidatamanager myguiplatform myguitexture myguiloglistener additivelayer scalinglayer
)
add_component_dir (widgets
box fontwrapper imagebutton tags list numericeditbox sharedstatebutton windowcaption widgets
)
add_component_dir (fontloader
fontloader
)
add_component_dir (sdlutil
events
gl4es_init
imagetosurface
sdlcursormanager
sdlgraphicswindow
sdlinputwrapper
sdlmappings
sdlvideowrapper
vsyncmode
)
add_component_dir (version
version
)
add_component_dir (fallback
fallback validate
)
add_component_dir (lua_ui
registerscriptsettings scriptsettings
properties widget element util layers content alignment resources
adapter text textedit window image container flex
)
copy_resource_file("lua_ui/content.lua" "${OPENMW_RESOURCES_ROOT}" "resources/lua_libs/content.lua")
if(WIN32)
add_component_dir (crashcatcher
windows_crashcatcher
windows_crashmonitor
windows_crashshm
windowscrashdumppathhelpers
)
elseif(NOT ANDROID)
add_component_dir (crashcatcher
crashcatcher
)
endif()
add_component_dir(detournavigator
agentbounds
areatype
asyncnavmeshupdater
bounds
changetype
collisionshapetype
commulativeaabb
dbrefgeometryobject
debug
exceptions
findrandompointaroundcircle
findsmoothpath
flags
generatenavmeshtile
gettilespositions
guardednavmeshcacheitem
heightfieldshape
makenavmesh
navigator
navigatorimpl
navigatorstub
navigatorutils
navmeshcacheitem
navmeshdata
navmeshdb
navmeshdbutils
navmeshmanager
navmeshtilescache
navmeshtileview
objectid
objecttransform
offmeshconnection
offmeshconnectionsmanager
preparednavmeshdata
preparednavmeshdatatuple
raycast
recast
recastallocutils
recastcontext
recastglobalallocator
recastmesh
recastmeshbuilder
recastmeshobject
recastmeshprovider
recastmeshtiles
recastparams
recasttempallocator
ref
serialization
settings
settingsutils
sharednavmeshcacheitem
stats
status
tilebounds
tilecachedrecastmeshmanager
tileposition
tilespositionsrange
updateguard
version
waitconditiontype
)
add_component_dir(loadinglistener
reporter
)
add_component_dir(serialization
binaryreader
binarywriter
osgyaml
sizeaccumulator
)
add_component_dir(sqlite3
db
request
statement
transaction
)
add_component_dir(esmloader
lessbyid
load
esmdata
)
add_component_dir(navmeshtool
protocol
)
add_component_dir(platform
platform
file
)
if (WIN32)
add_component_dir(platform
file.win32
)
elseif (UNIX)
add_component_dir(platform
file.posix
)
else ()
add_component_dir(platform
file.stdio
)
endif()
add_component_dir(testing
expecterror
util
)
set (ESM_UI ${CMAKE_CURRENT_SOURCE_DIR}/contentselector/contentselector.ui
)
if (USE_QT)
add_component_qt_dir (contentselector
model/modelitem model/esmfile
model/contentmodel
model/loadordererror
view/combobox view/contentselector
)
add_component_qt_dir (config
gamesettings
launchersettings
)
add_component_qt_dir (l10n
qttranslations
)
add_component_qt_dir (process
processinvoker
)
add_component_qt_dir (misc
helpviewer utf8qtextstream hash scalableicon
)
add_component_qt_dir (files
qtconversion
qtconfigpath
)
add_component_qt_dir (platform
application
)
QT_WRAP_UI(ESM_UI_HDR ${ESM_UI})
endif()
include_directories(${BULLET_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR})
find_package(SQLite3 REQUIRED)
add_library(components STATIC ${COMPONENT_FILES})
if (ANDROID)
set_property(TARGET components PROPERTY POSITION_INDEPENDENT_CODE ON)
endif()
target_link_libraries(components
${COLLADA_DOM_LIBRARIES}
# CMake's built-in OSG finder does not use pkgconfig, so we have to
# manually ensure the order is correct for inter-library dependencies.
# This only makes a difference with `-DOPENMW_USE_SYSTEM_OSG=ON -DOSG_STATIC=ON`.
# https://gitlab.kitware.com/cmake/cmake/-/issues/21701
${OSGPARTICLE_LIBRARIES}
${OSGVIEWER_LIBRARIES}
${OSGSHADOW_LIBRARIES}
${OSGANIMATION_LIBRARIES}
${OSGGA_LIBRARIES}
${OSGTEXT_LIBRARIES}
${OSGDB_LIBRARIES}
${OSGUTIL_LIBRARIES}
${OSGSIM_LIBRARIES}
${OSG_LIBRARIES}
${OPENTHREADS_LIBRARIES}
Boost::system
Boost::program_options
Boost::iostreams
SDL2::SDL2
${OPENGL_gl_LIBRARY}
${MyGUI_LIBRARIES}
${LUA_LIBRARIES}
LZ4::LZ4
RecastNavigation::DebugUtils
RecastNavigation::Detour
RecastNavigation::Recast
Base64
SQLite::SQLite3
smhasher
${ICU_LIBRARIES}
ZLIB::ZLIB
)
if(yaml-cpp_VERSION VERSION_GREATER_EQUAL 0.8.0)
target_link_libraries(components yaml-cpp::yaml-cpp)
else()
target_link_libraries(components yaml-cpp)
endif()
target_link_libraries(components ${BULLET_LIBRARIES})
if (USE_QT)
add_library(components_qt STATIC ${COMPONENT_QT_FILES} ${ESM_UI_HDR})
target_link_libraries(components_qt components Qt::Widgets Qt::Core)
if (BUILD_LAUNCHER OR BUILD_WIZARD)
add_dependencies(components_qt qm-files)
endif()
if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(components_qt PRIVATE --coverage)
target_link_libraries(components_qt gcov)
endif()
endif()
if (OSG_STATIC AND CMAKE_SYSTEM_NAME MATCHES "Linux")
find_package(X11 REQUIRED COMPONENTS Xinerama Xrandr)
target_link_libraries(components ${CMAKE_DL_LIBS} X11::X11 X11::Xinerama X11::Xrandr)
find_package(Fontconfig MODULE)
if(Fontconfig_FOUND)
target_link_libraries(components Fontconfig::Fontconfig)
endif()
endif()
if (WIN32)
target_link_libraries(components shlwapi)
endif()
# Fix for not visible pthreads functions for linker with glibc 2.15
if (UNIX AND NOT APPLE)
target_link_libraries(components ${CMAKE_THREAD_LIBS_INIT})
endif()
if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(components PRIVATE --coverage)
target_link_libraries(components gcov)
endif()
# Make the variable accessible for other subdirectories
set(COMPONENT_FILES ${COMPONENT_FILES} PARENT_SCOPE)
target_compile_definitions(components PUBLIC BT_USE_DOUBLE_PRECISION)
target_compile_definitions(components PRIVATE OPENMW_DOC_BASEURL="${OPENMW_DOC_BASEURL}")
if(OSG_STATIC)
unset(_osg_plugins_static_files)
add_library(components_osg_plugins INTERFACE)
foreach(_plugin ${USED_OSG_PLUGINS})
string(TOUPPER ${_plugin} _plugin_uc)
if(OPENMW_USE_SYSTEM_OSG)
list(APPEND _osg_plugins_static_files ${${_plugin_uc}_LIBRARY})
else()
list(APPEND _osg_plugins_static_files $<TARGET_FILE:${${_plugin_uc}_LIBRARY}>)
target_link_libraries(components_osg_plugins INTERFACE $<TARGET_PROPERTY:${${_plugin_uc}_LIBRARY},LINK_LIBRARIES>)
add_dependencies(components_osg_plugins ${${_plugin_uc}_LIBRARY})
endif()
endforeach()
# We use --whole-archive because OSG plugins use registration.
get_whole_archive_options(_opts ${_osg_plugins_static_files})
target_link_options(components_osg_plugins INTERFACE ${_opts})
target_link_libraries(components components_osg_plugins)
if(OPENMW_USE_SYSTEM_OSG)
# OSG plugin pkgconfig files are missing these dependencies.
# https://github.com/openscenegraph/OpenSceneGraph/issues/1052
find_package(Freetype REQUIRED)
find_package(JPEG REQUIRED)
find_package(PNG REQUIRED)
target_link_libraries(components Freetype::Freetype JPEG::JPEG PNG::PNG)
endif()
endif(OSG_STATIC)
if(USE_QT)
set_property(TARGET components_qt PROPERTY AUTOMOC ON)
endif(USE_QT)
if (MSVC AND PRECOMPILE_HEADERS_WITH_MSVC)
target_precompile_headers(components PUBLIC
<sol/sol.hpp>
<osg/State>
<osg/StateSet>
<osg/Node>
<osg/Drawable>
<osg/Camera>
<MyGUI_Widget.h>
<algorithm>
<filesystem>
<fstream>
<functional>
<memory>
<ostream>
<string>
<vector>
)
target_precompile_headers(components PRIVATE
<osgViewer/Viewer>
<boost/program_options/options_description.hpp>
)
endif()