Skip to content

SOABI/SOSABI detection tweaks #483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions cmake/nanobind-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,30 @@ else()
set(NB_SUFFIX_EXT "${CMAKE_SHARED_MODULE_SUFFIX}")
endif()

# This was added in CMake 3.17+, also available earlier in scikit-build-core.
# Check if FindPython/scikit-build-core defined a SOABI/SOSABI variable
if(DEFINED SKBUILD_SOABI)
set(NB_SOABI "${SKBUILD_SOABI}")
elif(DEFINED Python_SOABI)
set(NB_SOABI "${Python_SOABI}")
endif()

if(DEFINED SKBUILD_SOSABI)
set(NB_SOSABI "${SKBUILD_SOSABI}")
elif(DEFINED Python_SOSABI)
set(NB_SOSABI "${Python_SOSABI}")
endif()

# PyPy sets an invalid SOABI (platform missing), causing older FindPythons to
# report an incorrect value. Only use it if it looks correct (X-X-X form).
if(DEFINED Python_SOABI AND "${Python_SOABI}" MATCHES ".+-.+-.+")
set(NB_SUFFIX ".${Python_SOABI}${NB_SUFFIX_EXT}")
if(DEFINED NB_SOABI AND "${NB_SOABI}" MATCHES ".+-.+-.+")
set(NB_SUFFIX ".${NB_SOABI}${NB_SUFFIX_EXT}")
endif()

# Python_SOSABI is guaranteed to be available in CMake 3.26+, and it may
# also be available as part of backported FindPython in scikit-build-core.
if(DEFINED Python_SOSABI)
if(Python_SOSABI STREQUAL "")
if(DEFINED NB_SOSABI)
if(NB_SOSABI STREQUAL "")
set(NB_SUFFIX_S "${NB_SUFFIX_EXT}")
else()
set(NB_SUFFIX_S ".${Python_SOSABI}${NB_SUFFIX_EXT}")
set(NB_SUFFIX_S ".${NB_SOSABI}${NB_SUFFIX_EXT}")
endif()
endif()

Expand Down