mirror of
https://github.com/meekrosoft/fff
synced 2026-01-23 00:15:59 +01:00
Add GTest with FetchContent (#120)
* Add missing GTest linking * Add unit testing switch * Rename UNIT_TESTING to be fff-specific * Add fff.h generation toggle * Use options instead of variables for disabling build elements * Add interface library for when the header is not regenerated * Update build script and README
This commit is contained in:
@@ -8,6 +8,17 @@ set(
|
||||
src/test_cases.include
|
||||
)
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
FetchContent_Declare(
|
||||
googletest
|
||||
GIT_REPOSITORY https://github.com/google/googletest.git
|
||||
GIT_TAG v1.12.0
|
||||
)
|
||||
|
||||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
||||
FetchContent_MakeAvailable(googletest)
|
||||
|
||||
# Create the C test executable
|
||||
add_executable(c_test src/fff_test_c.c ${COMMON_FILE_LIST})
|
||||
target_include_directories(c_test PRIVATE include)
|
||||
@@ -16,7 +27,7 @@ target_link_libraries(c_test PRIVATE fff)
|
||||
# Create the C++ test executable
|
||||
add_executable(cpp_test src/fff_test_cpp.cpp ${COMMON_FILE_LIST})
|
||||
target_include_directories(cpp_test PRIVATE include)
|
||||
target_link_libraries(cpp_test PRIVATE gtest fff)
|
||||
target_link_libraries(cpp_test PRIVATE GTest::gtest_main fff)
|
||||
|
||||
# Create the C global test executable
|
||||
add_executable(c_global_test
|
||||
@@ -36,7 +47,7 @@ add_executable(cpp_global_test
|
||||
${COMMON_FILE_LIST}
|
||||
)
|
||||
target_include_directories(cpp_global_test PRIVATE include)
|
||||
target_link_libraries(cpp_global_test PRIVATE gtest fff)
|
||||
target_link_libraries(cpp_global_test PRIVATE GTest::gtest_main fff)
|
||||
|
||||
# Create the C++ custom function signature executable
|
||||
add_executable(cpp_custom_fn_signature_test
|
||||
@@ -44,7 +55,7 @@ add_executable(cpp_custom_fn_signature_test
|
||||
${COMMON_FILE_LIST}
|
||||
)
|
||||
target_include_directories(cpp_custom_fn_signature_test PRIVATE include)
|
||||
target_link_libraries(cpp_custom_fn_signature_test PRIVATE gtest fff)
|
||||
target_link_libraries(cpp_custom_fn_signature_test PRIVATE GTest::gtest_main fff)
|
||||
# Due to a bug in WinLibs for Windows it's not currently possible to use:
|
||||
# target_precompile_headers(cpp_custom_fn_signature_test PUBLIC include/custom_function.hpp)
|
||||
# See more info at target_precompile_headers(cpp_custom_fn_signature_test PUBLIC include/custom_function.hpp)
|
||||
|
||||
Reference in New Issue
Block a user