Skip to content

Commit 3267115

Browse files
committed
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.
1 parent caab827 commit 3267115

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,10 @@ IF (BUILD_CLAR)
693693
FILE(GLOB_RECURSE SRC_TEST ${CLAR_PATH}/*/*.c ${CLAR_PATH}/*/*.h)
694694
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")
695695

696+
IF(MSVC_IDE)
697+
LIST(APPEND SRC_CLAR "${CLAR_PATH}/precompiled.c")
698+
ENDIF()
699+
696700
ADD_CUSTOM_COMMAND(
697701
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/clar.suite
698702
COMMAND ${PYTHON_EXECUTABLE} generate.py -o "${CMAKE_CURRENT_BINARY_DIR}" -f -xonline -xstress .
@@ -723,6 +727,7 @@ IF (BUILD_CLAR)
723727
IF (MSVC_IDE)
724728
# Precompiled headers
725729
SET_TARGET_PROPERTIES(libgit2_clar PROPERTIES COMPILE_FLAGS "/Yuprecompiled.h /FIprecompiled.h")
730+
SET_SOURCE_FILES_PROPERTIES("${CLAR_PATH}/tests/precompiled.c" COMPILE_FLAGS "/Ycprecompiled.h")
726731
ENDIF ()
727732

728733
ENABLE_TESTING()

tests/precompiled.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include "precompiled.h"

tests/precompiled.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#include "common.h"
2+
#include "git2.h"
3+
#include "clar.h"
4+
#include "clar_libgit2.h"

0 commit comments

Comments
 (0)