Skip to content

Commit d1da227

Browse files
cdluminatesparkprime
authored andcommitted
CMake: Add USE_SYSTEM_GTEST option (default to OFF).
1 parent b5b0461 commit d1da227

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ include(ExternalProject)
55
# User-configurable options.
66
option(BUILD_JSONNET "Build jsonnet command-line tool." ON)
77
option(BUILD_TESTS "Build and run jsonnet tests." ON)
8+
option(USE_SYSTEM_GTEST "Use system-provided gtest library" OFF)
89
set(GLOBAL_OUTPUT_PATH_SUFFIX "" CACHE STRING
910
"Output artifacts directory.")
1011

@@ -33,7 +34,7 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${GLOBAL_OUTPUT_PATH})
3334
# known locations on the local machine. Downloading the library ourselves
3435
# allows us to pin to a specific version and makes things easier for users
3536
# who don't have package managers.
36-
if (BUILD_TESTS)
37+
if (BUILD_TESTS AND NOT USE_SYSTEM_GTEST)
3738
enable_testing()
3839

3940
# Generate and download googletest project.
@@ -66,6 +67,10 @@ if (BUILD_TESTS)
6667

6768
# Include googletest headers.
6869
include_directories("${gtest_SOURCE_DIR}/include")
70+
71+
elseif (BUILD_TESTS AND USE_SYSTEM_GTEST)
72+
enable_testing()
73+
add_subdirectory(/usr/src/googletest ${GLOBAL_OUTPUT_PATH}/googletest-build)
6974
endif()
7075

7176
# Compiler flags.

0 commit comments

Comments
 (0)