diff options
Diffstat (limited to 'test/CMakeLists.txt')
-rw-r--r-- | test/CMakeLists.txt | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..9bd9e87 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,66 @@ +include(FetchContent) + +if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") + set(CVG_FLAGS -Wno-long-long -fsanitize=address -fsanitize=undefined -fprofile-arcs -ftest-coverage) +else() + +endif() + +set(gtest_URL https://github.com/google/googletest.git) +set(gtest_TAG v1.14.0) + +FetchContent_Declare( + googletest + GIT_REPOSITORY ${gtest_URL} + GIT_TAG ${gtest_TAG} +) +FetchContent_MakeAvailable(googletest) +include(GoogleTest) + +enable_testing() + +set(CMAKE_THREAD_LIBS_INIT "-lpthread") +set(CMAKE_HAVE_THREADS_LIBRARY 1) +set(CMAKE_USE_WIN32_THREADS_INIT 0) +set(CMAKE_USE_PTHREADS_INIT 1) +set(THREADS_PREFER_PTHREAD_FLAG ON) + +function(fud_add_test test_name) + set(options NO_OPTIONS) + set(oneValueArgs NO_ONE_VALUE_ARGS) + set(multiValueArgs SOURCES) + cmake_parse_arguments(FUD_ADD_TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + add_executable(${test_name} test_common.cpp ${FUD_ADD_TEST_SOURCES}) + + target_include_directories(${test_name} PUBLIC $<TARGET_PROPERTY:libfud>) + + target_link_libraries(${test_name} PUBLIC GTest::gtest_main libfud) + + target_compile_options(${test_name} PRIVATE ${CVG_FLAGS}) + target_link_options(${test_name} PRIVATE ${CVG_FLAGS}) + + set_target_properties( + ${test_name} PROPERTIES + CXX_STANDARD 20 + C_STANDARD 23 + CXX_EXTENSIONS OFF + C_EXTENSIONS OFF + CXX_STANDARD_REQUIRED ON) + + gtest_discover_tests(${test_name}) +endfunction() + +fud_add_test(test_result SOURCES test_result.cpp) +# fud_add_test(test_ext_algorithm SOURCES test_algorithm.cpp) +# fud_add_test(test_ext_array SOURCES +# test_ext_array.cpp +# test_ext_unique_array.cpp) +# fud_add_test(test_ext_utf8 SOURCES +# test_ext_utf8.cpp) +# fud_add_test(test_ext_string SOURCES +# test_ext_string.cpp +# test_ext_string_cxx.cpp) +# fud_add_test(test_ext_string_format SOURCES +# test_ext_string_format.cpp) + |