-
Notifications
You must be signed in to change notification settings - Fork 13
/
CMakeLists.txt
144 lines (115 loc) · 4.95 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
# Copyright (C) 2022 Smirnov Vladimir / [email protected]
# SPDX-License-Identifier: MIT
# See LICENSE file for details.
# Common declarations
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/install CACHE STRING "" FORCE)
cmake_minimum_required(VERSION 3.12...3.19)
project(modgen)
set(MERNEL_ROOT ${CMAKE_CURRENT_LIST_DIR}/ext/mernel)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake ${MERNEL_ROOT}/cmake)
if (WIN32)
add_definitions(-DNOMINMAX -D_UNICODE -DUNICODE -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS -D_USE_MATH_DEFINES)
endif()
# Qt Setup
set(QT_MODULE_LIST Core Gui Widgets Svg)
find_package(Qt5 COMPONENTS ${QT_MODULE_LIST} LinguistTools)
set(QT_CMAKE_EXPORT_NAMESPACE Qt5)
set(${QT_CMAKE_EXPORT_NAMESPACE}::uic ${Qt5Widgets_UIC_EXECUTABLE})
set(${QT_CMAKE_EXPORT_NAMESPACE}::rcc ${Qt5Core_RCC_EXECUTABLE})
set(${QT_CMAKE_EXPORT_NAMESPACE}::lrelease ${Qt5_LRELEASE_EXECUTABLE})
include(targets)
include(qt_helpers)
add_definitions(-DCASCLIB_NO_AUTO_LINK_LIBRARY -DSTORMLIB_NO_AUTO_LINK)
include(CascLib)
include(StormLib)
include(ext/mernel/mernel_thirdparty.cmake)
include(ext/mernel/mernel.cmake)
# source
set(sourceRoot ${CMAKE_CURRENT_SOURCE_DIR}/src)
set(pluginRootBin ${CMAKE_CURRENT_BINARY_DIR}/plugins)
set(presetsRootBin ${CMAKE_CURRENT_BINARY_DIR}/presets)
AddTarget(TYPE shared NAME ModgenCore
SOURCE_DIR ${sourceRoot}/CoreLib
INCLUDES ${sourceRoot}/CoreLib
EXPORT_INCLUDES
LINK_LIBRARIES rapidjson casclib stormlib MernelPlatform
)
file(GLOB_RECURSE resourceFiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/modules
${CMAKE_CURRENT_SOURCE_DIR}/modules/*.json)
foreach(filename ${resourceFiles})
add_custom_command(OUTPUT ${pluginRootBin}/${filename}
COMMAND ${CMAKE_COMMAND} ARGS -E copy ${CMAKE_CURRENT_SOURCE_DIR}/modules/${filename} ${pluginRootBin}/${filename}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/modules/${filename})
target_sources(ModgenCore PRIVATE ${pluginRootBin}/${filename})
endforeach()
file(GLOB_RECURSE presetFiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/presets
${CMAKE_CURRENT_SOURCE_DIR}/presets/*.json ${CMAKE_CURRENT_SOURCE_DIR}/presets/*.txt)
foreach(filename ${presetFiles})
add_custom_command(OUTPUT ${presetsRootBin}/${filename}
COMMAND ${CMAKE_COMMAND} ARGS -E copy ${CMAKE_CURRENT_SOURCE_DIR}/presets/${filename} ${presetsRootBin}/${filename}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/presets/${filename})
target_sources(ModgenCore PRIVATE ${presetsRootBin}/${filename})
endforeach()
# ConsoleApp
AddTarget( TYPE app_console NAME modgen_console
SOURCE_DIR ${sourceRoot}/ConsoleApp
LINK_LIBRARIES ModgenCore MernelPlatform
)
if (NOT Qt5Core_DIR)
return()
endif()
# QtApp
AddTarget( TYPE app_ui NAME modgen
SOURCE_DIR ${sourceRoot}/QtApp
INCLUDES ${sourceRoot}/QtApp
LINK_LIBRARIES ModgenCore MernelPlatform
QT_MODULES Widgets
)
GenerateQrcWithTranslations(Translations ${CMAKE_CURRENT_SOURCE_DIR}/translations qrcName)
AddQrcTarget(${CMAKE_CURRENT_SOURCE_DIR}/theme/breeze.qrc)
AddResourceCustomTarget("all_resources" Translations breeze)
install(DIRECTORY ${pluginRootBin} DESTINATION bin PATTERN *.ilk EXCLUDE PATTERN *.pdb EXCLUDE)
install(DIRECTORY ${presetsRootBin} DESTINATION bin PATTERN *.ilk EXCLUDE PATTERN *.pdb EXCLUDE)
foreach(th IN ITEMS dark light)
install(FILES theme/${th}.conf DESTINATION bin/theme)
configure_file(theme/${th}.conf ${CMAKE_CURRENT_BINARY_DIR}/theme/${th}.conf COPYONLY)
endforeach()
#[[
########## Installation (Win32 only at the moment) ##########
#]]
if(WIN32)
# Qt install - plugins
set(QtPluginsList Qt5::QSvgPlugin)
if(APPLE)
list(APPEND QtPluginsList Qt5::QCocoaIntegrationPlugin)
elseif(WIN32)
list(APPEND QtPluginsList Qt5::QWindowsIntegrationPlugin Qt5::QWindowsVistaStylePlugin)
endif()
foreach(plugin ${QtPluginsList})
get_target_property(imploc_RELEASE ${plugin} IMPORTED_LOCATION_RELEASE)
get_target_property(imploc_DEBUG ${plugin} IMPORTED_LOCATION_DEBUG)
get_filename_component(pluginPath ${imploc_RELEASE} DIRECTORY)
get_filename_component(pluginDir ${pluginPath} NAME)
if (EXISTS "${imploc_DEBUG}")
install(FILES ${imploc_DEBUG} DESTINATION bin/${pluginDir} CONFIGURATIONS Debug )
endif()
install(FILES ${imploc_RELEASE} DESTINATION bin/${pluginDir} CONFIGURATIONS Release )
endforeach()
# Qt install - shared libs
foreach(qt5Module ${QT_MODULE_LIST})
get_target_property(imploc_RELEASE Qt5::${qt5Module} IMPORTED_LOCATION_RELEASE)
get_target_property(imploc_DEBUG Qt5::${qt5Module} IMPORTED_LOCATION_DEBUG)
if (EXISTS "${imploc_DEBUG}")
install(FILES ${imploc_DEBUG} DESTINATION bin CONFIGURATIONS Debug )
endif()
install(FILES ${imploc_RELEASE} DESTINATION bin CONFIGURATIONS Release )
endforeach()
# Compiler runtime
set(CMAKE_INSTALL_UCRT_LIBRARIES TRUE)
if (NOT(CMAKE_BUILD_TYPE STREQUAL Release))
set(CMAKE_INSTALL_DEBUG_LIBRARIES TRUE)
endif()
include (InstallRequiredSystemLibraries)
endif(WIN32)