Skip to content

Commit 906af5b

Browse files
zhztheplayerfacebook-github-bot
authored andcommitted
build(cmake): Change FetchContent name of gtest to googletest as gtest_SOURCE_DIR is used internally by googletest (facebookincubator#12430)
Summary: Project name `gtest` is [used internally](https://github.com/google/googletest/blob/3fbe4db9a39291ae8d7a9c5f1d75896bb4c5a18f/googletest/CMakeLists.txt#L50) for `googletest/googletest` in googletest's source code Currently Velox imports gtest by `FetchContent_Declare(gtest)`, which means `gtest_SOURCE_DIR` will overwrite the one defined by googletest itself from `googletest/googletest` to `googletest`. This would lead to weird issues when using bundled googletest. For example in [velox4j](https://github.com/velox4j/velox4j) when importing velox's source code, the following error will be caused: ``` CMake Error: File /opt/velox4j/src/main/cpp/cmake-build-debug/_deps/gtest-src/cmake/Config.cmake.in does not exist. CMake Error at /opt/cmake/share/cmake-3.29/Modules/CMakePackageConfigHelpers.cmake:482 (configure_file): configure_file Problem configuring file Call Stack (most recent call first): cmake-build-debug/_deps/gtest-src/googletest/CMakeLists.txt:106 (configure_package_config_file) ``` The patch fixes the issue by simply changing `FetchContent_Declare(gtest` to `FetchContent_Declare(googletest` so there is no chance that the project names collide. See also a similar issue: google/googletest#2457. Pull Request resolved: facebookincubator#12430 Reviewed By: kKPulla Differential Revision: D70038120 Pulled By: mbasmanova fbshipit-source-id: d7f5a7441335ae30e01e0269cd4265a57dcb4df0
1 parent eb3cc2d commit 906af5b

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

CMake/resolve_dependency_modules/gtest.cmake

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ velox_resolve_dependency_url(GTEST)
2424

2525
message(STATUS "Building gtest from source")
2626
FetchContent_Declare(
27-
gtest
27+
googletest
2828
URL ${VELOX_GTEST_SOURCE_URL}
2929
URL_HASH ${VELOX_GTEST_BUILD_SHA256_CHECKSUM}
3030
OVERRIDE_FIND_PACKAGE SYSTEM EXCLUDE_FROM_ALL)
3131

32-
FetchContent_MakeAvailable(gtest)
32+
FetchContent_MakeAvailable(googletest)
3333

3434
# Mask compilation warning in clang 16.
3535
target_compile_options(gtest PRIVATE -Wno-implicit-int-float-conversion)

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ if(NOT VELOX_DISABLE_GOOGLETEST)
594594
velox_set_source(GTest)
595595
velox_resolve_dependency(GTest)
596596
set(VELOX_GTEST_INCUDE_DIR
597-
"${gtest_SOURCE_DIR}/googletest/include"
597+
"${gtest_SOURCE_DIR}/include"
598598
PARENT_SCOPE)
599599
endif()
600600

0 commit comments

Comments
 (0)