Skip to content

Commit 875cb68

Browse files
minrkhenryiii
andauthored
docs: be explicit about what it means to "use SKBUILD_SOABI" (#646)
I'm not super experienced with building Python modules with cmake, so it wasn't clear to me until I found it in a test what exactly "use SKBUILD_SOABI" meant until I found it in one of the tests, so I thought others might like to see the `set(Python_SOABI ${SKBUILD_SOABI})`. --------- Signed-off-by: Henry Schreiner <[email protected]> Co-authored-by: Henry Schreiner <[email protected]>
1 parent 25472a5 commit 875cb68

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

docs/cmakelists.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,26 @@ If you are making a Limited ABI / Stable API package, you'll need the
4242

4343
If you want to cross-compile to Windows ARM, you'll need to use
4444
`${SKBUILD_SOABI}`, which is always correct, instead of trusting FindPython's
45-
`Python_SOABI` value.
45+
`Python_SOABI` value. You can manually set the extension suffix after making a
46+
target:
47+
48+
```cmake
49+
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
50+
set_property (TARGET ${name} PROPERTY SUFFIX "$.{SKBUILD_SOSABI}.pyd")
51+
else()
52+
set_property (TARGET ${name} PROPERTY SUFFIX ".${SKBUILD_SOSABI}${CMAKE_SHARED_MODULE_SUFFIX}")
53+
endif()
54+
```
55+
56+
A quicker way to do this would be to instead override `Python_SOABI` after
57+
`find_package(Python)`:
58+
59+
```cmake
60+
set(Python_SOABI ${SKBUILD_SOABI})
61+
```
62+
63+
However, this isn't officially supported upstream, and only works due to the way
64+
this variable is used when creating targets.
4665

4766
:::
4867

0 commit comments

Comments
 (0)