Skip to content
Snippets Groups Projects
Commit 2a14f12d authored by Damiano Amatruda's avatar Damiano Amatruda
Browse files

[CMake] Allow to compile Catch2 tests for host

- CMake function 'sbs_target' now links to 'boardcore-host' when not
  cross-compiling
- CMake function 'sbs_catch_test' is added to register Catch2 test cases
  in CTest only when not cross-compiling
parent a8085d19
Branches
Tags
No related merge requests found
......@@ -20,6 +20,7 @@
# THE SOFTWARE.
cmake_minimum_required(VERSION 3.16)
enable_testing()
include(cmake/sbs.cmake)
#-----------------------------------------------------------------------------#
......@@ -103,7 +104,7 @@ add_executable(catch-tests-entry
)
target_compile_definitions(catch-tests-entry PUBLIC USE_MOCK_PERIPHERALS)
sbs_target(catch-tests-entry stm32f429zi_stm32f4discovery)
#catch_discover_tests(catch-tests-entry)
sbs_catch_test(catch-tests-entry)
#-----------------------------------------------------------------------------#
# Tests - Drivers #
......
......@@ -46,6 +46,7 @@ function(sbs_target TARGET OPT_BOARD)
message(FATAL_ERROR "No board selected")
endif()
target_include_directories(${TARGET} PRIVATE src/shared)
if(CMAKE_CROSSCOMPILING)
target_link_libraries(${TARGET} PRIVATE SkywardBoardcore::Boardcore-${OPT_BOARD})
add_custom_command(
TARGET ${TARGET} POST_BUILD
......@@ -54,4 +55,13 @@ function(sbs_target TARGET OPT_BOARD)
BYPRODUCTS ${TARGET}.hex ${TARGET}.bin
VERBATIM
)
else()
target_link_libraries(${TARGET} PRIVATE SkywardBoardcore::Boardcore-host)
endif()
endfunction()
function(sbs_catch_test TARGET)
if(NOT CMAKE_CROSSCOMPILING)
catch_discover_tests(${TARGET})
endif()
endfunction()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment