if(MAKE_TESTS AND (WIN64 OR (UNIX AND NOT APPLE)))

  set (CMAKE_CXX_FLAGS "-Wno-error=deprecated-declarations")

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

  # CMake script for PAPPSOms++ library
  # Authors: Copyright Olivier Langella & Filippo Rusconi
  # GPLv3+
  # Created: 03/03/2015 from the CMakeLists file of the Bio++ project
  # Changes 20201201 by FR.


  IF(USEPAPPSOTREE)
    set(USEPAPPSOTREE 1)
    message("USEPAPPSOTREE is defined")
    message("Please be sure that your environment has accessed to the PAPPSO directory")
  ENDIF(USEPAPPSOTREE)

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

  #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

  #set(CMAKE_MODULE_PATH "/usr/share/cmake-3.0/Modules")

  message("tests/CMakeLists.txt - CMAKE_MODULE_PATH:" ${CMAKE_MODULE_PATH})

  #find_package(QuaZip-Qt6 REQUIRED)

  find_package(Catch2 REQUIRED)
  find_package(Boost COMPONENTS chrono REQUIRED)


  if(OdsStream_FOUND)
  else (OdsStream_FOUND)
    find_package(OdsStream REQUIRED)
  endif(OdsStream_FOUND)

  if(TARGET OdsStream::Core)
    message("OdsStream::Core found.")
  else (TARGET OdsStream::Core)
    message("OdsStream::Core not found.")
  endif (TARGET OdsStream::Core)

  # When running tests we necessarily have to document the location of the
  # libraries that were built locally.
  set(PappsoMSpp_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/src")
  set(PappsoMSpp_LIBRARY "${CMAKE_BINARY_DIR}/src/libpappsomspp.so")
  set(PappsoMSppWidget_LIBRARY "${CMAKE_BINARY_DIR}/src/pappsomspp/widget/libpappsomspp-widget.so")

  message("${PappsoMSpp_INCLUDE_DIRS}")
  message("${PappsoMSpp_LIBRARY}")
  message("${PappsoMSppWidget_LIBRARY}")


  # These source files are compiled into a single Catch2-based test binary.
  set(catch2_only_cpp_SRCS
    catch-only-tests-main.cpp
    test_aa.cpp
    test_big_hyperscore.cpp
    test_datapoint.cpp
    test_fasta_reader.cpp
    test_fragmentationcid.cpp
    test_hyperscore.cpp
    test_isotope_with_spectrum.cpp
    test_trace.cpp
    test_maptrace.cpp
    test_massrange.cpp
    test_tracecombiner.cpp
    test_massspectrum.cpp
    test_mzintegrationparams.cpp
    test_massspectrumcombiner.cpp
    test_trace_filters.cpp
    test_xic.cpp
    test_protein.cpp
    test_proteincode.cpp
    test_peptide.cpp
    test_peptidefragment.cpp
    test_peptidenaturalisotopelist.cpp
    test_natural_isotope_average.cpp
    test_psm.cpp
    test_msrunoutput.cpp
    test_msrunreaderng.cpp
    test_uimonitor.cpp
    test_rawmasslist.cpp
    test_timsframe.cpp
    test_tims_data_xic_chromatogram.cpp
    test_tims_ion_mobility_grid.cpp
    test_tandem_run_wrapper.cpp
    test_msrunalignment.cpp
    test_scan_15968.cpp
    test_c13n15.cpp
    test_xicextractor.cpp
    test_xtandem_spectrum.cpp
    saxparsers/xtandemresultshandler.cpp
  )

  # These source files are compiled into a single Catch2-based test binary.
  # tests dedicated to check memory usage and avoid memory leaks
  set(catch2_only_cpp_memory_SRCS
    memory/test_tandemwrapperrun.cpp
    memory/test_timsdata_reader_memory.cpp
  )

  # These source files are compiled into a single Catch2-based test binary.
  # tests dedicated to check speed performances (benchmarks)
  set(catch2_only_cpp_benchmark_SRCS
    benchmarks/catch-only-benchmarks-main.cpp
    benchmarks/test_msrunreaderng.cpp
    benchmarks/test_timsxicextractor.cpp
    benchmarks/test_timsxicextractor_based_masspec.cpp
  )

  add_executable(catch2-only-benchmarks
    common.cpp
    ${catch2_only_cpp_benchmark_SRCS}
  )
  
  add_executable(catch2-only-memory
    common.cpp
    ${catch2_only_cpp_memory_SRCS}
  )
  add_executable(catch2-only-tests
    common.cpp
    ${catch2_only_cpp_SRCS}
  )

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

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

  # So that the <xxx>-based #includes find the proper header files even
  # if these are not installed on the system.
  include_directories("${CMAKE_SOURCE_DIR}/src")

  target_include_directories(catch2-only-tests PRIVATE
    ${INCLUDE_DIRECTORIES}
    Catch2::Catch2 Catch2::Catch2WithMain 
  )
  
  target_include_directories(catch2-only-benchmarks PRIVATE
    ${INCLUDE_DIRECTORIES}
    Catch2::Catch2
  )

  set(required_target_link_libraries
    pappsomspp-shared
    Catch2::Catch2
    Catch2::Catch2WithMain 
    OdsStream::Core
    liblzf::liblzf
    QuaZip::QuaZip
  )

  target_link_libraries(catch2-only-tests
    ${required_target_link_libraries})
    
  target_link_libraries(catch2-only-memory
    pappsomspp-shared
    Catch2::Catch2
    Catch2::Catch2WithMain
    QuaZip::QuaZip
  )
    
  target_link_libraries(catch2-only-benchmarks
    pappsomspp-shared
    Catch2::Catch2
    liblzf::liblzf
    Boost::chrono
    QuaZip::QuaZip
    OdsStream::Core
    )

  # 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")

  set_property(TEST catch2-only-tests  PROPERTY
    ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_PATH}/src")

  if(WIN32)
    set(ENV{PATH} "$ENV{PATH};..\\src")
  endif()

  add_subdirectory(widget)

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

else()
  message(STATUS "Tests are not built.")
endif()


