Skip to content

Commit c571915

Browse files
Vipul-Cariappamcbarton
authored andcommitted
fixes to build for WASM
1 parent 895a37e commit c571915

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

CMakeLists.txt

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,27 @@ if (CMAKE_COMPILER_IS_GNUCXX)
1111
endif()
1212

1313
message(STATUS "Looking for python ...")
14-
set(Python_FIND_VIRTUALENV ONLY)
15-
find_package (Python COMPONENTS Interpreter Development)
16-
if (NOT Python_FOUND)
17-
set(Python_FIND_VIRTUALENV STANDARD)
18-
find_package (Python COMPONENTS Interpreter Development)
19-
endif()
2014

21-
if (NOT Python_Development_FOUND)
22-
message(FATAL_ERROR "Python development package not found and python component required")
15+
if(NOT EMSCRIPTEN)
16+
set(Python_FIND_VIRTUALENV ONLY)
17+
find_package (Python COMPONENTS Interpreter Development)
18+
if (NOT Python_FOUND)
19+
set(Python_FIND_VIRTUALENV STANDARD)
20+
find_package (Python COMPONENTS Interpreter Development)
21+
endif()
22+
23+
if (NOT Python_Development_FOUND)
24+
message(FATAL_ERROR "Python development package not found and python component required")
25+
endif()
26+
else()
27+
set(Python_INCLUDE_DIRS
28+
"${CMAKE_PREFIX_PATH}/include/python3.11"
29+
)
30+
31+
set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE)
32+
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-s SIDE_MODULE=1")
33+
set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-s SIDE_MODULE=1")
34+
set(CMAKE_STRIP FALSE)
2335
endif()
2436

2537
include_directories("${PROJECT_SOURCE_DIR}/include" "${Python_INCLUDE_DIRS}")
@@ -28,6 +40,12 @@ file (GLOB cppyy_src src/*.cxx)
2840

2941
add_library(cppyy SHARED ${cppyy_src})
3042

43+
if (EMSCRIPTEN)
44+
target_link_options(cppyy
45+
PUBLIC "SHELL: -s WASM_BIGINT"
46+
)
47+
endif()
48+
3149
if(APPLE)
3250
set_target_properties(cppyy PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
3351
set_target_properties(cppyy PROPERTIES SUFFIX ".so")

src/Cppyy.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ namespace Cppyy {
354354
CPPYY_IMPORT
355355
TCppType_t GetEnumConstantType(TCppScope_t scope);
356356
CPPYY_IMPORT
357-
long long GetEnumDataValue(TCppScope_t scope);
357+
TCppIndex_t GetEnumDataValue(TCppScope_t scope);
358358
CPPYY_IMPORT
359359
TCppScope_t InstantiateTemplate(
360360
TCppScope_t tmpl, Cpp::TemplateArgInfo* args, size_t args_size);

0 commit comments

Comments
 (0)