lafiona commented on a change in pull request #12004:
URL: https://github.com/apache/arrow/pull/12004#discussion_r796124859
##########
File path: matlab/CMakeLists.txt
##########
@@ -273,10 +328,209 @@ if(MATLAB_BUILD_TESTS)
# Define a test executable target. TODO: Remove the placeholder test. This is
# just for testing GoogleTest integration.
add_executable(placeholder_test ${CMAKE_SOURCE_DIR}/src/placeholder_test.cc)
+ add_executable(mex_util_test
${CPP_SOURCE_DIR}/arrow/matlab/mex/mex_util_test.cc)
+
# Declare a dependency on the GTest::gtest and GTest::gtest_main IMPORTED
# targets.
target_link_libraries(placeholder_test GTest::gtest GTest::gtest_main)
- # Add a test target.
+ # Declare a dependency on the GTest::gtest and GTest::gtest_main IMPORTED
+ # targets.
+ target_link_libraries(mex_util_test GTest::gtest GTest::gtest_main)
+ target_link_libraries(mex_util_test arrow_matlab)
+
+ # Include the MATLAB MEX headers.
+ target_include_directories(mex_util_test PRIVATE ${Matlab_INCLUDE_DIRS})
+ # Include the C++ source headers.
+ target_include_directories(mex_util_test PRIVATE ${CPP_SOURCE_DIR})
+
+ # Add test targets for C++ tests.
add_test(PlaceholderTestTarget placeholder_test)
+ add_test(CheckNumArgsTestTarget mex_util_test)
+
+ # On macOS, add the directory of libarrow.dylib to the $DYLD_LIBRARY_PATH for
+ # running CheckNumArgsTestTarget.
+ if(APPLE)
+ get_target_property(ARROW_SHARED_LIB arrow_shared IMPORTED_LOCATION)
+ get_filename_component(ARROW_SHARED_LIB_DIR ${ARROW_SHARED_LIB} DIRECTORY)
+
+ set_tests_properties(CheckNumArgsTestTarget
+ PROPERTIES ENVIRONMENT
+
"DYLD_LIBRARY_PATH=${ARROW_SHARED_LIB_DIR}")
+ endif()
+
+ # On Windows:
+ # Add the directory of gtest.dll and gtest_main.dll to the %PATH% for running
+ # all tests.
+ # Add the directory of libmx.dll, libmex.dll, and libarrow.dll to the %PATH%
for running
+ # CheckNumArgsTestTarget.
+ # Note: When appending to the path using set_test_properties' ENVIRONMENT
property,
+ # make sure that we escape ';' to prevent CMake from interpreting the
input as
+ # a list of strings.
+ if(WIN32)
+ get_target_property(GTEST_SHARED_LIB GTest::gtest IMPORTED_LOCATION)
+ get_filename_component(GTEST_SHARED_LIB_DIR ${GTEST_SHARED_LIB} DIRECTORY)
+
+ get_target_property(GTEST_MAIN_SHARED_LIB GTest::gtest_main
IMPORTED_LOCATION)
+ get_filename_component(GTEST_MAIN_SHARED_LIB_DIR ${GTEST_MAIN_SHARED_LIB}
DIRECTORY)
+
+ set_tests_properties(PlaceholderTestTarget
+ PROPERTIES ENVIRONMENT
+
"PATH=${GTEST_SHARED_LIB_DIR}\;${GTEST_MAIN_SHARED_LIB_DIR}\;$ENV{PATH}"
+ )
+
+ get_target_property(ARROW_SHARED_LIB arrow_shared IMPORTED_LOCATION)
+ get_filename_component(ARROW_SHARED_LIB_DIR ${ARROW_SHARED_LIB} DIRECTORY)
+
+ set(MATLAB_DLL_DEPENDENCIES_DIR "${Matlab_ROOT_DIR}/bin/win64")
+
+ set_tests_properties(CheckNumArgsTestTarget
+ PROPERTIES ENVIRONMENT
+
"PATH=${ARROW_SHARED_LIB_DIR}\;${MATLAB_DLL_DEPENDENCIES_DIR}\;${GTEST_SHARED_LIB_DIR}\;${GTEST_MAIN_SHARED_LIB_DIR}\;$ENV{PATH}"
+ )
+ endif()
+endif()
+
+#
##############################################################################
+# Install
+#
##############################################################################
+# Create a subdirectory at CMAKE_INSTALL_PREFIX to install the interface.
+set(CMAKE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/arrow_matlab")
+
+# Install MATLAB source files.
+if(APPLE)
+ # On macOS, exclude '.DS_Store' files in the source tree from installation.
+ install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/matlab/"
+ DESTINATION ${CMAKE_INSTALL_DIR}
+ PATTERN ".DS_Store" EXCLUDE)
+else()
+ install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/matlab/" DESTINATION
${CMAKE_INSTALL_DIR})
+endif()
+
+# Install arrow_matlab and mexfcn.
+if(WIN32)
+ install(TARGETS arrow_matlab mexfcn RUNTIME DESTINATION ${CMAKE_INSTALL_DIR})
+else()
+ # On Linux install arrow_matlab.so and on macOS install arrow_matlab.dylib
+ # using the LIBRARY keyword.
+ install(TARGETS arrow_matlab mexfcn LIBRARY DESTINATION ${CMAKE_INSTALL_DIR})
+endif()
Review comment:
This makes sense to me! I've accepted your suggestion to simplify this
logic into one line of code.
--
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]