]> git.proxmox.com Git - ceph.git/blame - ceph/src/arrow/cpp/src/arrow/python/CMakeLists.txt
import quincy 17.2.0
[ceph.git] / ceph / src / arrow / cpp / src / arrow / python / CMakeLists.txt
CommitLineData
1d09f67e
TL
1# Licensed to the Apache Software Foundation (ASF) under one
2# or more contributor license agreements. See the NOTICE file
3# distributed with this work for additional information
4# regarding copyright ownership. The ASF licenses this file
5# to you under the Apache License, Version 2.0 (the
6# "License"); you may not use this file except in compliance
7# with the License. You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing,
12# software distributed under the License is distributed on an
13# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14# KIND, either express or implied. See the License for the
15# specific language governing permissions and limitations
16# under the License.
17
18#
19# arrow_python
20#
21
22find_package(Python3Alt REQUIRED)
23
24add_custom_target(arrow_python-all)
25add_custom_target(arrow_python)
26add_custom_target(arrow_python-tests)
27add_dependencies(arrow_python-all arrow_python arrow_python-tests)
28
29set(ARROW_PYTHON_SRCS
30 arrow_to_pandas.cc
31 benchmark.cc
32 common.cc
33 datetime.cc
34 decimal.cc
35 deserialize.cc
36 extension_type.cc
37 helpers.cc
38 inference.cc
39 init.cc
40 io.cc
41 ipc.cc
42 numpy_convert.cc
43 numpy_to_arrow.cc
44 python_to_arrow.cc
45 pyarrow.cc
46 serialize.cc)
47
48set_source_files_properties(init.cc PROPERTIES SKIP_PRECOMPILE_HEADERS ON
49 SKIP_UNITY_BUILD_INCLUSION ON)
50
51if(ARROW_FILESYSTEM)
52 list(APPEND ARROW_PYTHON_SRCS filesystem.cc)
53endif()
54
55set(ARROW_PYTHON_DEPENDENCIES arrow_dependencies)
56
57if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
58 set_property(SOURCE pyarrow.cc
59 APPEND_STRING
60 PROPERTY COMPILE_FLAGS " -Wno-cast-qual ")
61endif()
62
63set(ARROW_PYTHON_SHARED_LINK_LIBS arrow_shared)
64if(WIN32)
65 list(APPEND ARROW_PYTHON_SHARED_LINK_LIBS ${PYTHON_LIBRARIES} ${PYTHON_OTHER_LIBS})
66endif()
67
68set(ARROW_PYTHON_INCLUDES ${NUMPY_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS})
69
70add_arrow_lib(arrow_python
71 CMAKE_PACKAGE_NAME
72 ArrowPython
73 PKG_CONFIG_NAME
74 arrow-python
75 SOURCES
76 ${ARROW_PYTHON_SRCS}
77 PRECOMPILED_HEADERS
78 "$<$<COMPILE_LANGUAGE:CXX>:arrow/python/pch.h>"
79 OUTPUTS
80 ARROW_PYTHON_LIBRARIES
81 DEPENDENCIES
82 ${ARROW_PYTHON_DEPENDENCIES}
83 SHARED_LINK_FLAGS
84 ${ARROW_VERSION_SCRIPT_FLAGS} # Defined in cpp/arrow/CMakeLists.txt
85 SHARED_LINK_LIBS
86 ${ARROW_PYTHON_SHARED_LINK_LIBS}
87 STATIC_LINK_LIBS
88 ${PYTHON_OTHER_LIBS}
89 EXTRA_INCLUDES
90 "${ARROW_PYTHON_INCLUDES}")
91
92add_dependencies(arrow_python ${ARROW_PYTHON_LIBRARIES})
93
94foreach(LIB_TARGET ${ARROW_PYTHON_LIBRARIES})
95 target_compile_definitions(${LIB_TARGET} PRIVATE ARROW_PYTHON_EXPORTING)
96endforeach()
97
98if(ARROW_BUILD_STATIC AND MSVC)
99 target_compile_definitions(arrow_python_static PUBLIC ARROW_STATIC)
100endif()
101
102if(ARROW_FLIGHT AND ARROW_BUILD_SHARED)
103 # Must link to shared libarrow_flight: we don't want to link more than one
104 # copy of gRPC into the eventual Cython shared object, otherwise gRPC calls
105 # fail with weird errors due to multiple copies of global static state (The
106 # other solution is to link gRPC shared everywhere instead of statically only
107 # in Flight)
108 add_arrow_lib(arrow_python_flight
109 CMAKE_PACKAGE_NAME
110 ArrowPythonFlight
111 PKG_CONFIG_NAME
112 arrow-python-flight
113 SOURCES
114 flight.cc
115 OUTPUTS
116 ARROW_PYFLIGHT_LIBRARIES
117 DEPENDENCIES
118 flight_grpc_gen
119 SHARED_LINK_FLAGS
120 ${ARROW_VERSION_SCRIPT_FLAGS} # Defined in cpp/arrow/CMakeLists.txt
121 SHARED_LINK_LIBS
122 arrow_python_shared
123 arrow_flight_shared
124 STATIC_LINK_LIBS
125 ${PYTHON_OTHER_LIBS}
126 EXTRA_INCLUDES
127 "${ARROW_PYTHON_INCLUDES}")
128
129 add_dependencies(arrow_python ${ARROW_PYFLIGHT_LIBRARIES})
130
131 foreach(LIB_TARGET ${ARROW_PYFLIGHT_LIBRARIES})
132 target_compile_definitions(${LIB_TARGET} PRIVATE ARROW_PYFLIGHT_EXPORTING)
133 endforeach()
134
135 if(ARROW_BUILD_STATIC AND MSVC)
136 target_compile_definitions(arrow_python_flight_static PUBLIC ARROW_STATIC)
137 endif()
138endif()
139
140if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
141 # Clang, be quiet. Python C API has lots of macros
142 set_property(SOURCE ${ARROW_PYTHON_SRCS}
143 APPEND_STRING
144 PROPERTY COMPILE_FLAGS -Wno-parentheses-equality)
145endif()
146
147arrow_install_all_headers("arrow/python")
148
149# ----------------------------------------------------------------------
150
151if(ARROW_BUILD_TESTS)
152 add_library(arrow_python_test_main STATIC util/test_main.cc)
153
154 target_link_libraries(arrow_python_test_main GTest::gtest)
155 target_include_directories(arrow_python_test_main SYSTEM
156 PUBLIC ${ARROW_PYTHON_INCLUDES})
157
158 if(APPLE)
159 target_link_libraries(arrow_python_test_main ${CMAKE_DL_LIBS})
160 set_target_properties(arrow_python_test_main PROPERTIES LINK_FLAGS
161 "-undefined dynamic_lookup")
162 elseif(NOT MSVC)
163 target_link_libraries(arrow_python_test_main pthread ${CMAKE_DL_LIBS})
164 endif()
165
166 if(ARROW_TEST_LINKAGE STREQUAL shared)
167 set(ARROW_PYTHON_TEST_LINK_LIBS arrow_python_test_main arrow_python_shared
168 arrow_testing_shared arrow_shared)
169 else()
170 set(ARROW_PYTHON_TEST_LINK_LIBS arrow_python_test_main arrow_python_static
171 arrow_testing_static arrow_static)
172 endif()
173
174 add_arrow_test(python_test
175 STATIC_LINK_LIBS
176 "${ARROW_PYTHON_TEST_LINK_LIBS}"
177 EXTRA_LINK_LIBS
178 ${PYTHON_LIBRARIES}
179 EXTRA_INCLUDES
180 "${ARROW_PYTHON_INCLUDES}"
181 LABELS
182 "arrow_python-tests"
183 NO_VALGRIND)
184endif()