summaryrefslogtreecommitdiff
path: root/src/CMakeLists.txt
blob: 27dfc590f5765e743bdcb39c7274dd254a5b2e4e (plain)
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
CMAKE_MINIMUM_REQUIRED (VERSION 2.8.11)

CMAKE_POLICY(SET CMP0020 NEW)
#CMAKE_POLICY(SET CMP0043 NEW)

SET(PROJ_AUTHOR Tannin)
SET(PROJ_ARCH x86)
IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
  SET(PROJ_ARCH x64)
ENDIF()

SET(organizer_SRCS
    transfersavesdialog.cpp
    syncoverwritedialog.cpp
    spawn.cpp
    singleinstance.cpp
    settingsdialog.cpp
    settings.cpp
    selfupdater.cpp
    selectiondialog.cpp
    queryoverwritedialog.cpp
    profilesdialog.cpp
    profile.cpp
    pluginlistsortproxy.cpp
    pluginlist.cpp
    pluginlistview.cpp
    overwriteinfodialog.cpp
    nxmaccessmanager.cpp
    nexusinterface.cpp
    motddialog.cpp
    modlistsortproxy.cpp
    modlist.cpp
    modidlineedit.cpp
    modinfodialog.cpp
    modinfo.cpp
    modinfobackup.cpp
    modinfoforeign.cpp
    modinfooverwrite.cpp
    modinforegular.cpp
    modinfoseparator.cpp
    modinfowithconflictinfo.cpp
    messagedialog.cpp
    mainwindow.cpp
    main.cpp
    loghighlighter.cpp
    logbuffer.cpp
    lockeddialogbase.cpp
    lockeddialog.cpp
    waitingonclosedialog.cpp
    loadmechanism.cpp
    installationmanager.cpp
    helper.cpp
    filedialogmemory.cpp
    executableslist.cpp
    editexecutablesdialog.cpp
    downloadmanager.cpp
    downloadlistwidget.cpp
    downloadlistsortproxy.cpp
    downloadlist.cpp
    directoryrefresher.cpp
    credentialsdialog.cpp
    categoriesdialog.cpp
    categories.cpp
    bbcode.cpp
    activatemodsdialog.cpp
    moapplication.cpp
    profileinputdialog.cpp
    icondelegate.cpp
    csvbuilder.cpp
    savetextasdialog.cpp
    qtgroupingproxy.cpp
    modlistview.cpp
    problemsdialog.cpp
    serverinfo.cpp
    browserview.cpp
    browserdialog.cpp
    persistentcookiejar.cpp
    noeditdelegate.cpp
    previewgenerator.cpp
    previewdialog.cpp
    aboutdialog.cpp
    modflagicondelegate.cpp
    genericicondelegate.cpp
    organizerproxy.cpp
    viewmarkingscrollbar.cpp
    plugincontainer.cpp
    organizercore.cpp
    instancemanager.cpp
    usvfsconnector.cpp
    eventfilter.cpp
    moshortcut.cpp
    listdialog.cpp
    lcdnumber.cpp
    forcedloaddialog.cpp
    forcedloaddialogwidget.cpp

    shared/windows_error.cpp
    shared/error_report.cpp
    shared/directoryentry.cpp
    shared/util.cpp
    shared/appconfig.cpp
    shared/leaktrace.cpp
    shared/stackdata.cpp
  )

SET(organizer_HDRS
    transfersavesdialog.h
    syncoverwritedialog.h
    spawn.h
    singleinstance.h
    settingsdialog.h
    settings.h
    selfupdater.h
    selectiondialog.h
    queryoverwritedialog.h
    profilesdialog.h
    profile.h
    pluginlistsortproxy.h
    pluginlist.h
    pluginlistview.h
    overwriteinfodialog.h
    nxmaccessmanager.h
    nexusinterface.h
    motddialog.h
    modlistsortproxy.h
    modlist.h
    modidlineedit.h
    modinfodialog.h
    modinfo.h
    modinfobackup.h
    modinfoforeign.h
    modinfooverwrite.h
    modinforegular.h
    modinfoseparator.h
    modinfowithconflictinfo.h
    messagedialog.h
    mainwindow.h
    loghighlighter.h
    logbuffer.h
    lockeddialogbase.h
    lockeddialog.h
    waitingonclosedialog.h
    loadmechanism.h
    installationmanager.h
    helper.h
    filedialogmemory.h
    executableslist.h
    editexecutablesdialog.h
    downloadmanager.h
    downloadlistwidget.h
    downloadlistsortproxy.h
    downloadlist.h
    directoryrefresher.h
    credentialsdialog.h
    categoriesdialog.h
    categories.h
    bbcode.h
    activatemodsdialog.h
    moapplication.h
    profileinputdialog.h
    icondelegate.h
    csvbuilder.h
    savetextasdialog.h
    qtgroupingproxy.h
    modlistview.h
    problemsdialog.h
    serverinfo.h
    browserview.h
    browserdialog.h
    persistentcookiejar.h
    noeditdelegate.h
    previewgenerator.h
    previewdialog.h
    aboutdialog.h
    modflagicondelegate.h
    genericicondelegate.h
    organizerproxy.h
    viewmarkingscrollbar.h
    plugincontainer.h
    organizercore.h
    ilockedwaitingforprocess.h
    iuserinterface.h
    instancemanager.h
    usvfsconnector.h
    eventfilter.h
    descriptionpage.h
    moshortcut.h
    listdialog.h
    lcdnumber.h
    forcedloaddialog.h
    forcedloaddialogwidget.h

    shared/windows_error.h
    shared/error_report.h
    shared/directoryentry.h
    shared/util.h
    shared/appconfig.h
    shared/appconfig.inc
    shared/leaktrace.h
    shared/stackdata.h
  )

