Skip to content

Commit a6921b8

Browse files
committed
ifcwrap cmake - provide correct suffix for wasm python extension
1 parent c3c94b9 commit a6921b8

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/ifcwrap/CMakeLists.txt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ IF(NOT Python_Development_FOUND)
5353
MESSAGE(FATAL_ERROR "BUILD_IFCPYTHON enabled, but unable to find Python lib or header. Disable BUILD_IFCPYTHON or fix Python paths to proceed.")
5454
ENDIF()
5555

56+
# Ensure version is saved here, from wasm libraries,
57+
# not from Python interpreter that might be unrelated to pyodide Python version.
58+
set(_python_libs_version "${Python_VERSION_MAJOR}${Python_VERSION_MINOR}")
5659
INCLUDE_DIRECTORIES(${Python_INCLUDE_DIRS})
5760
INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_SOURCE_DIR})
5861

@@ -109,11 +112,14 @@ if(NOT ${PYTHON_EXECUTABLE} STREQUAL "")
109112
endif()
110113
FIND_PACKAGE(Python COMPONENTS Interpreter)
111114
IF(Python_Interpreter_FOUND OR PYTHON_MODULE_INSTALL_DIR)
112-
if (NOT WASM_BUILD)
113-
# Not on WASM because we're cross compiling in that case
114-
#
115115
# Python_SOABI example value is 'cp311-win_amd64'.
116-
if(WIN32)
116+
if(WASM_BUILD)
117+
# For WASM we usually don't provide interpreter,
118+
# so `find_package` couldn't find `Python_SOABI`.
119+
# So we just hardcode it.
120+
# .cpython-313-wasm32-emscripten.so
121+
set(PYTHON_EXTENSION_SUFFIX ".cpython-${_python_libs_version}-wasm32-emscripten.so")
122+
elseif(WIN32)
117123
set(PYTHON_EXTENSION_SUFFIX ".${Python_SOABI}.pyd")
118124
else()
119125
set(PYTHON_EXTENSION_SUFFIX ".${Python_SOABI}.so")
@@ -131,7 +137,6 @@ IF(Python_Interpreter_FOUND OR PYTHON_MODULE_INSTALL_DIR)
131137
SUFFIX ${PYTHON_EXTENSION_SUFFIX}
132138
)
133139
endif()
134-
endif(NOT WASM_BUILD)
135140

136141
if (PYTHON_MODULE_INSTALL_DIR)
137142
set(python_package_dir "${PYTHON_MODULE_INSTALL_DIR}")

0 commit comments

Comments
 (0)