Commit c3d09b78 authored by Laurent Stacul's avatar Laurent Stacul Committed by Facebook Github Bot

Cannot build tests if Gtest not configured by CMake (#1331)

Summary:
When Gtest cannot be discovered by CMake config file, the tests fails to compile:
```
In file included from /home/docker/opensource/folly/folly/test/common/TestMain.cpp:23:
/home/docker/opensource/folly/folly/portability/GTest.h:32:10: fatal error: gtest/gtest.h: No such file or directory
   32 | #include <gtest/gtest.h>
      |          ^~~~~~~~~~~~~~~
```
This PR fixes this problem with a classic `find_package`.
Pull Request resolved: https://github.com/facebook/folly/pull/1331

Differential Revision: D20323404

Pulled By: yfeldblum

fbshipit-source-id: 2e41f99172c504063c00c45a9fa5c08a26bcc0c8
parent 6f3d8f43
...@@ -448,6 +448,7 @@ option(BUILD_SLOW_TESTS "If enabled, compile tests that take a while to run in d ...@@ -448,6 +448,7 @@ option(BUILD_SLOW_TESTS "If enabled, compile tests that take a while to run in d
if (BUILD_TESTS) if (BUILD_TESTS)
option(USE_CMAKE_GOOGLE_TEST_INTEGRATION "If enabled, use the google test integration included in CMake." ON) option(USE_CMAKE_GOOGLE_TEST_INTEGRATION "If enabled, use the google test integration included in CMake." ON)
find_package(GMock MODULE REQUIRED) find_package(GMock MODULE REQUIRED)
find_package(GTest MODULE REQUIRED)
if (USE_CMAKE_GOOGLE_TEST_INTEGRATION) if (USE_CMAKE_GOOGLE_TEST_INTEGRATION)
include(GoogleTest OPTIONAL RESULT_VARIABLE HAVE_CMAKE_GTEST) include(GoogleTest OPTIONAL RESULT_VARIABLE HAVE_CMAKE_GTEST)
enable_testing() enable_testing()
...@@ -512,6 +513,7 @@ if (BUILD_TESTS) ...@@ -512,6 +513,7 @@ if (BUILD_TESTS)
SYSTEM SYSTEM
PUBLIC PUBLIC
${LIBGMOCK_INCLUDE_DIR} ${LIBGMOCK_INCLUDE_DIR}
${GTEST_INCLUDE_DIRS}
) )
target_link_libraries(folly_test_support target_link_libraries(folly_test_support
PUBLIC PUBLIC
......
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