You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ko...@apache.org on 2023/04/21 00:03:53 UTC
[arrow] branch main updated: GH-35252: [C++] Use FindGTestAlt.cmake by ArrowTesting (#35253)
This is an automated email from the ASF dual-hosted git repository.
kou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new 388f3a88c6 GH-35252: [C++] Use FindGTestAlt.cmake by ArrowTesting (#35253)
388f3a88c6 is described below
commit 388f3a88c64750b3db77c5ca044ceae750e8db85
Author: Sutou Kouhei <ko...@clear-code.com>
AuthorDate: Fri Apr 21 09:03:40 2023 +0900
GH-35252: [C++] Use FindGTestAlt.cmake by ArrowTesting (#35253)
### Rationale for this change
`find_package(Arrow)` is failed when a project doesn't set `CMAKE_CXX_STANDARD`.
### What changes are included in this PR?
* `find_package(Arrow)` doesn't need to use `FindGTestAlt.cmake`. `find_package(ArrowTesting)` needs it.
* `FindGTestAlt.cmake` doesn't need to run availability check when it's called from `find_package(ArrowTesting)`. Because it's already done when Apache Arrow C++ is built.
### Are these changes tested?
Yes.
### Are there any user-facing changes?
Yes.
* Closes: #35252
Authored-by: Sutou Kouhei <ko...@clear-code.com>
Signed-off-by: Sutou Kouhei <ko...@clear-code.com>
---
cpp/cmake_modules/FindGTestAlt.cmake | 2 +-
cpp/cmake_modules/ThirdpartyToolchain.cmake | 17 ++++++++++++++---
cpp/src/arrow/ArrowTestingConfig.cmake.in | 18 ++++++++++++++++++
cpp/src/arrow/CMakeLists.txt | 10 ++++++++--
4 files changed, 41 insertions(+), 6 deletions(-)
diff --git a/cpp/cmake_modules/FindGTestAlt.cmake b/cpp/cmake_modules/FindGTestAlt.cmake
index 86aa262641..77d4f39d9e 100644
--- a/cpp/cmake_modules/FindGTestAlt.cmake
+++ b/cpp/cmake_modules/FindGTestAlt.cmake
@@ -36,7 +36,7 @@ endif()
find_package(GTest ${find_package_args})
set(GTestAlt_FOUND ${GTest_FOUND})
-if(GTestAlt_FOUND)
+if(GTestAlt_FOUND AND GTestAlt_NEED_CXX_STANDARD_CHECK)
set(KEEP_CMAKE_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE})
set(CMAKE_TRY_COMPILE_TARGET_TYPE EXECUTABLE)
set(GTestAlt_CXX_STANDARD_TEST_SOURCE
diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake
index 8bd02a8672..b5f9716722 100644
--- a/cpp/cmake_modules/ThirdpartyToolchain.cmake
+++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake
@@ -229,6 +229,7 @@ endmacro()
macro(resolve_dependency DEPENDENCY_NAME)
set(options)
set(one_value_args
+ ARROW_CMAKE_PACKAGE_NAME
FORCE_ANY_NEWER_VERSION
HAVE_ALT
IS_RUNTIME_DEPENDENCY
@@ -290,8 +291,15 @@ macro(resolve_dependency DEPENDENCY_NAME)
endif()
endif()
if(${DEPENDENCY_NAME}_SOURCE STREQUAL "SYSTEM" AND ARG_IS_RUNTIME_DEPENDENCY)
- provide_find_module(${PACKAGE_NAME} "Arrow")
- list(APPEND ARROW_SYSTEM_DEPENDENCIES ${PACKAGE_NAME})
+ if(NOT ARG_ARROW_CMAKE_PACKAGE_NAME)
+ set(ARG_ARROW_CMAKE_PACKAGE_NAME "Arrow")
+ endif()
+ if(ARG_ARROW_CMAKE_PACKAGE_NAME STREQUAL "Arrow")
+ provide_find_module(${PACKAGE_NAME} "Arrow")
+ list(APPEND ARROW_SYSTEM_DEPENDENCIES ${PACKAGE_NAME})
+ else()
+ provide_find_module(${PACKAGE_NAME} ${ARG_ARROW_CMAKE_PACKAGE_NAME})
+ endif()
if(ARROW_BUILD_STATIC)
find_package(PkgConfig QUIET)
foreach(ARG_PC_PACKAGE_NAME ${ARG_PC_PACKAGE_NAMES})
@@ -2220,11 +2228,14 @@ macro(build_gtest)
endmacro()
if(ARROW_TESTING)
+ set(GTestAlt_NEED_CXX_STANDARD_CHECK TRUE)
resolve_dependency(GTest
HAVE_ALT
TRUE
REQUIRED_VERSION
- 1.10.0)
+ 1.10.0
+ ARROW_CMAKE_PACKAGE_NAME
+ "ArrowTesting")
if(GTest_SOURCE STREQUAL "SYSTEM")
find_package(PkgConfig QUIET)
diff --git a/cpp/src/arrow/ArrowTestingConfig.cmake.in b/cpp/src/arrow/ArrowTestingConfig.cmake.in
index 87ee9e755e..b65f6ef0d5 100644
--- a/cpp/src/arrow/ArrowTestingConfig.cmake.in
+++ b/cpp/src/arrow/ArrowTestingConfig.cmake.in
@@ -26,9 +26,27 @@
@PACKAGE_INIT@
+set(ARROW_GTEST_SOURCE "@GTest_SOURCE@")
+
include(CMakeFindDependencyMacro)
find_dependency(Arrow)
+if(DEFINED CMAKE_MODULE_PATH)
+ set(ARROW_TESTING_CMAKE_MODULE_PATH_OLD ${CMAKE_MODULE_PATH})
+else()
+ unset(ARROW_TESTING_CMAKE_MODULE_PATH_OLD)
+endif()
+set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
+if("${ARROW_GTEST_SOURCE}" STREQUAL "SYSTEM")
+ find_dependency(GTestAlt)
+endif()
+if(DEFINED ARROW_TESTING_CMAKE_MODULE_PATH_OLD)
+ set(CMAKE_MODULE_PATH ${ARROW_TESTING_CMAKE_MODULE_PATH_OLD})
+ unset(ARROW_TESTING_CMAKE_MODULE_PATH_OLD)
+else()
+ unset(CMAKE_MODULE_PATH)
+endif()
+
include("${CMAKE_CURRENT_LIST_DIR}/ArrowTestingTargets.cmake")
arrow_keep_backward_compatibility(ArrowTesting arrow_testing)
diff --git a/cpp/src/arrow/CMakeLists.txt b/cpp/src/arrow/CMakeLists.txt
index f1430bb697..32c9b9354e 100644
--- a/cpp/src/arrow/CMakeLists.txt
+++ b/cpp/src/arrow/CMakeLists.txt
@@ -703,6 +703,12 @@ endif()
if(ARROW_TESTING)
# that depend on gtest
+ set(ARROW_TESTING_SHARED_INSTALL_INTERFACE_LIBS Arrow::arrow_shared)
+ set(ARROW_TESTING_STATIC_INSTALL_INTERFACE_LIBS Arrow::arrow_static)
+ if(GTest_SOURCE STREQUAL "SYSTEM")
+ list(APPEND ARROW_TESTING_SHARED_INSTALL_INTERFACE_LIBS ${ARROW_GTEST_GTEST})
+ list(APPEND ARROW_TESTING_STATIC_INSTALL_INTERFACE_LIBS ${ARROW_GTEST_GTEST})
+ endif()
add_arrow_lib(arrow_testing
CMAKE_PACKAGE_NAME
ArrowTesting
@@ -722,14 +728,14 @@ if(ARROW_TESTING)
arrow_shared
${ARROW_GTEST_GTEST}
SHARED_INSTALL_INTERFACE_LIBS
- Arrow::arrow_shared
+ ${ARROW_TESTING_SHARED_INSTALL_INTERFACE_LIBS}
STATIC_LINK_LIBS
arrow::flatbuffers
rapidjson::rapidjson
arrow_static
${ARROW_GTEST_GTEST}
STATIC_INSTALL_INTERFACE_LIBS
- Arrow::arrow_static)
+ ${ARROW_TESTING_STATIC_INSTALL_INTERFACE_LIBS})
add_custom_target(arrow_testing)
add_dependencies(arrow_testing ${ARROW_TESTING_LIBRARIES})