Skip to content

Commit 5221e18

Browse files
committed
Add target for testing libgit2 headers
1 parent 23c5c31 commit 5221e18

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

tests/CMakeLists.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ ide_split_sources(libgit2_tests)
5151
# this on newer compilers to avoid unnecessary recompilation.
5252
#
5353
if(CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)
54-
add_definitions(-include \"clar_suite.h\")
54+
target_compile_options(libgit2_tests PRIVATE -include "clar_suite.h")
5555
endif()
5656

5757
if(MSVC_IDE)
@@ -79,3 +79,15 @@ add_clar_test(ssh -v -sonline::push -sonline::clone::ssh_cert -s
7979
add_clar_test(proxy -v -sonline::clone::proxy)
8080
add_clar_test(auth_clone -v -sonline::clone::cred)
8181
add_clar_test(auth_clone_and_push -v -sonline::clone::push -sonline::push)
82+
83+
# Header file validation project
84+
add_executable(headertest headertest.c)
85+
set_target_properties(headertest PROPERTIES C_STANDARD 90)
86+
set_target_properties(headertest PROPERTIES C_EXTENSIONS OFF)
87+
target_include_directories(headertest PRIVATE ${LIBGIT2_INCLUDES})
88+
89+
if (MSVC)
90+
target_compile_options(headertest PUBLIC /W4 /WX)
91+
else()
92+
target_compile_options(headertest PUBLIC -Wall -Wextra -pedantic -Werror)
93+
endif()

tests/headertest.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Dummy project to validate header files
3+
*
4+
* This project is not intended to be executed, it should only include all
5+
* header files to make sure that they can be used with stricter compiler
6+
* settings than the libgit2 source files generally supports.
7+
*/
8+
#include "git2.h"
9+
10+
int main(void)
11+
{
12+
return 0;
13+
}

0 commit comments

Comments
 (0)