# Using meshsearch from another package The wheel that `pip install meshsearch` installs carries the C++ library as source, for packages that build on it: the headers, the library's sources and a CMake package, which needs CMake 3.16 or later. `find_package(meshsearch)` reads that package, which creates the static library target `meshsearch::meshsearch` in your build, from those sources, with your compiler and your build type. No library is prebuilt, so nothing has to match the compiler or the standard library the wheel was built with. Build in an optimised configuration, as on every route ([install](index.md#install)). The target requires C++17 of whatever links it and brings the platform's thread library. It compiles meshsearch's sources with `-ffp-contract=off` and `-fno-math-errno`, which your own sources do not get: the first keeps distances, and with them boundary and tie decisions, the same on every platform, so your build returns the same results, in the same order, as every other build of the same version, unless those options change floating-point semantics, as `-ffast-math` does. The sources are part of your build, so the compile options of the directory that calls `find_package`, warnings as errors for one, apply to them too. `python -m meshsearch --cmake-dir` prints the directory that holds the CMake package. A plain CMake project passes it as `meshsearch_DIR`: ``` cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -Dmeshsearch_DIR="$(python -m meshsearch --cmake-dir)" ``` with a `CMakeLists.txt` such as this one: ```{literalinclude} ../examples/downstream/cmake/CMakeLists.txt :language: cmake ``` A Python package built with scikit-build-core needs no setting: it lists meshsearch among its build requirements, pip installs the wheel into the isolated build environment, and scikit-build-core puts that environment's site-packages on CMake's search path, where `find_package` finds it. The `pyproject.toml` of a package whose extension module is written with nanobind: ```{literalinclude} ../examples/downstream/python/pyproject.toml :language: toml ``` and its `CMakeLists.txt`: ```{literalinclude} ../examples/downstream/python/CMakeLists.txt :language: cmake ``` The complete packages, with their sources, are in [`examples/downstream`](https://github.com/SimoSartori/meshsearch/tree/main/examples/downstream); the module is installed into the package directory named in `wheel.packages`. Two things follow from how the build environment is assembled. numpy, the wheel's only dependency, is installed into it as well. And scikit-build-core searches the site-packages of the interpreter that runs pip before those of the build environment, so a meshsearch already installed there is the one found; the version given to `find_package` is still checked against it. The library compiled into your module is the version the build found. meshsearch is linked into your module statically: it is needed to build the module, not to run it, and belongs in your `dependencies` only if your package also imports `meshsearch`. Your module holds its own copy of the library and shares no types with meshsearch's Python module: a grid built in one cannot be passed to the other. Nor does it share meshsearch's binding library: the CMake package brings none, so your module may use any version of nanobind, another binding library, or the C API. The CMake package stops with an error if your build already has a target named `meshsearch`; rename that target. The classic CMake install, described in the [README](https://github.com/SimoSartori/meshsearch#install), installs a prebuilt static archive with its own CMake package, under the same target name, for projects that do not go through pip. Use the wheel's CMake package when pip builds your package, and the classic install when your project is itself installed with CMake; the same `CMakeLists.txt` works with either.