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

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

  message(\n${BoldRed}"Now configuring src/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 REQUIRED)

  find_package(Catch2 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)

  macro(TEST_FIND_LIBRARY OUTPUT_LIBS lib_name include_to_find)
    #start:
    find_path("${CMAKE_SOURCE_DIR}/src" ${include_to_find})

    set(${lib_name}_NAMES ${lib_name} ${lib_name}.lib ${lib_name}.dll)

    find_library(${lib_name}_LIBRARY NAMES ${${lib_name}_NAMES})

    if(${lib_name}_LIBRARY)

      message("-- Library ${lib_name} found here:")
      message("   includes: ${${lib_name}_INCLUDE_DIR}")
      message("   dynamic libraries: ${${lib_name}_LIBRARY}")
      message(WARNING "Library ${lib_name} is already installed in the system tree. Test will be built against it. This may lead to unexpected results. You may want to do 'make install' before 'make test', or remove the installed version.")

    else()

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

    endif()

    set(${OUTPUT_LIBS} ${${OUTPUT_LIBS}} ${${lib_name}_LIBRARY})

  endmacro(TEST_FIND_LIBRARY)

  # File list
  set(CPP_TEST_FILES
    saxparsers/xtandemresultshandler.cpp
  )


  # These source files are compiled into a single Catch2-based test binary.
  set(catch2_only_cpp_SRCS
    catch-only-tests-main.cpp
    test_datapoint.cpp
    test_trace.cpp
    test_maptrace.cpp
    test_tracecombiner.cpp
    test_massspectrum.cpp
    test_mzintegrationparams.cpp
    test_massspectrumcombiner.cpp
    test_timsxicextractor.cpp
    test_timsxicextractor_based_masspec.cpp
    test_trace_filters.cpp
    test_xic.cpp
    test_aa.cpp
    test_protein.cpp
    test_peptide.cpp
    test_psm.cpp
    test_uimonitor.cpp
    test_timsframe.cpp
    test_tims_data_xic_chromatogram.cpp
    test_tims_ion_mobility_grid.cpp
    test_tandem_run_wrapper.cpp
    test_msrunalignment.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-tests
    common.cpp
    ${catch2_only_cpp_SRCS}
    ${catch2_only_cpp_memory_SRCS}
  )

  set_property(TARGET catch2-only-tests 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
  )

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

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

  add_executable(test_fasta_reader test_fasta_reader.cpp)
  target_link_libraries(test_fasta_reader Qt5::Core pappsomspp-shared)
  add_test(test_fasta_reader "test_fasta_reader")


  add_executable(test_massrange test_massrange.cpp)
  target_link_libraries(test_massrange Qt5::Core pappsomspp-shared)
  add_test(test_massrange "test_massrange")


  add_executable(test_peptidenaturalisotopelist test_peptidenaturalisotopelist.cpp)
  target_link_libraries(test_peptidenaturalisotopelist Qt5::Core Qt5::Gui pappsomspp-shared)
  add_test(test_peptidenaturalisotopelist "test_peptidenaturalisotopelist")

  add_executable(test_natural_isotope_average test_natural_isotope_average.cpp)
  target_link_libraries(test_natural_isotope_average Qt5::Core pappsomspp-shared)
  add_test(test_natural_isotope_average "test_natural_isotope_average")

  add_executable(test_peptidefragment test_peptidefragment.cpp)
  target_link_libraries(test_peptidefragment Qt5::Core Qt5::Gui pappsomspp-shared)
  add_test(test_peptidefragment "test_peptidefragment")

  add_executable(test_fragmentationcid test_fragmentationcid.cpp)
  target_link_libraries(test_fragmentationcid Qt5::Core Qt5::Gui pappsomspp-shared)
  add_test(test_fragmentationcid "test_fragmentationcid")

  #IF (FALSE) 
  add_executable(test_big_hyperscore test_big_hyperscore.cpp ${CPP_TEST_FILES})
  target_link_libraries(test_big_hyperscore Qt5::Core Qt5::Gui Qt5::Xml pappsomspp-shared)
  add_test(test_big_hyperscore "test_big_hyperscore")
  #ENDIF(FALSE)

  add_executable(test_rawmasslist test_rawmasslist.cpp)
  target_link_libraries(test_rawmasslist Qt5::Core Qt5::Gui pappsomspp-shared)
  add_test(test_rawmasslist "test_rawmasslist")

  add_executable(test_isotope_with_spectrum common.cpp test_isotope_with_spectrum.cpp)
  target_link_libraries(test_isotope_with_spectrum Qt5::Core Qt5::Gui pappsomspp-shared  ${Boost_LIBRARIES} OdsStream::Core)
  add_test(test_isotope_with_spectrum "test_isotope_with_spectrum")
  set(TEST_LIST ${TEST_LIST} test_isotope_with_spectrum)

  add_executable(test_hyperscore common.cpp test_hyperscore.cpp)
  target_link_libraries(test_hyperscore Qt5::Core pappsomspp-shared Qt5::Gui  ${Boost_LIBRARIES} OdsStream::Core)
  add_test(test_hyperscore "test_hyperscore")
  set(TEST_LIST ${TEST_LIST} test_hyperscore)

  add_executable(test_xtandem_spectrum common.cpp test_xtandem_spectrum.cpp)
  target_link_libraries(test_xtandem_spectrum Qt5::Core pappsomspp-shared Qt5::Gui  ${Boost_LIBRARIES} OdsStream::Core)
  add_test(test_xtandem_spectrum "test_xtandem_spectrum")
  set(TEST_LIST ${TEST_LIST} test_xtandem_spectrum)

  add_executable(test_scan_15968  common.cpp test_scan_15968.cpp)
  target_link_libraries(test_scan_15968 Qt5::Core Qt5::Gui pappsomspp-shared  ${Boost_LIBRARIES} OdsStream::Core)
  add_test(test_scan_15968 "test_scan_15968")
  set(TEST_LIST ${TEST_LIST} test_scan_15968)


  add_executable(test_xicextractor test_xicextractor.cpp)
  target_link_libraries(test_xicextractor Qt5::Core Qt5::Gui pappsomspp-shared  ${Boost_LIBRARIES} OdsStream::Core )
  add_test(test_xicextractor "test_xicextractor")
  set(TEST_LIST ${TEST_LIST} test_xicextractor)

  add_executable(test_msrunoutput test_msrunoutput.cpp)
  target_link_libraries(test_msrunoutput Qt5::Core Qt5::Gui Qt5::Concurrent pappsomspp-shared  ${Boost_LIBRARIES} OdsStream::Core Catch2::Catch2)
  add_test(test_msrunoutput "test_msrunoutput")
  set(TEST_LIST ${TEST_LIST} test_msrunoutput)


  #if(UNIX)

  #set_property(TEST catch2-only-tests test_big_hyperscore test_fasta_reader 
  #test_massrange test_peptidenaturalisotopelist test_peptidefragment 
  #test_fragmentationcid ${TEST_LIST} test_natural_isotope_average test_rawmasslist 
  #PROPERTY ENVIRONMENT "LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}:../src")

  #endif()

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



  add_subdirectory(widget)

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


