Commit a9f5ce77 authored by Gauthier Quesnel's avatar Gauthier Quesnel
Browse files

cmake: add function to add unit test

parent d3d9265a
Pipeline #222 passed with stage
in 18 seconds
......@@ -7,24 +7,28 @@ target_include_directories(libbits INTERFACE include/)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/bits DESTINATION include)
function(add_unit_test target source)
add_executable(${target} ${source})
add_executable(test_parameter test/parameter.cpp)
set_target_properties(${target} PROPERTIES
COMPILE_DEFINITIONS EXAMPLES_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/test\"
CXX_STANDARD 14
CXX_STANDARD_REQUIRED ON)
set_target_properties(test_parameter PROPERTIES
COMPILE_DEFINITIONS EXAMPLES_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/test\"
CXX_STANDARD 14
CXX_STANDARD_REQUIRED ON)
target_compile_definitions(${target}
PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:_CRT_SECURE_NO_WARNINGS>
$<$<CXX_COMPILER_ID:MSVC>:_SCL_SECURE_NO_WARNINGS>)
target_compile_definitions(test_parameter
PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:_CRT_SECURE_NO_WARNINGS>
$<$<CXX_COMPILER_ID:MSVC>:_SCL_SECURE_NO_WARNINGS>)
target_link_libraries(${target} libbits)
target_link_libraries(test_parameter libbits)
target_include_directories(test_parameter PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
target_include_directories(test_parameter PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
add_test(${target} ${target})
endfunction()
add_test(test_parameter test_parameter)
add_unit_test(test_parameter test/parameter.cpp)
add_unit_test(test_array test/array.cpp)
enable_testing()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment