From 5221e1854846ac31dd2ada44fb29dc705104e851 Mon Sep 17 00:00:00 2001 From: Peter Pettersson Date: Sat, 2 Oct 2021 23:54:14 +0200 Subject: Add target for testing libgit2 headers --- tests/CMakeLists.txt | 14 +++++++++++++- tests/headertest.c | 13 +++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 tests/headertest.c diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 072470350..d42c6ad5b 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -51,7 +51,7 @@ ide_split_sources(libgit2_tests) # this on newer compilers to avoid unnecessary recompilation. # if(CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0) - add_definitions(-include \"clar_suite.h\") + target_compile_options(libgit2_tests PRIVATE -include "clar_suite.h") endif() if(MSVC_IDE) @@ -79,3 +79,15 @@ add_clar_test(ssh -v -sonline::push -sonline::clone::ssh_cert -s add_clar_test(proxy -v -sonline::clone::proxy) add_clar_test(auth_clone -v -sonline::clone::cred) add_clar_test(auth_clone_and_push -v -sonline::clone::push -sonline::push) + +# Header file validation project +add_executable(headertest headertest.c) +set_target_properties(headertest PROPERTIES C_STANDARD 90) +set_target_properties(headertest PROPERTIES C_EXTENSIONS OFF) +target_include_directories(headertest PRIVATE ${LIBGIT2_INCLUDES}) + +if (MSVC) + target_compile_options(headertest PUBLIC /W4 /WX) +else() + target_compile_options(headertest PUBLIC -Wall -Wextra -pedantic -Werror) +endif() diff --git a/tests/headertest.c b/tests/headertest.c new file mode 100644 index 000000000..2af8a14ec --- /dev/null +++ b/tests/headertest.c @@ -0,0 +1,13 @@ +/* + * Dummy project to validate header files + * + * This project is not intended to be executed, it should only include all + * header files to make sure that they can be used with stricter compiler + * settings than the libgit2 source files generally supports. + */ +#include "git2.h" + +int main(void) +{ + return 0; +} -- cgit v1.2.1