Steps to reproduce:
- Create venv, activate venv, and update pip:
python3 -m venv venv && source venv/bin/activate && python3 -m pip install --upgrade pip
- Installation: There are two ways to install.
- Git clone repo and install from source:
git clone --recursive https://github.com/lionlai1989/xtensor_pybind11_cmake.git
python3 -m pip install .
- Install from github:
python3 -m pip install "mymodule @ git+ssh://[email protected]/lionlai1989/xtensor_pybind11_cmake.git"
- Verify installation:
>>> import numpy as np
>>> import mymodule
>>> v = np.arange(15).reshape(3, 5)
>>> mymodule.sum_of_sines(v)
1.2853996391883833
- Link the library
xtensor::use_xsimd
to my targetmymodule
inCMakeLists.txt
:
- Uncomment Line:44 in
CMakeLists.txt
:
target_link_libraries(mymodule PUBLIC xtensor pybind11::module xtensor-python Python::NumPy xtensor::optimize xtensor::use_xsimd)
- The error when
python3 -m pip install .
:
-- Configuring done (1.3s)
CMake Error at src/mypackage/CMakeLists.txt:5 (target_link_libraries):
Target "sum_of_sines_static" links to:
xtensor::optimize
but the target was not found. Possible reasons include:
* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.
-- Generating done (0.0s)
CMake Warning:
Manually-specified variables were not used by the project:
EXAMPLE_VERSION_INFO
CMake Generate step failed. Build files cannot be regenerated correctly.