SET(organizer_UIS
    transfersavesdialog.ui
    syncoverwritedialog.ui
    simpleinstalldialog.ui
    settingsdialog.ui
    selectiondialog.ui
    queryoverwritedialog.ui
    profilesdialog.ui
    overwriteinfodialog.ui
    motddialog.ui
    modinfodialog.ui
    messagedialog.ui
    mainwindow.ui
    lockeddialog.ui
    waitingonclosedialog.ui
    installdialog.ui
    finddialog.ui
    editexecutablesdialog.ui
    credentialsdialog.ui
    categoriesdialog.ui
    activatemodsdialog.ui
    profileinputdialog.ui
    savetextasdialog.ui
    problemsdialog.ui
    previewdialog.ui
    browserdialog.ui
    aboutdialog.ui
    listdialog.ui
    forcedloaddialog.ui
    forcedloaddialogwidget.ui
  )

SET(organizer_QRCS
    resources.qrc
    stylesheet_resource.qrc
    )

SET(organizer_RCS
    app_icon.rc
    version.rc
	)


source_group(src REGULAR_EXPRESSION ".*\\.(h|cpp)")

set(application
	iuserinterface
	main
	mainwindow
	moapplication
	moshortcut
	selfupdater
	singleinstance
)

set(browser
	browserdialog
	browserview
)

set(core
	categories
	shared/directoryentry
	directoryrefresher
	executableslist
	installationmanager
	instancemanager
	loadmechanism
	nexusinterface
	nxmaccessmanager
	organizercore
	organizerproxy
)

set(dialogs
	aboutdialog
	activatemodsdialog
	categoriesdialog
	credentialsdialog
	editexecutablesdialog
	filedialogmemory
	forcedloaddialog
	forcedloaddialogwidget
	listdialog
	messagedialog
	motddialog
	overwriteinfodialog
	queryoverwritedialog
	problemsdialog
	savetextasdialog
	selectiondialog
	syncoverwritedialog
	transfersavesdialog
	waitingonclosedialog
)

set(downloads
	downloadlist
	downloadlistsortproxy
	downloadlistwidget
	downloadmanager
)

set(locking
	ilockedwaitingforprocess
	lockeddialog
	lockeddialogbase
)

set(modinfo
	modinfo
	modinfobackup
	modinfodialog
	modinfoforeign
	modinfooverwrite
	modinforegular
	modinfoseparator
	modinfowithconflictinfo
)

set(modlist
	modlist
	modlistsortproxy
	modlistview
)

set(plugins
	plugincontainer
	pluginlist
	pluginlistsortproxy
	pluginlistview
)

set(previews
	previewdialog
	previewgenerator
)

set(profiles
	profile
	profileinputdialog
	profilesdialog
)

set(resources
	app_icon
	version
)

set(settings
	settings
	settingsdialog
)

set(utilities
	shared/appconfig
	bbcode
	csvbuilder
	shared/error_report
	eventfilter
	helper
	shared/leaktrace
	persistentcookiejar
	serverinfo
	spawn
	shared/stackdata
	shared/util
	usvfsconnector
	shared/windows_error
)

set(widgets
	descriptionpage
	genericicondelegate
	icondelegate
	lcdnumber
	logbuffer
	loghighlighter
	modflagicondelegate
	modidlineedit
	noeditdelegate
	qtgroupingproxy
	viewmarkingscrollbar
)

