Skip to content

Commit 49f03c0

Browse files
committed
tests: include test declarations for old gcc
Older versions of gcc do not believe that we've adequately declared our test functions. Include `clar_suite.h` conditionally for those old versions. Do not do this on newer compilers to avoid unnecessary recompilation of the entire suite when we add or remove a test function.
1 parent cf52205 commit 49f03c0

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

tests/CMakeLists.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ if(MSVC_IDE)
2525
endif()
2626

2727
add_custom_command(
28-
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/clar.suite
28+
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/clar.suite ${CMAKE_CURRENT_BINARY_DIR}/clar_suite.h
2929
COMMAND ${PYTHON_EXECUTABLE} generate.py -o "${CMAKE_CURRENT_BINARY_DIR}" -f -xonline -xstress -xperf .
3030
DEPENDS ${SRC_TEST}
3131
WORKING_DIRECTORY ${CLAR_PATH}
@@ -48,6 +48,14 @@ target_include_directories(libgit2_tests PRIVATE ../src PUBLIC ../include)
4848
target_link_libraries(libgit2_tests ${LIBGIT2_LIBS})
4949
ide_split_sources(libgit2_tests)
5050

51+
#
52+
# Old versions of gcc require us to declare our test functions; don't do
53+
# this on newer compilers to avoid unnecessary recompilation.
54+
#
55+
if(CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)
56+
add_definitions(-include \"clar_suite.h\")
57+
endif()
58+
5159
if(MSVC_IDE)
5260
# Precompiled headers
5361
set_target_properties(libgit2_tests PROPERTIES COMPILE_FLAGS "/Yuprecompiled.h /FIprecompiled.h")

0 commit comments

Comments
 (0)