CMakeLists.txt 8.8 KB

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