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

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

  message("${BoldGreen}\nNow configuring tests for ${CMAKE_PROJECT_NAME}\n${ColourReset}")

  # 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(USE_PAPPSO_TREE)
    set(USEPAPPSOTREE 1)
    message("USEPAPPSOTREE is defined")
    message("Please be sure that your environment has accessed to the PAPPSO directory")
  endif(USE_PAPPSO_TREE)

  configure_file(${CMAKE_UTILS_PATH}/tests-config.h.cmake.in ${CMAKE_CURRENT_BINARY_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(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/pappsomspp/core/libpappsomspp-core.so")
  set(PappsoMSppWidget_LIBRARY "${CMAKE_BINARY_DIR}/src/pappsomspp/gui/libpappsomspp-gui.so")

  message("In tests, include dirs for pappsomspp: ${PappsoMSpp_INCLUDE_DIRS}")
  message("In tests, core library: ${PappsoMSpp_LIBRARY}")
  message("In tests, widget library: ${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_aacode.cpp
        test_big_hyperscore.cpp
        test_cborpsmmap.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_mzcbor.cpp
        test_trace_filters.cpp
        test_xic.cpp
        test_proforma.cpp
        test_project.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_qualified_spectrum.cpp
        test_msrunoutput.cpp
        test_uimonitor.cpp
        test_rawmasslist.cpp
        test_spectree.cpp
        test_timsframe.cpp
        test_tandem_run_wrapper.cpp
        test_unimod.cpp
        test_scan_15968.cpp
        test_c13n15.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)

  add_executable(catch2-only-memory ${catch2_only_cpp_memory_SRCS} common.cpp)

  add_executable(catch2-only-tests ${catch2_only_cpp_SRCS} common.cpp)

  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

  message("CMAKE_BINARY_DIR ${CMAKE_BINARY_DIR}")
  message("CMAKE_CURRENT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}")

  target_include_directories(
        catch2-only-tests
        PUBLIC ${CMAKE_BINARY_DIR} # so that #include "config.h" works and #include "tests/tests-config.h" works also
               ${PappsoMSpp_INCLUDE_DIRS}
               Catch2::Catch2
               Catch2::Catch2WithMain
    )

  get_target_property(INCLUDE_DIRS catch2-only-tests INTERFACE_INCLUDE_DIRECTORIES)
  message("Include directories for catch2-only-tests: ${INCLUDE_DIRS}")

  target_include_directories(
        catch2-only-memory
        PUBLIC ${CMAKE_BINARY_DIR} # so that #include "config.h" works
               ${PappsoMSpp_INCLUDE_DIRS}
               Catch2::Catch2
               Catch2::Catch2WithMain
    )

  set(required_target_link_libraries
        Core
        Catch2::Catch2
        Catch2::Catch2WithMain
        OdsStream::Core
        liblzf::liblzf
        QuaZip::QuaZip
        OdsStream::Core
    )

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

  target_link_libraries(catch2-only-memory ${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")

  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)

  add_subdirectory(benchmarks)
  add_subdirectory(proteincode)
  add_subdirectory(peptidoms)
  add_subdirectory(dia)
  if(USE_PAPPSO_TREE)
    add_subdirectory(pappsotree)
  endif()
  message(\n${BoldGreen}"Done configuring tests for ${CMAKE_PROJECT_NAME}"${ColourReset}\n)

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