Fix find_package by mircomarahrens · Pull Request #321 · xtensor-stack/xtensor-python

Expand Up @@ -49,7 +49,9 @@ endif() # Running find_package(PythonInterp) to retrieve the Python version # which is not exported by Pybind11's cmake. # Cf. https://github.com/pybind/pybind11/issues/2268 find_package(PythonInterp ${PythonLibsNew_FIND_VERSION} REQUIRED) #find_package(PythonInterp ${PythonLibsNew_FIND_VERSION} REQUIRED) # the above line uses a deprecated cmake method, use the following instead find_package(Python COMPONENTS Interpreter Development.Module NumPy REQUIRED)
set(pybind11_REQUIRED_VERSION 2.6.1) if(TARGET pybind11 OR TARGET pybind11::headers) Expand All @@ -60,13 +62,7 @@ else() message(STATUS "Found pybind11: ${pybind11_INCLUDE_DIRS}/pybind11") endif()
# Look for NumPy headers, except if NUMPY_INCLUDE_DIRS is passed, # which is required under some circumstances (such as wasm, where # there is no real python executable) if(NOT NUMPY_INCLUDE_DIRS) find_package(NumPy REQUIRED) endif() message(STATUS "Found numpy: ${NUMPY_INCLUDE_DIRS}") message(STATUS "Found numpy: ${Python_NumPy_INCLUDE_DIR}")
# Build # ===== Expand All @@ -85,7 +81,7 @@ set(XTENSOR_PYTHON_HEADERS
add_library(xtensor-python INTERFACE) target_include_directories(xtensor-python INTERFACE "$<BUILD_INTERFACE:${XTENSOR_PYTHON_INCLUDE_DIR};${pybind11_INCLUDE_DIRS};${NUMPY_INCLUDE_DIRS}>" "$<BUILD_INTERFACE:${XTENSOR_PYTHON_INCLUDE_DIR};${pybind11_INCLUDE_DIRS};${Python_NumPy_INCLUDE_DIR}>"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this to target_link_libraries, i.e.

target_link_libraries(xtensor-python INTERFACE
    "$<BUILD_INTERFACE:Python::NumPy>"
)
$<INSTALL_INTERFACE:include>) target_link_libraries(xtensor-python INTERFACE xtensor) get_target_property(inc_dir xtensor-python INTERFACE_INCLUDE_DIRECTORIES) Expand Down