#------------------------------------------------------------------------------
#
# \brief	CMakeLists.txt file for "liblepto"
#
#------------------------------------------------------------------------------


cmake_minimum_required(VERSION 3.11)
project(ocelli_tests)

message(STATUS "LEPTO MCU_REV: ${MCU_REV}")
message(STATUS "LEPTO MCU_BOARD: ${MCU_BOARD}")

find_package( Catch2 3 )
if( NOT Catch2_FOUND )
   find_package( Catch )
   if( NOT Catch_FOUND )
      # find_package does not work for Catch, at least on ubuntu 20.04
      if( EXISTS /usr/include/catch )
         add_definitions( "-DCATCH_V1" )
      elseif( EXISTS /usr/include/catch2 )
         if( EXISTS /usr/include/catch2/catch_test_macros.hpp )
            add_definitions( "-DCATCH_V3" )
         else()
            add_definitions( "-DCATCH_V2" )
         endif()
      else( EXISTS /usr/include/catch2 )
         message( FATAL_ERROR "Install eeither Catch or Catch2")
      endif( EXISTS /usr/include/catch )
   endif( NOT Catch_FOUND )
   add_definitions( "-DCATCH_V1" )
else( NOT Catch2_FOUND)
   add_definitions( "-DCATCH_V3" )
   set( CATCH_LIBRARY "Catch2::Catch2WithMain" )
endif( NOT Catch2_FOUND )

set(headers
         #include/ocelli/touch.h
)

set(sources
   test_touch.cpp
   test_screen.cpp
   test_widget.cpp
)

add_executable( ocelli_tests
   ${sources}
   ${headers}
)

target_link_libraries(
   ocelli_tests
   ocelli
   ${CATCH_LIBRARY}
)

if ( CAMPO )
   use_common_config_headers( ${PROJECT_NAME} )
endif( CAMPO )

add_test(
   NAME ocelli_tests
   COMMAND ocelli_tests
   WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)


#------------------------------------------------------------------------------
