Skip to content
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

[WIP] fixes to build for WASM #76

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
34 changes: 26 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,27 @@ if (CMAKE_COMPILER_IS_GNUCXX)
endif()

message(STATUS "Looking for python ...")
set(Python_FIND_VIRTUALENV ONLY)
find_package (Python COMPONENTS Interpreter Development)
if (NOT Python_FOUND)
set(Python_FIND_VIRTUALENV STANDARD)
find_package (Python COMPONENTS Interpreter Development)
endif()

if (NOT Python_Development_FOUND)
message(FATAL_ERROR "Python development package not found and python component required")
if(NOT EMSCRIPTEN)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather have if (emscripten) then else as that is more clear

set(Python_FIND_VIRTUALENV ONLY)
find_package (Python COMPONENTS Interpreter Development)
if (NOT Python_FOUND)
set(Python_FIND_VIRTUALENV STANDARD)
find_package (Python COMPONENTS Interpreter Development)
endif()

if (NOT Python_Development_FOUND)
message(FATAL_ERROR "Python development package not found and python component required")
endif()
else()
set(Python_INCLUDE_DIRS
"${CMAKE_PREFIX_PATH}/include/python3.11"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't want Python_INCLUDE_DIRS to be set for a particular python version. The ci has version 3.11 for non wasm jobs, but we will want cppyy to support more than just that version. I plan to make this as part of the ci soon. Also given wasm support is constantly change, its probably best to look at using the latest python version for this work.

)

set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE)
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-s SIDE_MODULE=1")
set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-s SIDE_MODULE=1")
set(CMAKE_STRIP FALSE)
endif()

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

add_library(cppyy SHARED ${cppyy_src})

if (EMSCRIPTEN)
target_link_options(cppyy
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer set_target_properties and to use the link_flags option, and we can drop the CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-s SIDE_MODULE=1") and set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-s SIDE_MODULE=1") and put as compile_flags for the cppyy target.

PUBLIC "SHELL: -s WASM_BIGINT"
)
endif()

if(APPLE)
set_target_properties(cppyy PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
set_target_properties(cppyy PROPERTIES SUFFIX ".so")
Expand Down
2 changes: 1 addition & 1 deletion src/Cppyy.h
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ namespace Cppyy {
CPPYY_IMPORT
TCppType_t GetEnumConstantType(TCppScope_t scope);
CPPYY_IMPORT
long long GetEnumDataValue(TCppScope_t scope);
TCppIndex_t GetEnumDataValue(TCppScope_t scope);
CPPYY_IMPORT
TCppScope_t InstantiateTemplate(
TCppScope_t tmpl, Cpp::TemplateArgInfo* args, size_t args_size);
Expand Down