if(MAKE_TESTS AND (UNIX AND NOT APPLE))

  message(\n${BoldRed}"Now configuring src/tests for ${CMAKE_PROJECT_NAME}"${ColourReset}\n)
  message("TARGET is: ${TARGET}")

  ########################################################
  # Files

  file(GLOB ${TARGET}_test_SRCS
    ../src/nongui/*.cpp)

  set(tests_SRCS

    # The main() of the tests executable file
    testmain.cpp

    # Files for the tests
    nongui/test_IsoSpecEntity.cpp
    )

  find_package(Catch2 REQUIRED)


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

  find_package(Qt6 COMPONENTS Widgets Xml Svg REQUIRED)

  qt6_wrap_ui(tests_UIS_H ${${TARGET}_UIS})

  qt6_add_resources(tests_QRC_CPP ../minexpert2.qrc)


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

  ### These two lines required because now CMake only automocs
  ### the generated files and not the source files.
  # NOT sure about this. Let's comment that for the moment.
  # set_source_files_properties(${${TARGET}_UIS_H} PROPERTIES SKIP_AUTOMOC ON)
  # set_source_files_properties(${${TARGET}_QRC_CPP} PROPERTIES SKIP_AUTOMOC ON)

  add_executable(tests
    ${${TARGET}_test_SRCS}
    ${tests_SRCS}
    ${tests_UIS_H}
    ${tests_QRC_CPP})

  target_compile_definitions(tests PRIVATE TESTS) #add -DTESTS
  set_property(TARGET tests PROPERTY CXX_STANDARD 17) # we want C++17

  #message("CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}")

  include_directories(
    ${CMAKE_SOURCE_DIR}

    ${CMAKE_SOURCE_DIR}/src/nongui
    ${CMAKE_SOURCE_DIR}/src/gui

    ${CMAKE_CURRENT_SOURCE_DIR}

    ${Qt6Widgets_INCLUDE_DIRS}
    ${Qt6Xml_INCLUDE_DIRS}
    ${Qt6Svg_INCLUDE_DIRS}
    )

  target_include_directories(tests PRIVATE
    ${INCLUDE_DIRECTORIES}
    )

  set(required_target_link_libraries
    Qt6::Widgets
    Qt6::Xml
    Qt6::Svg
    QCustomPlotQt6::QCustomPlotQt6
    IsoSpec++::IsoSpec++
    PappsoMSpp::Core
    PappsoMSpp::Widget
    Catch2::Catch2
    )

  target_link_libraries(tests
    ${required_target_link_libraries})

  #add_test(tests "All Catch2-based tests")
  add_test(tests "tests")

  message("")
  message(STATUS "${BoldGreen}Finished processing src/tests.${ColourReset}")
  message("")

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


