CMakeLists.txt 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. # Find packages required to compile tests. Imported targets are directory-scoped, so the Boost components that the
  2. # engine links (found in src/) have to be looked up here too.
  3. find_package(Boost REQUIRED COMPONENTS filesystem unit_test_framework program_options thread
  4. OPTIONAL_COMPONENTS system chrono)
  5. # Compiler options.
  6. if(UNIX OR APPLE)
  7. add_definitions(-DBOOST_TEST_DYN_LINK)
  8. endif()
  9. if (UNIX)
  10. add_definitions(-DPOSIX) # For SUDM. TODO: Add elses?
  11. endif()
  12. # Directories to include for test compilations.
  13. include_directories(
  14. ${CMAKE_SOURCE_DIR}/src
  15. ${CMAKE_SOURCE_DIR}/src/installer
  16. ${CMAKE_CURRENT_SOURCE_DIR}
  17. ${ZLIB_INCLUDE_DIRS}
  18. ${OGRE_INCLUDE_DIRS}
  19. ${QT_QTCORE_INCLUDE_DIR}
  20. ${QT_QTGUI_INCLUDE_DIR}
  21. ${QT_QTCORE_INCLUDE_DIR}
  22. ${QT_QTGUI_INCLUDE_DIR}
  23. )
  24. # Test source files.
  25. set(SOURCE_FILES
  26. main.cpp
  27. VGearsGameState.cpp
  28. FF7Character.cpp
  29. FF7Common.cpp
  30. data/VGearsAFile.cpp
  31. data/VGearsAFileManager.cpp
  32. data/VGearsAFileSerializer.cpp
  33. data/VGearsBackgroundFile.cpp
  34. data/VGearsBackgroundFileManager.cpp
  35. data/VGearsBackgroundFileSerializer.cpp
  36. data/VGearsCameraMatrixFile.cpp
  37. data/VGearsCameraMatrixFileManager.cpp
  38. data/VGearsCameraMatrixFileSerializer.cpp
  39. data/VGearsFLevelBackground2DLoader.cpp
  40. data/VGearsFLevelFile.cpp
  41. data/VGearsFLevelFileSerializer.cpp
  42. data/VGearsFLevelTextureLoader.cpp
  43. data/VGearsHRCFile.cpp
  44. data/VGearsHRCFileManager.cpp
  45. data/VGearsHRCFileSerializer.cpp
  46. data/VGearsHRCMeshLoader.cpp
  47. data/VGearsHRCSkeletonLoader.cpp
  48. data/VGearsLGPArchive.cpp
  49. data/VGearsLGPArchiveFactory.cpp
  50. data/VGearsLGPArchiveSerializer.cpp
  51. data/VGearsLZSDataStream.cpp
  52. data/VGearsLZSFLevelFile.cpp
  53. data/VGearsLZSFLevelFileManager.cpp
  54. data/VGearsMapListFile.cpp
  55. data/VGearsPaletteFile.cpp
  56. data/VGearsPaletteFileManager.cpp
  57. data/VGearsPaletteFileSerializer.cpp
  58. data/VGearsPFile.cpp
  59. data/VGearsPFileManager.cpp
  60. data/VGearsPFileSerializer.cpp
  61. data/VGearsRSDFile.cpp
  62. data/VGearsRSDFileManager.cpp
  63. data/VGearsRSDFileSerializer.cpp
  64. data/VGearsSerializer.cpp
  65. data/VGearsTexCodec.cpp
  66. data/VGearsTexFile.cpp
  67. data/VGearsTriggersFile.cpp
  68. data/VGearsXMLSerializer.cpp
  69. data/FinalFantasy7/FF7ModelListFileManager.cpp
  70. data/FinalFantasy7/FF7ModelListFileSerializer.cpp
  71. data/FinalFantasy7/FF7ModelListFile.cpp
  72. data/worldmap/MapFile.cpp
  73. data/worldmap/MapFileManager.cpp
  74. data/worldmap/MapFileSerializer.cpp
  75. data/worldmap/TxzFile.cpp
  76. data/worldmap/TxzFileSerializer.cpp
  77. common/Application.cpp
  78. common/File.cpp
  79. common/FileSystem.cpp
  80. common/LzsFile.cpp
  81. common/VGearsManualObject.cpp
  82. common/VGearsResource.cpp
  83. common/VGearsStringUtil.cpp
  84. core/AudioManager.cpp
  85. core/Background2D.cpp
  86. core/Background2DAnimation.cpp
  87. core/MovieCameraFrame.cpp
  88. core/MovieState.cpp
  89. core/ScreenFadeState.cpp
  90. core/CameraManager.cpp
  91. core/ConfigCmd.cpp
  92. core/ConfigCmdHandler.cpp
  93. core/ConfigFile.cpp
  94. core/ConfigVar.cpp
  95. core/ConfigVarHandler.cpp
  96. core/Console.cpp
  97. core/DebugDraw.cpp
  98. core/DialogsManager.cpp
  99. core/Entity.cpp
  100. core/EntityCollision.cpp
  101. core/EntityDirection.cpp
  102. core/EntityManager.cpp
  103. core/EntityModel.cpp
  104. core/EntityPoint.cpp
  105. core/EntityTrigger.cpp
  106. core/GameFrameListener.cpp
  107. core/InputManager.cpp
  108. core/Savemap.cpp
  109. core/SavemapHandler.cpp
  110. core/ScriptManager.cpp
  111. core/TextHandler.cpp
  112. core/Timer.cpp
  113. core/UiAnimation.cpp
  114. core/UiFont.cpp
  115. core/UiManager.cpp
  116. core/UiSprite.cpp
  117. core/UiTextArea.cpp
  118. core/UiWidget.cpp
  119. core/Utilites.cpp
  120. core/Walkmesh.cpp
  121. core/XmlBackground2DFile.cpp
  122. core/XmlFile.cpp
  123. core/XmlFontFile.cpp
  124. core/XmlFontsFile.cpp
  125. core/XmlMapFile.cpp
  126. core/XmlMapsFile.cpp
  127. core/XmlMusicsFile.cpp
  128. core/XmlPrototypesFile.cpp
  129. core/XmlScreensFile.cpp
  130. core/XmlSoundsFile.cpp
  131. core/XmlTextFile.cpp
  132. core/XmlTextsFile.cpp
  133. core/XmlScreenFile.cpp
  134. core/XmlScriptsFile.cpp
  135. core/XmlWalkmeshFile.cpp
  136. core/particles/Particle.cpp
  137. core/particles/ParticleEmitter.cpp
  138. core/particles/ParticleEmitterDictionary.cpp
  139. core/particles/ParticleEmitterTranslator.cpp
  140. core/particles/ParticleRenderer.cpp
  141. core/particles/ParticleRendererTranslator.cpp
  142. core/particles/ParticleSystem.cpp
  143. core/particles/ParticleSystemFactory.cpp
  144. core/particles/ParticleSystemManager.cpp
  145. core/particles/ParticleSystemTranslator.cpp
  146. core/particles/ParticleSystemTranslatorManager.cpp
  147. core/particles/ParticleTechniqueTranslator.cpp
  148. core/particles/ParticleTechnique.cpp
  149. core/particles/ParticleVisual.cpp
  150. core/particles/emitters/PointEmitter.cpp
  151. core/particles/emitters/PointEmitterFactory.cpp
  152. core/particles/renderer/ParticleEntityRenderer.cpp
  153. core/particles/renderer/ParticleEntityRendererDictionary.cpp
  154. installer/DataInstaller.cpp
  155. installer/FieldDataInstaller.cpp
  156. installer/FieldTextWriter.cpp
  157. installer/KernelDataInstaller.cpp
  158. installer/MainWindow.cpp
  159. installer/MediaDataInstaller.cpp
  160. installer/ModelsAndAnimationsDb.cpp
  161. installer/ScopedLgp.cpp
  162. installer/SfxDump.cpp
  163. installer/TexFile.cpp
  164. installer/VGearsUtility.cpp
  165. installer/WindowFonts.cpp
  166. installer/WorldInstaller.cpp
  167. installer/common/BinGZipFile.cpp
  168. installer/common/DrawSkeleton.cpp
  169. installer/common/Logger.cpp
  170. installer/common/OgreBase.cpp
  171. installer/common/OgreGenUtilites.cpp
  172. installer/common/Vram.cpp
  173. installer/decompiler/CodeGenerator.cpp
  174. installer/decompiler/ControlFlow.cpp
  175. installer/decompiler/DecompilerException.cpp
  176. installer/decompiler/Disassembler.cpp
  177. installer/decompiler/Engine.cpp
  178. installer/decompiler/Graph.cpp
  179. installer/decompiler/LuaLanguage.cpp
  180. installer/decompiler/ScriptFormatter.cpp
  181. installer/decompiler/Value.cpp
  182. installer/decompiler/field/FieldCodeGenerator.cpp
  183. installer/decompiler/field/FieldEngine.cpp
  184. installer/decompiler/field/FieldDecompiler.cpp
  185. installer/decompiler/field/FieldDisassembler.cpp
  186. installer/decompiler/field/FieldScriptFormatter.cpp
  187. installer/decompiler/field/instruction/FieldBackgroundInstruction.cpp
  188. installer/decompiler/field/instruction/FieldCameraInstruction.cpp
  189. installer/decompiler/field/instruction/FieldCondJumpInstruction.cpp
  190. installer/decompiler/field/instruction/FieldControlFlowInstruction.cpp
  191. installer/decompiler/field/instruction/FieldMathInstruction.cpp
  192. installer/decompiler/field/instruction/FieldMediaInstruction.cpp
  193. installer/decompiler/field/instruction/FieldModelInstruction.cpp
  194. installer/decompiler/field/instruction/FieldModuleInstruction.cpp
  195. installer/decompiler/field/instruction/FieldNoOperationInstruction.cpp
  196. installer/decompiler/field/instruction/FieldPartyInstruction.cpp
  197. installer/decompiler/field/instruction/FieldUncategorizedInstruction.cpp
  198. installer/decompiler/field/instruction/FieldUncondJumpInstruction.cpp
  199. installer/decompiler/field/instruction/FieldWalkmeshInstruction.cpp
  200. installer/decompiler/field/instruction/FieldWindowInstruction.cpp
  201. installer/decompiler/instruction/BinaryOpStackInstruction.cpp
  202. installer/decompiler/instruction/CondJumpInstruction.cpp
  203. installer/decompiler/instruction/Instruction.cpp
  204. installer/decompiler/instruction/KernelCallInstruction.cpp
  205. installer/decompiler/instruction/LoadInstruction.cpp
  206. installer/decompiler/instruction/StackInstruction.cpp
  207. installer/decompiler/instruction/StoreInstruction.cpp
  208. installer/decompiler/instruction/UncondJumpInstruction.cpp
  209. installer/decompiler/world/WorldDisassembler.cpp
  210. installer/decompiler/world/WorldCodeGenerator.cpp
  211. installer/decompiler/world/WorldEngine.cpp
  212. installer/decompiler/world/instruction/WorldBinaryEqualStackInstruction.cpp
  213. installer/decompiler/world/instruction/WorldCondJumpInstruction.cpp
  214. installer/decompiler/world/instruction/WorldKernelCallInstruction.cpp
  215. installer/decompiler/world/instruction/WorldLoadBankInstruction.cpp
  216. installer/decompiler/world/instruction/WorldLoadInstruction.cpp
  217. installer/decompiler/world/instruction/WorldNoOutputInstruction.cpp
  218. installer/decompiler/world/instruction/WorldStackInstruction.cpp
  219. installer/decompiler/world/instruction/WorldStoreInstruction.cpp
  220. installer/decompiler/world/instruction/WorldSubStackInstruction.cpp
  221. installer/decompiler/world/instruction/WorldUncondJumpInstruction.cpp
  222. map/VGearsBackground2DFile.cpp
  223. map/VGearsBackground2DFileManager.cpp
  224. map/VGearsBackground2DFileXMLSerializer.cpp
  225. map/VGearsMapFile.cpp
  226. map/VGearsMapFileManager.cpp
  227. map/VGearsMapFileXMLSerializer.cpp
  228. map/VGearsWalkmeshFile.cpp
  229. map/VGearsWalkmeshFileManager.cpp
  230. map/VGearsWalkmeshFileXMLSerializer.cpp
  231. map/FinalFantasy7/FF7WalkmeshFileSerializer.cpp
  232. modules/worldmap/WorldMapModule.cpp
  233. )
  234. # Generate tests
  235. add_executable(v-gears-tests ${SOURCE_FILES})
  236. SET_PROPERTY(TARGET v-gears-tests PROPERTY FOLDER "build/v-gears-test")
  237. # Qt imported targets are directory-scoped: the ones created in src/ are not
  238. # visible here. Look them up again in this scope, and fall back to plain
  239. # linker flags when the config package is unavailable.
  240. if(NOT TARGET Qt5::Widgets)
  241. find_package(Qt5 COMPONENTS Core Widgets QUIET)
  242. endif()
  243. if(TARGET Qt5::Widgets)
  244. set(_test_qt_libs Qt5::Widgets Qt5::Core)
  245. else()
  246. set(_test_qt_libs -lQt5Widgets -lQt5Core)
  247. endif()
  248. # The tests use the same libraries as the engine (read from its target, as the variables set in src/ are not visible
  249. # here), plus libarchive, which the installer code needs.
  250. get_target_property(_engine_libs v-gears LINK_LIBRARIES)
  251. target_link_libraries(v-gears-tests
  252. libvgears
  253. ${_test_qt_libs}
  254. ${_engine_libs}
  255. archive
  256. ${ZLIB_LIBRARIES}
  257. Boost::unit_test_framework
  258. )
  259. add_test(NAME v-gears-tests COMMAND v-gears-tests)
  260. # Tests of the installer logic that doesn't need the rest of the engine (layout, option rules, verifier, log), and of
  261. # the data directory lookup shared by the game and the installer.
  262. add_executable(v-gears-installer-tests
  263. common/DataDirectory.cpp
  264. common/OgrePlugins.cpp
  265. ${CMAKE_SOURCE_DIR}/src/common/DataDirectory.cpp
  266. ${CMAKE_SOURCE_DIR}/src/common/InstallStamp.cpp
  267. ${CMAKE_SOURCE_DIR}/src/common/OgrePlugins.cpp
  268. installer/InstallLogic.cpp
  269. installer/ExternalTools.cpp
  270. installer/MovieCamera.cpp
  271. ${CMAKE_SOURCE_DIR}/src/installer/MovieCamera.cpp
  272. ${CMAKE_SOURCE_DIR}/src/installer/ExternalTools.cpp
  273. ${CMAKE_SOURCE_DIR}/src/installer/InstallCommandLine.cpp
  274. ${CMAKE_SOURCE_DIR}/src/installer/InstallLayout.cpp
  275. ${CMAKE_SOURCE_DIR}/src/installer/InstallLog.cpp
  276. ${CMAKE_SOURCE_DIR}/src/installer/InstallOptions.cpp
  277. ${CMAKE_SOURCE_DIR}/src/installer/InstallVerifier.cpp
  278. ${CMAKE_SOURCE_DIR}/src/installer/VideoFiles.cpp
  279. )
  280. SET_PROPERTY(TARGET v-gears-installer-tests PROPERTY FOLDER "build/v-gears-test")
  281. target_link_libraries(v-gears-installer-tests ${_test_qt_libs} ${Boost_LIBRARIES})
  282. target_compile_definitions(v-gears-installer-tests PRIVATE VGEARS_SOURCE_DIR="${CMAKE_SOURCE_DIR}")
  283. add_test(NAME v-gears-installer-tests COMMAND v-gears-installer-tests)