set(src_filters
	application core browser dialogs downloads locking modinfo modlist plugins
	previews profiles settings utilities widgets
)

set(root_filters resources)

foreach(filter in list ${src_filters})
	set(files)
	foreach(d in lists ${${filter}})
		set(files ${files} ${d}.cpp ${d}.h ${d}.rc ${d}.inc)
	endforeach()

	source_group(src\\${filter} FILES ${files})
endforeach()

foreach(filter in list ${root_filters})
	set(files)
	foreach(d in lists ${${filter}})
		set(files ${files} ${d}.cpp ${d}.h ${d}.rc ${d}.inc)
	endforeach()

	source_group(${filter} FILES ${files})
endforeach()

file(GLOB_RECURSE rule_files ../vsbuild/CMakeFiles/*.rule)
source_group(cmake FILES CMakeLists.txt ${rule_files})

source_group(qt FILES
	${organizer_QRCS}
	../vsbuild/src/ModOrganizer_autogen/mocs_compilation.cpp
	../vsbuild/src/qrc_resources.cpp
	../vsbuild/src/qrc_stylesheet_resource.cpp
	../vsbuild/src/organizer_en.qm)


# MO projects
SET(dependency_project_path "${DEPENDENCIES_DIR}")
SET(default_project_path "${DEPENDENCIES_DIR}/modorganizer_super")
GET_FILENAME_COMPONENT(${default_project_path} ${default_project_path} REALPATH)
SET(project_path "${default_project_path}" CACHE PATH "path to the other mo projects")

#TODO this should not be a hardcoded path
SET(lib_path "${project_path}/../../install/libs")

# Qt5
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
SET(CMAKE_AUTOMOC ON)
SET(CMAKE_AUTOUIC ON)
FIND_PACKAGE(Qt5Widgets REQUIRED)
FIND_PACKAGE(Qt5QuickWidgets REQUIRED)
FIND_PACKAGE(Qt5Quick REQUIRED)
FIND_PACKAGE(Qt5Network REQUIRED)
FIND_PACKAGE(Qt5WinExtras REQUIRED)
FIND_PACKAGE(Qt5WebEngineWidgets REQUIRED)
FIND_PACKAGE(Qt5WebSockets REQUIRED)
FIND_PACKAGE(Qt5Qml REQUIRED)
FIND_PACKAGE(Qt5LinguistTools)
QT5_WRAP_UI(organizer_UIHDRS ${organizer_UIS})
QT5_ADD_RESOURCES(organizer_RCCPPS ${organizer_QRCS})
SET(mo_translation_sources ${CMAKE_SOURCE_DIR}/src ${project_path}/uibase/src)
QT5_CREATE_TRANSLATION(organizer_translations_qm ${mo_translation_sources} ${CMAKE_SOURCE_DIR}/src/organizer_en.ts)
ADD_CUSTOM_TARGET(translations DEPENDS ${organizer_translations_qm})

INCLUDE_DIRECTORIES(${Qt5Declarative_INCLUDES})

ADD_DEFINITIONS(-DQT_MESSAGELOGCONTEXT)

# Boost
SET(Boost_USE_STATIC_LIBS       OFF)
SET(Boost_USE_MULTITHREADED      ON)
SET(Boost_USE_STATIC_RUNTIME    OFF)
FIND_PACKAGE(Boost REQUIRED)

INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})


FIND_PACKAGE(zlib REQUIRED)
# TODO FindZlib doesn't find the static zlib library

INCLUDE_DIRECTORIES(${project_path}/uibase/src
                    ${project_path}/bsatk/src
                    ${project_path}/esptk/src
                    ${project_path}/archive/src
                    ${dependency_project_path}/usvfs/include
                    ${project_path}/game_gamebryo/src/gamebryo
                    ${project_path}/game_gamebryo/src/creation
                    ${project_path}/game_features/src
                    ${project_path}/githubpp/src
                    ${LZ4_ROOT}/lib)

INCLUDE_DIRECTORIES(shared ${ZLIB_INCLUDE_DIRS})
LINK_DIRECTORIES(${lib_path}
                 ${ZLIB_ROOT}/lib
                 ${LZ4_ROOT}/bin)
EXECUTE_PROCESS(
  COMMAND git log -1 --format=%h
  WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
  OUTPUT_VARIABLE GIT_COMMIT_HASH
  OUTPUT_STRIP_TRAILING_WHITESPACE
)

ADD_DEFINITIONS(-D_UNICODE -DUNICODE -DNOMINMAX -D_CRT_SECURE_NO_WARNINGS -DBOOST_CONFIG_SUPPRESS_OUTDATED_MESSAGE -DGITID="${GIT_COMMIT_HASH}")

IF("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
  SET(usvfs_name usvfs_x64)
ELSE()
  SET(usvfs_name usvfs_x86)
ENDIF()

ADD_EXECUTABLE(ModOrganizer WIN32 ${organizer_HDRS} ${organizer_SRCS} ${organizer_UIHDRS} ${organizer_RCS} ${organizer_RCCPPS} ${organizer_translations_qm})
TARGET_LINK_LIBRARIES(ModOrganizer
                      Qt5::Widgets Qt5::WinExtras Qt5::WebEngineWidgets Qt5::Quick
                      Qt5::Qml Qt5::QuickWidgets Qt5::Network Qt5::WebSockets
                      ${Boost_LIBRARIES}
                      zlibstatic
                      uibase esptk bsatk githubpp
                      ${usvfs_name}
                      Dbghelp advapi32 Version Shlwapi liblz4 Crypt32)

IF (MSVC)
  SET_TARGET_PROPERTIES(ModOrganizer PROPERTIES COMPILE_FLAGS "/std:c++latest")
ENDIF()
IF (MSVC AND "${CMAKE_SIZEOF_VOID_P}" EQUAL 4)
  # 32 bits
  SET_TARGET_PROPERTIES(ModOrganizer PROPERTIES LINK_FLAGS "/LARGEADDRESSAWARE")
ENDIF()

IF (NOT "${OPTIMIZE_COMPILE_FLAGS}" STREQUAL "")
  SET_TARGET_PROPERTIES(ModOrganizer PROPERTIES COMPILE_FLAGS_RELWITHDEBINFO ${OPTIMIZE_COMPILE_FLAGS})
ENDIF()
IF (NOT "${OPTIMIZE_LINK_FLAGS}" STREQUAL "")
  SET_TARGET_PROPERTIES(ModOrganizer PROPERTIES LINK_FLAGS_RELWITHDEBINFO ${OPTIMIZE_LINK_FLAGS})
ENDIF()


###############
## Installation

SET(qt5bin ${Qt5Core_DIR}/../../../bin)

FIND_PROGRAM(WINDEPLOYQT_COMMAND windeployqt PATHS ${qt5bin} NO_DEFAULT_PATH)

INSTALL(TARGETS ModOrganizer
        RUNTIME DESTINATION bin)
INSTALL(FILES $<TARGET_PDB_FILE:ModOrganizer>
        DESTINATION pdb)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/dlls.manifest.qt5
        DESTINATION bin/dlls
        RENAME dlls.manifest)

INSTALL(FILES ${organizer_translations_qm} DESTINATION bin/translations)

INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/stylesheets
                  ${CMAKE_CURRENT_SOURCE_DIR}/tutorials
        DESTINATION bin)

#We should do this last, since windeployqt.exe scans the folders in bin for required modules e.g QtQuick.2 required by tutorials.
# use windeployqt.exe to install all required libraries
SET(windeploy_parameters "--no-translations --plugindir qtplugins --libdir dlls --release-with-debug-info --no-compiler-runtime")
INSTALL(
    CODE
    "EXECUTE_PROCESS(COMMAND
        ${qt5bin}/windeployqt.exe ModOrganizer.exe --webenginewidgets --websockets ${windeploy_parameters}
        WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/bin
    )
    EXECUTE_PROCESS(COMMAND
        ${qt5bin}/windeployqt.exe uibase.dll ${windeploy_parameters}
        WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/bin
    )
    file(REMOVE_RECURSE ${CMAKE_INSTALL_PREFIX}/bin/platforms)
    file(REMOVE_RECURSE ${CMAKE_INSTALL_PREFIX}/bin/styles)
    file(REMOVE_RECURSE ${CMAKE_INSTALL_PREFIX}/bin/dlls/imageformats)
    file(RENAME ${CMAKE_INSTALL_PREFIX}/bin/qtplugins/platforms ${CMAKE_INSTALL_PREFIX}/bin/platforms)
    file(RENAME ${CMAKE_INSTALL_PREFIX}/bin/qtplugins/styles ${CMAKE_INSTALL_PREFIX}/bin/styles)
    file(RENAME ${CMAKE_INSTALL_PREFIX}/bin/qtplugins/imageformats ${CMAKE_INSTALL_PREFIX}/bin/dlls/imageformats)
    file(REMOVE_RECURSE ${CMAKE_INSTALL_PREFIX}/bin/qtplugins)"
)

# qdds.dll needs installing manually as Qt no longer ships with it by default.
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../qdds.dll DESTINATION bin/dlls/imageformats)