CMakeLists.txt 9.2 KB

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