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.
This commit is contained in:
Patrick Steinhardt
2017-06-28 15:41:15 +02:00
parent caab8270a5
commit 3267115fc2
3 changed files with 10 additions and 0 deletions

View File

@@ -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()

1
tests/precompiled.c Normal file
View File

@@ -0,0 +1 @@
#include "precompiled.h"

4
tests/precompiled.h Normal file
View File

@@ -0,0 +1,4 @@
#include "common.h"
#include "git2.h"
#include "clar.h"
#include "clar_libgit2.h"