This repository has been archived on 2026-04-17. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
bhlib/test/CMakeLists.txt

42 lines
971 B
CMake
Raw Permalink Normal View History

# Project and C standard configuration
project(bhunit LANGUAGES C)
2025-01-18 17:24:36 +03:00
set(CMAKE_C_STANDARD 90)
set(CMAKE_C_STANDARD_REQUIRED ON)
# Disable extensions
2025-01-18 17:24:36 +03:00
set(CMAKE_C_EXTENSIONS OFF)
# Library code
set(BHUNIT_SOURCE
src/Unit.c
)
set(BHUNIT_HEADER
include/BH/Unit.h
)
# Library
add_library(BHUnit STATIC ${BHUNIT_SOURCE} ${BHUNIT_HEADER})
target_include_directories(BHUnit PUBLIC include)
2025-01-18 17:24:36 +03:00
# Enable testing
include(CTest)
enable_testing()
# Search files
file(GLOB TEST_FILES "tests/*.c")
2025-01-18 17:24:36 +03:00
foreach(TEST_FILENAME ${TEST_FILES})
# Add test
2025-01-18 17:24:36 +03:00
get_filename_component(TEST_NAME ${TEST_FILENAME} NAME_WE)
add_executable("${TEST_NAME}" ${TEST_FILENAME})
2025-02-03 10:56:40 +03:00
target_link_libraries("${TEST_NAME}" BHLib BHUnit)
2025-01-18 17:24:36 +03:00
add_test(NAME "${TEST_NAME}" COMMAND "${TEST_NAME}")
# Enable coverage
if(ENABLE_COVERAGE)
2025-01-18 17:24:36 +03:00
target_compile_options("${TEST_NAME}" PRIVATE -coverage)
target_link_options("${TEST_NAME}" PRIVATE -coverage)
endif()
endforeach()