CMakeLists.txt 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. set(editor_SRCS
  2. StdInc.cpp
  3. main.cpp
  4. mainwindow.cpp
  5. BitmapHandler.cpp
  6. maphandler.cpp
  7. Animation.cpp
  8. graphics.cpp
  9. windownewmap.cpp
  10. generatorprogress.cpp
  11. mapview.cpp
  12. objectbrowser.cpp
  13. mapsettings/abstractsettings.cpp
  14. mapsettings/mapsettings.cpp
  15. mapsettings/generalsettings.cpp
  16. mapsettings/modsettings.cpp
  17. mapsettings/timedevent.cpp
  18. mapsettings/victoryconditions.cpp
  19. mapsettings/loseconditions.cpp
  20. mapsettings/eventsettings.cpp
  21. mapsettings/rumorsettings.cpp
  22. mapsettings/translations.cpp
  23. PlayerSelectionDialog.cpp
  24. PlayerSettingsDialog.cpp
  25. playerparams.cpp
  26. scenelayer.cpp
  27. mapcontroller.cpp
  28. validator.cpp
  29. inspector/inspector.cpp
  30. inspector/townbuildingswidget.cpp
  31. inspector/towneventdialog.cpp
  32. inspector/towneventswidget.cpp
  33. inspector/townspellswidget.cpp
  34. inspector/armywidget.cpp
  35. inspector/messagewidget.cpp
  36. inspector/rewardswidget.cpp
  37. inspector/questwidget.cpp
  38. inspector/heroartifactswidget.cpp
  39. inspector/artifactwidget.cpp
  40. inspector/heroskillswidget.cpp
  41. inspector/herospellwidget.cpp
  42. inspector/PickObjectDelegate.cpp
  43. inspector/portraitwidget.cpp
  44. resourceExtractor/ResourceConverter.cpp
  45. helper.cpp
  46. campaigneditor/campaigneditor.cpp
  47. campaigneditor/campaignproperties.cpp
  48. campaigneditor/scenarioproperties.cpp
  49. campaigneditor/startingbonus.cpp
  50. campaigneditor/campaignview.cpp
  51. )
  52. if(ENABLE_TEMPLATE_EDITOR)
  53. set(editor_SRCS
  54. ${editor_SRCS}
  55. templateeditor/templateeditor.cpp
  56. templateeditor/templateview.cpp
  57. templateeditor/graphicelements/CardItem.cpp
  58. templateeditor/graphicelements/LineItem.cpp
  59. templateeditor/GeometryAlgorithm.cpp
  60. templateeditor/terrainselector.cpp
  61. templateeditor/factionselector.cpp
  62. templateeditor/mineselector.cpp
  63. )
  64. endif()
  65. set(editor_HEADERS
  66. StdInc.h
  67. mainwindow.h
  68. BitmapHandler.h
  69. maphandler.h
  70. Animation.h
  71. graphics.h
  72. windownewmap.h
  73. generatorprogress.h
  74. mapview.h
  75. objectbrowser.h
  76. mapsettings/abstractsettings.h
  77. mapsettings/mapsettings.h
  78. mapsettings/generalsettings.h
  79. mapsettings/modsettings.h
  80. mapsettings/timedevent.h
  81. mapsettings/victoryconditions.h
  82. mapsettings/loseconditions.h
  83. mapsettings/eventsettings.h
  84. mapsettings/rumorsettings.h
  85. mapsettings/translations.h
  86. PlayerSelectionDialog.h
  87. PlayerSettingsDialog.h
  88. playerparams.h
  89. scenelayer.h
  90. mapcontroller.h
  91. validator.h
  92. inspector/inspector.h
  93. inspector/townbuildingswidget.h
  94. inspector/towneventdialog.h
  95. inspector/towneventswidget.h
  96. inspector/townspellswidget.h
  97. inspector/armywidget.h
  98. inspector/messagewidget.h
  99. inspector/rewardswidget.h
  100. inspector/questwidget.h
  101. inspector/heroartifactswidget.h
  102. inspector/artifactwidget.h
  103. inspector/heroskillswidget.h
  104. inspector/herospellwidget.h
  105. inspector/PickObjectDelegate.h
  106. inspector/portraitwidget.h
  107. inspector/baseinspectoritemdelegate.h
  108. resourceExtractor/ResourceConverter.h
  109. mapeditorroles.h
  110. helper.h
  111. campaigneditor/campaigneditor.h
  112. campaigneditor/campaignproperties.h
  113. campaigneditor/scenarioproperties.h
  114. campaigneditor/startingbonus.h
  115. campaigneditor/campaignview.h
  116. )
  117. if(ENABLE_TEMPLATE_EDITOR)
  118. set(editor_HEADERS
  119. ${editor_HEADERS}
  120. templateeditor/templateeditor.h
  121. templateeditor/templateview.h
  122. templateeditor/graphicelements/CardItem.h
  123. templateeditor/graphicelements/LineItem.h
  124. templateeditor/GeometryAlgorithm.h
  125. templateeditor/terrainselector.h
  126. templateeditor/factionselector.h
  127. templateeditor/mineselector.h
  128. )
  129. endif()
  130. set(editor_FORMS
  131. mainwindow.ui
  132. windownewmap.ui
  133. generatorprogress.ui
  134. mapsettings/mapsettings.ui
  135. mapsettings/generalsettings.ui
  136. mapsettings/modsettings.ui
  137. mapsettings/timedevent.ui
  138. mapsettings/victoryconditions.ui
  139. mapsettings/loseconditions.ui
  140. mapsettings/eventsettings.ui
  141. mapsettings/rumorsettings.ui
  142. mapsettings/translations.ui
  143. PlayerSettingsDialog.ui
  144. playerparams.ui
  145. validator.ui
  146. inspector/townbuildingswidget.ui
  147. inspector/towneventdialog.ui
  148. inspector/towneventswidget.ui
  149. inspector/townspellswidget.ui
  150. inspector/armywidget.ui
  151. inspector/messagewidget.ui
  152. inspector/rewardswidget.ui
  153. inspector/questwidget.ui
  154. inspector/heroartifactswidget.ui
  155. inspector/artifactwidget.ui
  156. inspector/heroskillswidget.ui
  157. inspector/herospellwidget.ui
  158. inspector/portraitwidget.ui
  159. campaigneditor/campaigneditor.ui
  160. campaigneditor/campaignproperties.ui
  161. campaigneditor/scenarioproperties.ui
  162. campaigneditor/startingbonus.ui
  163. )
  164. if(ENABLE_TEMPLATE_EDITOR)
  165. set(editor_FORMS
  166. ${editor_FORMS}
  167. templateeditor/templateeditor.ui
  168. templateeditor/terrainselector.ui
  169. templateeditor/factionselector.ui
  170. templateeditor/mineselector.ui
  171. )
  172. endif()
  173. set(editor_RESOURCES
  174. resources.qrc
  175. )
  176. set(translationsDir "translation")
  177. set(editor_TS
  178. "${translationsDir}/belarusian.ts"
  179. "${translationsDir}/bulgarian.ts"
  180. "${translationsDir}/chinese.ts"
  181. "${translationsDir}/czech.ts"
  182. "${translationsDir}/english.ts"
  183. "${translationsDir}/finnish.ts"
  184. "${translationsDir}/french.ts"
  185. "${translationsDir}/german.ts"
  186. "${translationsDir}/greek.ts"
  187. "${translationsDir}/hungarian.ts"
  188. "${translationsDir}/italian.ts"
  189. "${translationsDir}/japanese.ts"
  190. "${translationsDir}/korean.ts"
  191. "${translationsDir}/norwegian.ts"
  192. "${translationsDir}/polish.ts"
  193. "${translationsDir}/portuguese.ts"
  194. "${translationsDir}/romanian.ts"
  195. "${translationsDir}/russian.ts"
  196. "${translationsDir}/spanish.ts"
  197. "${translationsDir}/swedish.ts"
  198. "${translationsDir}/turkish.ts"
  199. "${translationsDir}/ukrainian.ts"
  200. "${translationsDir}/vietnamese.ts"
  201. )
  202. if(ENABLE_TRANSLATIONS)
  203. if(TARGET Qt5::Core)
  204. file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${translationsDir}")
  205. set_source_files_properties(${editor_TS} PROPERTIES OUTPUT_LOCATION "${translationsDir}")
  206. qt5_add_translation(editor_QM ${editor_TS})
  207. set(translationsResource "${CMAKE_CURRENT_BINARY_DIR}/translations.qrc")
  208. list(APPEND editor_RESOURCES "${translationsResource}")
  209. set(rccQmFiles "")
  210. foreach(qmFile ${editor_QM})
  211. string(APPEND rccQmFiles "<file>${qmFile}</file>\n")
  212. endforeach()
  213. file(WRITE "${translationsResource}"
  214. "<!DOCTYPE RCC>
  215. <RCC version=\"1.0\">
  216. <qresource prefix=\"/\">
  217. ${rccQmFiles}
  218. </qresource>
  219. </RCC>"
  220. )
  221. endif()
  222. endif()
  223. if(WIN32)
  224. set(editor_ICON mapeditor.rc)
  225. endif()
  226. assign_source_group(${editor_SRCS} ${editor_HEADERS} ${editor_RESOURCES} ${editor_TS} ${editor_ICON})
  227. set(CMAKE_AUTOMOC ON)
  228. set(CMAKE_AUTOUIC ON)
  229. set(CMAKE_AUTORCC ON)
  230. if(POLICY CMP0071)
  231. cmake_policy(SET CMP0071 NEW)
  232. endif()
  233. # As moc files are generated in the binary dir, tell CMake
  234. # to always look for includes there:
  235. set(CMAKE_INCLUDE_CURRENT_DIR ON)
  236. if(ENABLE_SINGLE_APP_BUILD OR ANDROID)
  237. add_library(vcmieditor OBJECT ${editor_QM})
  238. else()
  239. add_executable(vcmieditor WIN32 ${editor_QM} ${editor_SRCS} ${editor_HEADERS} ${editor_UI_HEADERS} ${editor_ICON})
  240. endif()
  241. if(ENABLE_TRANSLATIONS)
  242. if(TARGET Qt6::Core)
  243. qt_add_translations(vcmieditor
  244. TS_FILES ${editor_TS}
  245. RESOURCE_PREFIX "/${translationsDir}"
  246. INCLUDE_DIRECTORIES
  247. ${CMAKE_CURRENT_BINARY_DIR})
  248. endif()
  249. endif()
  250. target_sources(vcmieditor PRIVATE
  251. ${editor_SRCS}
  252. ${editor_HEADERS}
  253. ${editor_FORMS}
  254. ${editor_RESOURCES}
  255. )
  256. if(WIN32)
  257. set_target_properties(vcmieditor
  258. PROPERTIES
  259. OUTPUT_NAME "VCMI_mapeditor"
  260. PROJECT_LABEL "VCMI_mapeditor"
  261. )
  262. # FIXME: Can't to get CMP0020 working with Vcpkg and CMake 3.8.2
  263. # So far I tried:
  264. # - cmake_minimum_required set to 2.8.11 globally and in this file
  265. # - cmake_policy in all possible places
  266. # - used NO_POLICY_SCOPE to make sure no other parts reset policies
  267. # Still nothing worked, warning kept appearing and WinMain didn't link automatically
  268. target_link_libraries(vcmieditor Qt${QT_VERSION_MAJOR}::WinMain)
  269. endif()
  270. if(APPLE)
  271. # This makes Xcode project prettier by moving mapeditor_autogen directory into vcmiclient subfolder
  272. set_property(GLOBAL PROPERTY AUTOGEN_TARGETS_FOLDER vcmieditor)
  273. endif()
  274. if(ENABLE_TEMPLATE_EDITOR)
  275. target_compile_definitions(vcmieditor PRIVATE ENABLE_TEMPLATE_EDITOR)
  276. endif()
  277. # Qt defines 'emit' as macros, which conflicts with TBB definition of method with same name
  278. target_compile_definitions(vcmieditor PRIVATE QT_NO_EMIT)
  279. if(ENABLE_STATIC_LIBS OR NOT (ENABLE_EDITOR AND ENABLE_LAUNCHER))
  280. target_compile_definitions(vcmieditor PRIVATE VCMIQT_STATIC)
  281. endif()
  282. target_link_libraries(vcmieditor vcmi vcmiqt Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Network)
  283. if(ENABLE_TEMPLATE_EDITOR)
  284. target_link_libraries(vcmieditor vcmi vcmiqt Qt${QT_VERSION_MAJOR}::Svg Qt${QT_VERSION_MAJOR}::Xml)
  285. if(QT_VERSION_MAJOR EQUAL 6)
  286. target_link_libraries(vcmieditor vcmi vcmiqt Qt6::SvgWidgets)
  287. endif()
  288. endif()
  289. target_include_directories(vcmieditor
  290. PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
  291. )
  292. vcmi_set_output_dir(vcmieditor "")
  293. enable_pch(vcmieditor)
  294. install(TARGETS vcmieditor DESTINATION ${BIN_DIR})
  295. # Install icons and desktop file on Linux
  296. if(NOT WIN32 AND NOT APPLE)
  297. foreach(iconSize 32 48 64 128 256)
  298. install(FILES "icons/mapeditor.${iconSize}x${iconSize}.png"
  299. DESTINATION "share/icons/hicolor/${iconSize}x${iconSize}/apps"
  300. RENAME vcmieditor.png
  301. )
  302. endforeach()
  303. install(FILES "vcmieditor.desktop" DESTINATION share/applications)
  304. endif()