Commit 04b67368 authored by Andrii Senkovych's avatar Andrii Senkovych

Introduce option to select default gtest installation. Refs #309

This will introduce RAPIDJSON_BUILD_THIRDPARTY_GTEST option. If it is set to
TRUE, cmake will look for GTest installation in `thirdparty/gtest` before
looking in other places.

Current default value (OFF) for RAPIDJSON_BUILD_THIRDPARTY_GTEST represents
previous behaviour when system-wide gtest installation is used whenever
possible.

This commit will as well eliminate problem described in #309 when source
directory found is `thirdparty/gtest` while include files are found
system-wide. This however won't give the user possibility to select gtest
installation to use.
parent 8d39282a
......@@ -17,6 +17,8 @@ SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
option(RAPIDJSON_BUILD_DOC "Build rapidjson documentation." ON)
option(RAPIDJSON_BUILD_EXAMPLES "Build rapidjson examples." ON)
option(RAPIDJSON_BUILD_TESTS "Build rapidjson perftests and unittests." ON)
option(RAPIDJSON_BUILD_THIRDPARTY_GTEST
"Use gtest installation in `thirdparty/gtest` by default if available" OFF)
option(RAPIDJSON_HAS_STDSTRING "" OFF)
if(RAPIDJSON_HAS_STDSTRING)
......
SET(GTEST_SEARCH_PATH
"${GTEST_SOURCE_DIR}"
"${CMAKE_SOURCE_DIR}/thirdparty/gtest")
IF(UNIX)
LIST(INSERT GTEST_SEARCH_PATH 1 "/usr/src/gtest")
IF(RAPIDJSON_BUILD_THIRDPARTY_GTEST)
LIST(APPEND GTEST_SEARCH_PATH "/usr/src/gtest")
ELSE()
LIST(INSERT GTEST_SEARCH_PATH 1 "/usr/src/gtest")
ENDIF()
ENDIF()
FIND_PATH(GTEST_SOURCE_DIR
......@@ -15,6 +20,7 @@ FIND_PATH(GTEST_SOURCE_DIR
FIND_PATH(GTEST_INCLUDE_DIR
NAMES gtest/gtest.h
PATH_SUFFIXES include
HINTS ${GTEST_SOURCE_DIR}
PATHS ${GTEST_SEARCH_PATH})
INCLUDE(FindPackageHandleStandardArgs)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment