include(FetchContent) if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") set(CVG_FLAGS -Wno-long-long -fprofile-arcs -ftest-coverage) else() endif() if(FUD_SAN) set(CVG_FLAGS ${CVG_FLAGS} -fsanitize=address -fsanitize=undefined) 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_link_libraries(${test_name} PUBLIC GTest::gtest_main fud) target_include_directories(${test_name} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/../include) 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_fud SOURCES test_fud.cpp) fud_add_test(test_allocator SOURCES test_allocator.cpp) fud_add_test(test_assert SOURCES test_assert.cpp) # fud_add_test(test_c_file SOURCES test_c_file.cpp) fud_add_test(test_directory SOURCES test_directory.cpp) fud_add_test(test_format SOURCES test_format.cpp) fud_add_test(test_option SOURCES test_option.cpp) fud_add_test(test_result SOURCES test_result.cpp) fud_add_test(test_span SOURCES test_span.cpp) fud_add_test(test_sqlite SOURCES test_sqlite.cpp) fud_add_test(test_string SOURCES test_string.cpp) fud_add_test(test_utf8 SOURCES test_utf8.cpp) fud_add_test(test_vector SOURCES test_vector.cpp) fud_add_test(test_string_convert SOURCES test_string_convert.cpp) # fud_add_test(test_deserialize_number SOURCES test_deserialize_number.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)