kou commented on a change in pull request #10614:
URL: https://github.com/apache/arrow/pull/10614#discussion_r660945071



##########
File path: matlab/CMakeLists.txt
##########
@@ -72,3 +89,28 @@ else()
   set_target_properties(featherwritemex PROPERTIES LIBRARY_OUTPUT_DIRECTORY
                                                    
$<1:${CMAKE_SOURCE_DIR}/src>)
 endif()
+
+# ######################
+# GoogleTest Integration
+# ######################
+# If the user has specified a GTEST_ROOT value, use their pre-built GoogleTest 
binaries.
+# Otherwise, download and build GoogleTest automatically.
+if(GTEST_ROOT)
+  find_package(GTest REQUIRED)
+else()
+  download_and_build_google_test()

Review comment:
       OK.
   How about referring GoogleTest bundled in Apache Arrow C++ instead of adding 
this functionality to the MATLAB library?
   If we build bundled GoogleTest in Apache Arrow C++, it's installed into 
`${ARROW_BUILD_DIR}/googletest_ep-prefix/{include,lib}/`. We can find it with 
`find_package(GTest REQUIRED CONFIG)` and 
`-DGTest_ROOT=${ARROW_BUILD_DIR}/googletest_ep-prefix`.
   And `find_package(GTest REQUIED COFNIG)` without `-DGTest_ROOT` will find 
GoogleTest installed into system by package manager.
    

##########
File path: matlab/CMakeLists.txt
##########
@@ -17,6 +17,23 @@
 
 cmake_minimum_required(VERSION 3.20)
 
+# This function uses the ThirdpartyToolchain CMake module
+# in cpp/cmake_modules to automatically download and build GoogleTest.
+function(download_and_build_google_test)
+  # The ExternalProject module is required for downloading and building 
external dependencies.
+  include(ExternalProject)
+  # The ThirdpartyToolchain module automatically builds xsimd by default,
+  # so we explicitly disable building of xsimd here.
+  set(ARROW_SIMD_LEVEL "NONE")
+  set(ARROW_RUNTIME_SIMD_LEVEL "NONE")
+  # The ThirdpartyToolchain module must know the location of the Arrow C++ 
libraries source code.
+  set(arrow_SOURCE_DIR ${CMAKE_SOURCE_DIR}/../cpp)
+  # The ThirdpartyToolchain module uses ExternalProject to download GoogleTest.
+  include(ThirdpartyToolchain)

Review comment:
       `ThirdpartyToolchain` has many Apache Arrow C++ specific configurations 
like `configure_file()` you changed.
   So you need to set some `ARROW_*` variables to `include` 
`ThirdpartyToolchain`.
   
   If we want to reuse `ThirdpartyToolchain` in the MATLAB library, we should 
make `ThirdpartyToolchain` reusable and reuse rather than `set` some variables 
and `include`.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to