`find_package` interferes with existing installation
This is a quick but rather subtle issue. My CMake list file goes like:
if (NOT TARGET Spglib::symspg)
find_package(Spglib CONFIG)
if (NOT Spglib_FOUND)
message(STATUS "Using bundled spglib sources")
add_subdirectory(${PROJECT_SOURCE_DIR}/.. _deps/spglib-build)
endif ()
endif ()
If I pip install from scratch it works just fine, i.e. the add_subdirectory is used. But if I run pip install again, then it picks up the current installation and it goes through find_package even though it is later removed at the install stage when the previous version is uninstalled.
I think the issue is with working around NO_CMAKE_INSTALL_PREFIX, but it is weird, shouldn't that point to tmp folder that would not interfere? Otherwise I did not configure any prefix for it to use. Any clues on what's happening here and how to work around it?
I believe the issue is with: https://github.com/scikit-build/scikit-build-core/blob/4f06e8cf8acc41c38c52152b6b8b2e0cbb321c34/src/scikit_build_core/builder/builder.py#L133-L139
I'm assuming you haven't set CMAKE_EXPORT_PACKAGE_REGISTRY, which could muddle with this.
The CMake way to do this is with the new-ish (3.24 IIRC) FindPackage + FetchContent integration: (see https://github.com/scikit-hep/boost-histogram/blob/8ded2db528ac1a8538462239a72a1f1efa5e10cf/CMakeLists.txt#L45-L50)
CMAKE_EXPORT_PACKAGE_REGISTRY nope not setup, on the pyproject.toml everything is rather vanilla, and the current CMakeLists.txt does not mess with anything related to find_package.
The CMake way to do this is with the new-ish (3.24 IIRC) FindPackage + FetchContent integration:
Yeah, for proper dependencies I do use the FetchContent approach. But this is a special case where I want to use the bundled project instead, i.e. Spglib_python where that snippet is in is just the python bindings and it is a subproject/subdir of Spglib so that if the system installed Spglib is found use and link to it, otherwise use the bundled source files commit-locked to the current sources.