CMakeLists.txt 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. formats/model/AFile.cpp
  28. formats/worldmap/MapFileSerializer.cpp
  29. engine/graphics/MovieCameraFrame.cpp
  30. engine/graphics/MovieState.cpp
  31. engine/graphics/ScreenFadeState.cpp
  32. engine/entity/EntityManager.cpp
  33. engine/entity/EntityPoint.cpp
  34. engine/ui/TextHandler.cpp
  35. installer/extractors/FieldDataInstaller.cpp
  36. installer/extractors/SfxDump.cpp
  37. installer/extractors/WindowFonts.cpp
  38. installer/decompiler/field/FieldCodeGenerator.cpp
  39. installer/decompiler/field/FieldDecompiler.cpp
  40. installer/decompiler/world/WorldDisassembler.cpp
  41. installer/decompiler/world/instruction/WorldSubStackInstruction.cpp
  42. )
  43. # Generate tests
  44. add_executable(v-gears-tests ${SOURCE_FILES})
  45. SET_PROPERTY(TARGET v-gears-tests PROPERTY FOLDER "build/v-gears-test")
  46. # Qt imported targets are directory-scoped: the ones created in src/ are not
  47. # visible here. Look them up again in this scope, and fall back to plain
  48. # linker flags when the config package is unavailable.
  49. if(NOT TARGET Qt5::Widgets)
  50. find_package(Qt5 COMPONENTS Core Widgets QUIET)
  51. endif()
  52. if(TARGET Qt5::Widgets)
  53. set(_test_qt_libs Qt5::Widgets Qt5::Core)
  54. else()
  55. set(_test_qt_libs -lQt5Widgets -lQt5Core)
  56. endif()
  57. # The tests use the same libraries as the engine (read from its target, as the variables set in src/ are not visible
  58. # here), plus libarchive, which the installer code needs.
  59. get_target_property(_engine_libs v-gears LINK_LIBRARIES)
  60. target_link_libraries(v-gears-tests
  61. libvgears
  62. ${_test_qt_libs}
  63. ${_engine_libs}
  64. archive
  65. ${ZLIB_LIBRARIES}
  66. Boost::unit_test_framework
  67. )
  68. add_test(NAME v-gears-tests COMMAND v-gears-tests)
  69. # Tests of the installer logic that doesn't need the rest of the engine (layout, option rules, verifier, log), and of
  70. # the data directory lookup shared by the game and the installer.
  71. add_executable(v-gears-installer-tests
  72. common/DataDirectory.cpp
  73. common/OgrePlugins.cpp
  74. ${CMAKE_SOURCE_DIR}/src/common/DataDirectory.cpp
  75. ${CMAKE_SOURCE_DIR}/src/common/InstallStamp.cpp
  76. ${CMAKE_SOURCE_DIR}/src/common/OgrePlugins.cpp
  77. installer/steps/InstallLogic.cpp
  78. installer/steps/ExternalTools.cpp
  79. installer/extractors/MovieCamera.cpp
  80. ${CMAKE_SOURCE_DIR}/src/installer/extractors/MovieCamera.cpp
  81. ${CMAKE_SOURCE_DIR}/src/installer/steps/ExternalTools.cpp
  82. ${CMAKE_SOURCE_DIR}/src/installer/cli/InstallCommandLine.cpp
  83. ${CMAKE_SOURCE_DIR}/src/installer/steps/InstallLayout.cpp
  84. ${CMAKE_SOURCE_DIR}/src/installer/steps/InstallLog.cpp
  85. ${CMAKE_SOURCE_DIR}/src/installer/steps/InstallOptions.cpp
  86. ${CMAKE_SOURCE_DIR}/src/installer/steps/InstallVerifier.cpp
  87. ${CMAKE_SOURCE_DIR}/src/installer/steps/VideoFiles.cpp
  88. )
  89. SET_PROPERTY(TARGET v-gears-installer-tests PROPERTY FOLDER "build/v-gears-test")
  90. target_link_libraries(v-gears-installer-tests ${_test_qt_libs} ${Boost_LIBRARIES})
  91. target_compile_definitions(v-gears-installer-tests PRIVATE VGEARS_SOURCE_DIR="${CMAKE_SOURCE_DIR}")
  92. add_test(NAME v-gears-installer-tests COMMAND v-gears-installer-tests)