You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by we...@apache.org on 2018/08/08 16:36:39 UTC

[arrow] branch master updated: ARROW-2994: [Python] Only include Python and NumPy include directories for libarrow_python targets

This is an automated email from the ASF dual-hosted git repository.

wesm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new 5c97cd6  ARROW-2994: [Python] Only include Python and NumPy include directories for libarrow_python targets
5c97cd6 is described below

commit 5c97cd6bfd447dcc3d8d2b8e6debe6b92b8c1b42
Author: Wes McKinney <we...@apache.org>
AuthorDate: Wed Aug 8 12:36:34 2018 -0400

    ARROW-2994: [Python] Only include Python and NumPy include directories for libarrow_python targets
    
    This should enable CMake to reuse artifacts when switching between Python versions
    
    Author: Wes McKinney <we...@apache.org>
    
    Closes #2380 from wesm/ARROW-2994 and squashes the following commits:
    
    4277bfd1 <Wes McKinney> MSVC does not use the $lib_objlib target
    46fa1975 <Wes McKinney> Fix up CMake commands to work
    65b6aa6b <Wes McKinney> Add extra includes option
---
 cpp/CMakeLists.txt                  |  7 -------
 cpp/cmake_modules/BuildUtils.cmake  | 32 ++++++++++++++++++++++++++++++--
 cpp/src/arrow/python/CMakeLists.txt | 11 +++++++++++
 3 files changed, 41 insertions(+), 9 deletions(-)

diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
index 43215b6..310c191 100644
--- a/cpp/CMakeLists.txt
+++ b/cpp/CMakeLists.txt
@@ -715,12 +715,5 @@ endif()
 add_subdirectory(src/arrow)
 
 if(ARROW_PYTHON)
-  find_package(PythonLibsNew REQUIRED)
-  find_package(NumPy REQUIRED)
-
-  include_directories(SYSTEM
-    ${NUMPY_INCLUDE_DIRS}
-    ${PYTHON_INCLUDE_DIRS})
-
   add_subdirectory(src/arrow/python)
 endif()
diff --git a/cpp/cmake_modules/BuildUtils.cmake b/cpp/cmake_modules/BuildUtils.cmake
index 8255248..f913d20 100644
--- a/cpp/cmake_modules/BuildUtils.cmake
+++ b/cpp/cmake_modules/BuildUtils.cmake
@@ -92,7 +92,7 @@ endfunction()
 function(ADD_ARROW_LIB LIB_NAME)
   set(options)
   set(one_value_args SHARED_LINK_FLAGS)
-  set(multi_value_args SOURCES STATIC_LINK_LIBS STATIC_PRIVATE_LINK_LIBS SHARED_LINK_LIBS SHARED_PRIVATE_LINK_LIBS DEPENDENCIES)
+  set(multi_value_args SOURCES STATIC_LINK_LIBS STATIC_PRIVATE_LINK_LIBS SHARED_LINK_LIBS SHARED_PRIVATE_LINK_LIBS EXTRA_INCLUDES DEPENDENCIES)
   cmake_parse_arguments(ARG "${options}" "${one_value_args}" "${multi_value_args}" ${ARGN})
   if(ARG_UNPARSED_ARGUMENTS)
     message(SEND_ERROR "Error: unrecognized arguments: ${ARG_UNPARSED_ARGUMENTS}")
@@ -101,6 +101,10 @@ function(ADD_ARROW_LIB LIB_NAME)
   if(MSVC)
     set(LIB_DEPS ${ARG_SOURCES})
     set(EXTRA_DEPS ${ARG_DEPENDENCIES})
+
+    if (ARG_EXTRA_INCLUDES)
+      set(LIB_INCLUDES ${ARG_EXTRA_INCLUDES})
+    endif()
   else()
     add_library(${LIB_NAME}_objlib OBJECT
       ${ARG_SOURCES})
@@ -110,7 +114,14 @@ function(ADD_ARROW_LIB LIB_NAME)
       add_dependencies(${LIB_NAME}_objlib ${ARG_DEPENDENCIES})
     endif()
     set(LIB_DEPS $<TARGET_OBJECTS:${LIB_NAME}_objlib>)
+    set(LIB_INCLUDES)
     set(EXTRA_DEPS)
+
+    if (ARG_EXTRA_INCLUDES)
+      target_include_directories(${LIB_NAME}_objlib SYSTEM PUBLIC
+        ${ARG_EXTRA_INCLUDES}
+        )
+    endif()
   endif()
 
   set(RUNTIME_INSTALL_DIR bin)
