|
| 1 | +@PACKAGE_INIT@ |
| 2 | + |
| 3 | +# numpycpp -- header-only C++ numpy API library. |
| 4 | +# |
| 5 | +# Backend selection (set BEFORE find_package, or via cmake -D): |
| 6 | +# cmake -DNUMPYCPP_STD_ONLY=OFF .. # bitexact (default): SVML + OpenBLAS via dlsym |
| 7 | +# cmake -DNUMPYCPP_STD_ONLY=ON .. # std: pure <cmath> + C++ loops, no dlsym |
| 8 | +# |
| 9 | +# The flag is propagated automatically to every target that links numpycpp: |
| 10 | +# bitexact → INTERFACE_LINK_LIBRARIES dl |
| 11 | +# std → INTERFACE_COMPILE_DEFINITIONS NUMPYCPP_STD_ONLY |
| 12 | + |
| 13 | +# Non-namespaced + namespaced alias. |
| 14 | +# pybind11_add_module users: if the :: target is lost during generation, use |
| 15 | +# target_include_directories(mymod PRIVATE ${numpycpp_INCLUDE_DIRS}) |
| 16 | +add_library(numpycpp INTERFACE IMPORTED) |
| 17 | + |
| 18 | +set_target_properties(numpycpp PROPERTIES |
| 19 | + IMPORTED_GLOBAL TRUE |
| 20 | + INTERFACE_COMPILE_FEATURES "cxx_std_17" |
| 21 | + INTERFACE_INCLUDE_DIRECTORIES "${PACKAGE_PREFIX_DIR}/include/numpycpp" |
| 22 | +) |
| 23 | + |
| 24 | +add_library(numpycpp::numpycpp ALIAS numpycpp) |
| 25 | + |
| 26 | +# Propagate the correct backend flags to every consumer automatically. |
| 27 | +if(NUMPYCPP_STD_ONLY) |
| 28 | + # std backend: no external dependencies |
| 29 | + set_property(TARGET numpycpp APPEND PROPERTY |
| 30 | + INTERFACE_COMPILE_DEFINITIONS NUMPYCPP_STD_ONLY) |
| 31 | + message(STATUS "numpycpp: std backend (pure <cmath>, no dlsym)") |
| 32 | +else() |
| 33 | + # bitexact backend (default): libdl needed for dlsym -> numpy .so at runtime |
| 34 | + set_property(TARGET numpycpp APPEND PROPERTY |
| 35 | + INTERFACE_LINK_LIBRARIES dl) |
| 36 | + message(STATUS "numpycpp: bitexact backend (SVML + OpenBLAS via dlsym, -ldl)") |
| 37 | +endif() |
| 38 | + |
| 39 | +# Fallback variables (pybind11_add_module target-loss workaround) |
| 40 | +set(numpycpp_INCLUDE_DIRS "${PACKAGE_PREFIX_DIR}/include/numpycpp") |
| 41 | + |
| 42 | +check_required_components(numpycpp) |
0 commit comments