Skip to content

Commit 71f53b2

Browse files
Use built in cmake features to find NumPy
1 parent 3cc25f4 commit 71f53b2

2 files changed

Lines changed: 3 additions & 103 deletions

File tree

‎CMakeLists.txt‎

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
cmake_minimum_required(VERSION 3.29)
1111
project(xtensor-python)
1212

13-
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
1413
set(XTENSOR_PYTHON_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
1514

1615
# Versioning
@@ -46,7 +45,7 @@ else()
4645
message(STATUS "Found xtensor: ${xtensor_INCLUDE_DIRS}/xtensor")
4746
endif()
4847

49-
find_package(Python COMPONENTS Interpreter REQUIRED)
48+
find_package(Python3 COMPONENTS Interpreter Development.Module NumPy REQUIRED)
5049

5150
set(pybind11_REQUIRED_VERSION 3.0.0)
5251
if (NOT TARGET pybind11::headers)
@@ -60,14 +59,6 @@ else ()
6059
message(STATUS "Found pybind11 v${pybind11_VERSION}")
6160
endif ()
6261

63-
# Look for NumPy headers, except if NUMPY_INCLUDE_DIRS is passed,
64-
# which is required under some circumstances (such as wasm, where
65-
# there is no real python executable)
66-
if(NOT NUMPY_INCLUDE_DIRS)
67-
find_package(NumPy REQUIRED)
68-
endif()
69-
message(STATUS "Found numpy: ${NUMPY_INCLUDE_DIRS}")
70-
7162
# Build
7263
# =====
7364

@@ -84,10 +75,8 @@ set(XTENSOR_PYTHON_HEADERS
8475
)
8576

8677
add_library(xtensor-python INTERFACE)
87-
target_include_directories(xtensor-python INTERFACE
88-
"$<BUILD_INTERFACE:${XTENSOR_PYTHON_INCLUDE_DIR};${pybind11_INCLUDE_DIRS};${NUMPY_INCLUDE_DIRS}>"
89-
$<INSTALL_INTERFACE:include>)
90-
target_link_libraries(xtensor-python INTERFACE xtensor)
78+
target_include_directories(xtensor-python INTERFACE "$<BUILD_INTERFACE:${XTENSOR_PYTHON_INCLUDE_DIR}>" $<INSTALL_INTERFACE:include>)
79+
target_link_libraries(xtensor-python INTERFACE xtensor pybind11::pybind11 Python3::NumPy)
9180
get_target_property(inc_dir xtensor-python INTERFACE_INCLUDE_DIRECTORIES)
9281

9382
OPTION(BUILD_TESTS "xtensor test suite" OFF)

‎cmake/FindNumPy.cmake‎

Lines changed: 0 additions & 89 deletions
This file was deleted.

0 commit comments

Comments
 (0)