@@ -121,6 +132,12 @@ function(ADD_ARROW_LIB LIB_NAME)
       add_dependencies(${LIB_NAME}_shared ${EXTRA_DEPS})
     endif()
 
+    if (LIB_INCLUDES)
+      target_include_directories(${LIB_NAME}_shared SYSTEM PUBLIC
+        ${ARG_EXTRA_INCLUDES}
+        )
+    endif()
+
     if(APPLE)
       # On OS X, you can avoid linking at library load time and instead
       # expecting that the symbols have been loaded separately. This happens
@@ -178,6 +195,12 @@ function(ADD_ARROW_LIB LIB_NAME)
       add_dependencies(${LIB_NAME}_static ${EXTRA_DEPS})
     endif()
 
+    if (LIB_INCLUDES)
+      target_include_directories(${LIB_NAME}_static SYSTEM PUBLIC
+        ${ARG_EXTRA_INCLUDES}
+        )
+    endif()
+
     if (MSVC)
       set(LIB_NAME_STATIC ${LIB_NAME}_static)
       target_compile_definitions(${LIB_NAME}_static PUBLIC ARROW_STATIC)
@@ -285,7 +308,7 @@ endfunction()
 function(ADD_ARROW_TEST REL_TEST_NAME)
   set(options NO_VALGRIND)
   set(single_value_args)
-  set(multi_value_args STATIC_LINK_LIBS)
+  set(multi_value_args STATIC_LINK_LIBS EXTRA_INCLUDES)
   cmake_parse_arguments(ARG "${options}" "${one_value_args}" "${multi_value_args}" ${ARGN})
   if(ARG_UNPARSED_ARGUMENTS)
     message(SEND_ERROR "Error: unrecognized arguments: ${ARG_UNPARSED_ARGUMENTS}")
@@ -307,6 +330,11 @@ function(ADD_ARROW_TEST REL_TEST_NAME)
     else()
       target_link_libraries(${TEST_NAME} ${ARROW_TEST_LINK_LIBS})
     endif()
+    if (ARG_EXTRA_INCLUDES)
+      target_include_directories(${TEST_NAME} SYSTEM PUBLIC
+        ${ARG_EXTRA_INCLUDES}
+        )
+    endif()
     add_dependencies(unittest ${TEST_NAME})
   else()
     # No executable, just invoke the test (probably a script) directly.
diff --git a/cpp/src/arrow/python/CMakeLists.txt b/cpp/src/arrow/python/CMakeLists.txt
index a14ea96..1910053 100644
--- a/cpp/src/arrow/python/CMakeLists.txt
+++ b/cpp/src/arrow/python/CMakeLists.txt
@@ -19,6 +19,9 @@
 # arrow_python
 #######################################
 
+find_package(PythonLibsNew REQUIRED)
+find_package(NumPy REQUIRED)
+
 set(ARROW_PYTHON_SRCS
   arrow_to_pandas.cc
   arrow_to_python.cc
@@ -55,11 +58,16 @@ if (MSVC)
     )
 endif()
 
+set(ARROW_PYTHON_INCLUDES
+  ${NUMPY_INCLUDE_DIRS}
+  ${PYTHON_INCLUDE_DIRS})
+
 ADD_ARROW_LIB(arrow_python
   SOURCES ${ARROW_PYTHON_SRCS}
   SHARED_LINK_FLAGS ""
   SHARED_LINK_LIBS ${ARROW_PYTHON_SHARED_LINK_LIBS}
   STATIC_LINK_LIBS "${PYTHON_OTHER_LIBS}"
+  EXTRA_INCLUDES "${ARROW_PYTHON_INCLUDES}"
 )
 
 if ("${COMPILER_FAMILY}" STREQUAL "clang")
@@ -108,6 +116,8 @@ if (ARROW_BUILD_TESTS)
 
   target_link_libraries(arrow_python_test_main
     gtest)
+  target_include_directories(arrow_python_test_main SYSTEM PUBLIC
+    ${ARROW_PYTHON_INCLUDES})
 
   if (APPLE)
 	target_link_libraries(arrow_python_test_main
@@ -129,6 +139,7 @@ if (ARROW_BUILD_TESTS)
 
   ADD_ARROW_TEST(python-test
     STATIC_LINK_LIBS "${ARROW_PYTHON_TEST_LINK_LIBS}"
+    EXTRA_INCLUDES "${ARROW_PYTHON_INCLUDES}"
     NO_VALGRIND)
   target_link_libraries(python-test
     ${PYTHON_LIBRARIES})