summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2021-11-11 16:53:33 -0500
committerEdward Thomson <ethomson@edwardthomson.com>2021-11-11 17:11:24 -0500
commit49f03c0305d89e4bcee6c12af956381f70e14753 (patch)
tree826989e241f22b24f82e8332ce93a299025c8f08
parentcf522050bf904c0de92d5a0fc75f50db412ed59d (diff)
downloadlibgit2-49f03c0305d89e4bcee6c12af956381f70e14753.tar.gz
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.
-rw-r--r--tests/CMakeLists.txt10
1 files changed, 9 insertions, 1 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 760925fcf..e109913ff 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -25,7 +25,7 @@ if(MSVC_IDE)
endif()
add_custom_command(
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/clar.suite
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/clar.suite ${CMAKE_CURRENT_BINARY_DIR}/clar_suite.h
COMMAND ${PYTHON_EXECUTABLE} generate.py -o "${CMAKE_CURRENT_BINARY_DIR}" -f -xonline -xstress -xperf .
DEPENDS ${SRC_TEST}
WORKING_DIRECTORY ${CLAR_PATH}
@@ -48,6 +48,14 @@ target_include_directories(libgit2_tests PRIVATE ../src PUBLIC ../include)
target_link_libraries(libgit2_tests ${LIBGIT2_LIBS})
ide_split_sources(libgit2_tests)
+#
+# Old versions of gcc require us to declare our test functions; don't do
+# 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\")
+endif()
+
if(MSVC_IDE)
# Precompiled headers
set_target_properties(libgit2_tests PROPERTIES COMPILE_FLAGS "/Yuprecompiled.h /FIprecompiled.h")