lafiona commented on a change in pull request #12004:
URL: https://github.com/apache/arrow/pull/12004#discussion_r774208166



##########
File path: matlab/CMakeLists.txt
##########
@@ -212,56 +233,113 @@ if(MATLAB_BUILD_TESTS)
     # C++ libraries that are built from source.
     build_arrow(BUILD_GTEST)
   else()
+    # GTest is found, on Windows, IMPORTED_LOCATION needs to be set to 
indicate where the shared
+    # libraries live
+    if(WIN32)
+      set(GTEST_SHARED_LIB_DIR "${GTEST_ROOT}/bin")
+      set(GTEST_SHARED_LIBRARY_FILENAME
+          "${CMAKE_SHARED_LIBRARY_PREFIX}gtest${CMAKE_SHARED_LIBRARY_SUFFIX}")
+      set(GTEST_SHARED_LIBRARY_LIB
+          "${GTEST_SHARED_LIB_DIR}/${GTEST_SHARED_LIBRARY_FILENAME}")
+
+      set(GTEST_MAIN_SHARED_LIB_DIR "${GTEST_ROOT}/bin")
+      set(GTEST_MAIN_SHARED_LIBRARY_FILENAME
+          
"${CMAKE_SHARED_LIBRARY_PREFIX}gtest_main${CMAKE_SHARED_LIBRARY_SUFFIX}")
+      set(GTEST_MAIN_SHARED_LIBRARY_LIB
+          "${GTEST_MAIN_SHARED_LIB_DIR}/${GTEST_MAIN_SHARED_LIBRARY_FILENAME}")
+
+      set_target_properties(GTest::gtest PROPERTIES IMPORTED_LOCATION
+                                                    
"${GTEST_SHARED_LIBRARY_LIB}")
+
+      set_target_properties(GTest::gtest_main
+                            PROPERTIES IMPORTED_LOCATION
+                                       "${GTEST_MAIN_SHARED_LIBRARY_LIB}")
+    endif()
+
     find_package(Arrow)
     if(NOT Arrow_FOUND)
       # Trigger an automatic build of the Arrow C++ libraries.
       build_arrow()
     endif()
   endif()
+
 else()
   find_package(Arrow)
   if(NOT Arrow_FOUND)
     build_arrow()
   endif()
 endif()
 
+# On Windows: copy arrow.dll into the directory where the MATLAB C++ tests 
reside,
+# since Windows require runtime DLLs that are depended on by executables to be 
in
+# the same directory (or on the %PATH%).
+if(WIN32)
+  get_property(ARROW_SHARED_LIB
+               TARGET arrow_shared
+               PROPERTY IMPORTED_LOCATION)
+
+  add_custom_target(copy_arrow_to_build_output_dir ALL
+                    COMMAND ${CMAKE_COMMAND} -E make_directory 
${MATLAB_BUILD_OUTPUT_DIR}
+                    COMMAND ${CMAKE_COMMAND} -E copy_if_different 
${ARROW_SHARED_LIB}
+                            ${MATLAB_BUILD_OUTPUT_DIR}
+                    COMMENT "Start copying arrow.dll from ${ARROW_SHARED_LIB} 
to ${MATLAB_BUILD_OUTPUT_DIR}"
+  )

Review comment:
       Thanks @kou, I've updated the description to reflect the changes that I 
made in response to your feedback. 
   
   `arrow.dll` is not only used by the tests. On Windows, it needs to be copied 
to the location of `arrow_matlab.dll` and the MEX function, `mexfcn.mexw64`, so 
that they can access the Arrow APIs. 




-- 
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