Commit 3267115fc2f5f69384cc569dcb3a28aadd8305f7

Patrick Steinhardt 2017-06-28T15:41:15

cmake: create own precompiled headers for tests As soon as we split up our CMakeBuild.txt build instructions, we will be unable to simply link against the git2 library's precompiled header from other targets. To avoid this future breakage, create a new precompiled header for our test suite. Next to being compatible with the split, this enables us to also include additional files like the clar headers, which may help speeding up compilation of the test suite.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 54809e1..5224496 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -693,6 +693,10 @@ IF (BUILD_CLAR)
 	FILE(GLOB_RECURSE SRC_TEST ${CLAR_PATH}/*/*.c ${CLAR_PATH}/*/*.h)
 	SET(SRC_CLAR "${CLAR_PATH}/main.c" "${CLAR_PATH}/clar_libgit2.c" "${CLAR_PATH}/clar_libgit2_trace.c" "${CLAR_PATH}/clar_libgit2_timer.c" "${CLAR_PATH}/clar.c")
 
+	IF(MSVC_IDE)
+		LIST(APPEND SRC_CLAR "${CLAR_PATH}/precompiled.c")
+	ENDIF()
+
 	ADD_CUSTOM_COMMAND(
 		OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/clar.suite
 		COMMAND ${PYTHON_EXECUTABLE} generate.py -o "${CMAKE_CURRENT_BINARY_DIR}" -f -xonline -xstress .
@@ -723,6 +727,7 @@ IF (BUILD_CLAR)
 	IF (MSVC_IDE)
 		# Precompiled headers
 		SET_TARGET_PROPERTIES(libgit2_clar PROPERTIES COMPILE_FLAGS "/Yuprecompiled.h /FIprecompiled.h")
+		SET_SOURCE_FILES_PROPERTIES("${CLAR_PATH}/tests/precompiled.c" COMPILE_FLAGS "/Ycprecompiled.h")
 	ENDIF ()
 
 	ENABLE_TESTING()
diff --git a/tests/precompiled.c b/tests/precompiled.c
new file mode 100644
index 0000000..5f656a4
--- /dev/null
+++ b/tests/precompiled.c
@@ -0,0 +1 @@
+#include "precompiled.h"
diff --git a/tests/precompiled.h b/tests/precompiled.h
new file mode 100644
index 0000000..ea53a60
--- /dev/null
+++ b/tests/precompiled.h
@@ -0,0 +1,4 @@
+#include "common.h"
+#include "git2.h"
+#include "clar.h"
+#include "clar_libgit2.h"