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



find_package(Catch2 REQUIRED)

#apt-get install libpwiz-dev libboost-dev
#CTEST_OUTPUT_ON_FAILURE=TRUE make test
#make test ARGS="-V"
#make test ARGS="-V -I 4,4"

#export LD_LIBRARY_PATH=/home/langella/developpement/git/pappsomspp/build/src:$LD_LIBRARY_PATH

# msconvert /gorgone/pappso/versions_logiciels_pappso/deepprot/donnees/PXD004732/01650b_BG3-TUM_first_pool_65_01_01-DDA-1h-R2.mzXML --mgf --filter "scanNumber 59739"

# msconvert /gorgone/pappso/versions_logiciels_pappso/deepprot/donnees/PXD004732/01650b_BG3-TUM_first_pool_65_01_01-DDA-1h-R2.mzXML --mgf --filter "scanNumber 59737"

# 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(specoms_cpp_SRCS
    ../src/algorithms/fptree/fptree.cpp
    ../src/algorithms/fptree/spectreeextractorreporterinterface.cpp
    ../src/algorithms/fptree/threadedfptree.cpp
    ../src/core/digestion/peptidemodificationpipeline.cpp
    ../src/core/digestion/protopeptidedigestion.cpp
    ../src/core/peptide_database/peptidedatabase.cpp
    ../src/core/spectrum_matcher_legacy/missedcleavagefinder.cpp
    ../src/core/spectrum_matcher_legacy/peptidecandidate.cpp
    ../src/core/spectrum_matcher_legacy/peptidespectrumshifter.cpp
    ../src/core/spectrum_matcher_legacy/spectrummatcher.cpp
    ../src/core/spectrum_matcher_legacy/specxtractmatcherlegacy.cpp
    ../src/core/digestionpipeline.cpp
    ../src/core/fastafile.cpp
    ../src/core/fastasourcelist.cpp
    ../src/core/msspectrumreader.cpp
    ../src/core/runningdeepprot.cpp
    ../src/core/spectrumint.cpp
    ../src/core/spectrumintstore.cpp
    ../src/output/mzidentml.cpp
    ../src/output/mzidentmlallcandidates.cpp
    ../src/output/odsoutput.cpp
    ../src/output/odsspecsimilarities.cpp
    ../src/output/outputinterface.cpp
    ../src/output/psmcboroutput.cpp
    ../src/utils/decisionbox.cpp
    ../src/utils/deepprotparams.cpp
    ../src/utils/monitorcli.cpp
    ../src/utils/monitorinterface.cpp
    ../src/utils/utils.cpp
  )
  # These source files are compiled into a single Catch2-based test binary.
  set(catch2_only_cpp_SRCS
    test_spectree.cpp
    test_spectrumfilter.cpp
    test_spectrumint.cpp
    test_spectrumshifter.cpp    
  )
  
  set(catch2_benchmarks_only_cpp_SRCS
    test_benchmark.cpp    
  )

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

  add_executable(catch2-only-benchmarks
    ${catch2_benchmarks_only_cpp_SRCS}
    ${specoms_cpp_SRCS}
  )

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

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

  
  set(required_target_link_libraries
    QuaZip::QuaZip
    OdsStream::Core
    PappsoMSpp::Core
    Qt6::Qml
    Qt6::Sql
    Qt6::Concurrent
    Catch2::Catch2WithMain
    SQLite3::SQLite3
  )
  
  target_link_libraries(catch2-only-tests
    ${required_target_link_libraries})
  target_link_libraries(catch2-only-benchmarks
    ${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")
