# CMake script for PAPPSOms++ library
# Author: Olivier Langella
# Created: 03/03/2015 from the CMakeLists file of the Bio++ project



find_package(Catch2 REQUIRED)



# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt6Xml_EXECUTABLE_COMPILE_FLAGS}")


configure_file (config.h.cmake ${CMAKE_SOURCE_DIR}/tests/config.h)


# These source files are compiled into a single Catch2-based test binary.
set(tests_cpp_SRCS
  common.cpp
)
# These source files are compiled into a single Catch2-based test binary.
set(catch2_only_cpp_SRCS
    benchmark.cpp
    matrix.cpp
    specglobspectra.cpp
    specglobspeptidepectra.cpp
    test_sgpeptidemodel.cpp
    test_sgposttreatment.cpp
    test_spectralalignment.cpp
  )

add_executable(catch2-only-tests
  ${catch2_only_cpp_SRCS}
  ${tests_cpp_SRCS}
)

add_custom_target(catch2 catch2-only-tests
                  DEPENDS catch2-only-tests
                  WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
                  COMMENT "Running the Catch2-intbased tests.")

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


set(required_target_link_libraries
    PappsoMSpp::Core
    Catch2::Catch2
    Catch2::Catch2WithMain 
    Qt6::Core
    Qt6::Widgets
    Qt6::Sql
    Qt6::Qml
    Boost::chrono
)


target_link_libraries(catch2-only-tests
  ${required_target_link_libraries})

# 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-only-tests "catch2-only-tests")
