18 lines
677 B
CMake
18 lines
677 B
CMake
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY .)
|
|
|
|
file(REMOVE .gitignore)
|
|
function(unit_test dir name lib sources)
|
|
string(TOLOWER ${name} lower)
|
|
string(TOLOWER ${dir}/${name} testname)
|
|
string(REPLACE "/" "_" targetname ${testname})
|
|
|
|
add_executable(${targetname} EXCLUDE_FROM_ALL ${lower}.c ${sources} $<TARGET_OBJECTS:${lib}>)
|
|
target_compile_definitions(${targetname} PUBLIC -DCONFIG_TESTING_DIR=\"${testname}\")
|
|
set_target_properties(${targetname} PROPERTIES OUTPUT_NAME ${lower})
|
|
add_dependencies(tests ${targetname})
|
|
|
|
add_test(NAME ${dir}/${name} COMMAND tests/${testname} --verbose WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
|
|
file(APPEND .gitignore "${lower}\n")
|
|
endfunction()
|