message(\n${BoldRed}"Now configuring tests for ${CMAKE_PROJECT_NAME} ${ColourReset}\n")

find_package(Catch2 REQUIRED)


get_property(libmass_INCLUDE_DIRS GLOBAL PROPERTY glob_prop_libmass_INCLUDE_DIRS)
get_property(libmass_LIBRARIES GLOBAL PROPERTY glob_prop_libmass_LIBRARIES)
message(STATUS "Found libmass at: ${libmass_LIBRARIES} with include dir: ${libmass_INCLUDE_DIRS}")

set(catch2_tests_SRCS
    test_Isotope.cpp
    test_Formula.cpp
)


include_directories(
  ${libmass_INCLUDE_DIRS})


add_executable(catch2-tests
    ${catch2_tests_SRCS}
    ${${TARGET}_QRC_CPP}
)

# Finally actually set the linking dependencies to the executable.
target_link_libraries(catch2-tests

  -Wl,--whole-archive
  ${libmass_LIBRARIES}
  ${libmassgui_LIBRARIES}
  -Wl,--no-whole-archive

  -Wl,--no-as-needed
  PappsoMSpp::Core
  -Wl,--as-needed

  IsoSpec++::IsoSpec++

  Qt6::Core
  Qt6::Xml
  Qt6::Network

  Catch2::Catch2
  Catch2::Catch2WithMain
)

set_property(TARGET catch2-tests PROPERTY CXX_STANDARD 17) # we want C++17

# Add the Catch2-based single binary test file to the CMake's test suite so
# that it gets called using 'make test'. To see the output, add "ARGS=-V" to
# the call.
add_test(catch2-tests "catch2-tests")
