try SWIG wrappers approach to bypass CORBA infrastructure

- do not link OCCT TKXMesh because of duplicate symbols
This commit is contained in:
Jules BOURDAIS 2024-11-19 09:58:32 +01:00
parent 9ae5c9d8d8
commit a053c039d5
11 changed files with 116 additions and 56 deletions

View File

@ -27,6 +27,7 @@ PROJECT(SalomeSMESH C CXX)
STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
if (DEFINED EMSCRIPTEN)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
list(APPEND CMAKE_FIND_ROOT_PATH "/")
message("Using Emscripten")
add_compile_options(-sUSE_BOOST_HEADERS=1 -pthread)
@ -67,7 +68,7 @@ ENDIF(EXISTS ${KERNEL_ROOT_DIR})
# ==============
INCLUDE(SalomeSetupPlatform) # From KERNEL
# Always build libraries as shared objects:
SET(BUILD_SHARED_LIBS TRUE)
SET(BUILD_SHARED_LIBS FALSE)
# User options
# ============
@ -131,10 +132,11 @@ FIND_PACKAGE(SalomeSWIG REQUIRED)
# Boost
# CORBA
FIND_PACKAGE(SalomeOmniORB REQUIRED)
FIND_PACKAGE(SalomeOmniORBPy REQUIRED)
# IF(DEFINED EMSCRIPTEN)
# LIST(TRANSFORM OMNIORB_LIBRARIES REPLACE "\.so$" "\.a")
# ENDIF()
IF(DEFINED EMSCRIPTEN)
LIST(TRANSFORM OMNIORB_LIBRARIES REPLACE "\.so$" "\.a")
ELSE()
FIND_PACKAGE(SalomeOmniORBPy REQUIRED)
ENDIF()
# LibXml2
FIND_PACKAGE(SalomeLibXml2 REQUIRED)

View File

@ -38,7 +38,8 @@ ADD_DEFINITIONS(
SET(_link_LIBRARIES
${OpenCASCADE_FoundationClasses_LIBRARIES}
${OpenCASCADE_ModelingData_LIBRARIES}
${OpenCASCADE_ModelingAlgorithms_LIBRARIES}
# ${OpenCASCADE_ModelingAlgorithms_LIBRARIES}
TKGeomAlgo TKTopAlgo TKPrim TKBO TKShHealing TKBool TKHLR TKFillet TKOffset TKFeat TKMesh
${GEOM_GEOMUtils}
SMDS
SMESHDS

View File

@ -38,7 +38,8 @@ ADD_DEFINITIONS(
SET(_link_LIBRARIES
${KERNEL_OpUtil}
${OpenCASCADE_FoundationClasses_LIBRARIES}
${OpenCASCADE_ModelingAlgorithms_LIBRARIES}
# ${OpenCASCADE_ModelingAlgorithms_LIBRARIES}
TKGeomAlgo TKTopAlgo TKPrim TKBO TKShHealing TKBool TKHLR TKFillet TKOffset TKFeat TKMesh
SMESHDS
SMESHUtils
)

View File

@ -39,7 +39,8 @@ ADD_DEFINITIONS(
SET(_link_LIBRARIES
${OpenCASCADE_FoundationClasses_LIBRARIES}
${OpenCASCADE_DataExchange_LIBRARIES}
${OpenCASCADE_ModelingAlgorithms_LIBRARIES}
# ${OpenCASCADE_ModelingAlgorithms_LIBRARIES}
TKGeomAlgo TKTopAlgo TKPrim TKBO TKShHealing TKBool TKHLR TKFillet TKOffset TKFeat TKMesh
${KERNEL_SALOMEBasics}
MeshDriver
SMDS
@ -53,7 +54,8 @@ SET(_link_LIBRARIES_bin
${KERNEL_SalomeIDLKERNEL}
${OpenCASCADE_FoundationClasses_LIBRARIES}
${OpenCASCADE_DataExchange_LIBRARIES}
${OpenCASCADE_ModelingAlgorithms_LIBRARIES}
# ${OpenCASCADE_ModelingAlgorithms_LIBRARIES}
TKGeomAlgo TKTopAlgo TKPrim TKBO TKShHealing TKBool TKHLR TKFillet TKOffset TKFeat TKMesh
MeshDriver
SMDS
)

View File

@ -55,7 +55,8 @@ ENDIF(SALOME_SMESH_USE_CGNS)
# libraries to link to
SET(_link_LIBRARIES
${OpenCASCADE_ModelingAlgorithms_LIBRARIES}
# ${OpenCASCADE_ModelingAlgorithms_LIBRARIES}
TKGeomAlgo TKTopAlgo TKPrim TKBO TKShHealing TKBool TKHLR TKFillet TKOffset TKFeat TKMesh
${OpenCASCADE_ModelingData_LIBRARIES}
${OpenCASCADE_ApplicationFramework_LIBRARIES}
${GEOM_NMTTools}

View File

@ -34,7 +34,8 @@ ADD_DEFINITIONS(
# libraries to link to
SET(_link_LIBRARIES
${OpenCASCADE_ModelingAlgorithms_LIBRARIES}
# ${OpenCASCADE_ModelingAlgorithms_LIBRARIES}
TKGeomAlgo TKTopAlgo TKPrim TKBO TKShHealing TKBool TKHLR TKFillet TKOffset TKFeat TKMesh
${OpenCASCADE_FoundationClasses_LIBRARIES}
${OpenCASCADE_ModelingData_LIBRARIES}
${Boost_LIBRARIES}

View File

@ -75,9 +75,10 @@ SET(_link_LIBRARIES
${KERNEL_SalomeKernelHelpers}
${KERNEL_SalomeDS}
${KERNEL_SalomeCatalog}
${PYTHON_LIBRARIES}
# ${PYTHON_LIBRARIES}
${OpenCASCADE_ApplicationFramework_LIBRARIES}
${OpenCASCADE_ModelingAlgorithms_LIBRARIES}
# ${OpenCASCADE_ModelingAlgorithms_LIBRARIES}
TKGeomAlgo TKTopAlgo TKPrim TKBO TKShHealing TKBool TKHLR TKFillet TKOffset TKFeat TKMesh
${GEOM_GEOMClient}
${GEOM_SalomeIDLGEOM}
VTK::IOLegacy

View File

@ -52,7 +52,9 @@ ENDIF(SALOME_SMESH_USE_TBB)
SET(_link_LIBRARIES
${KERNEL_SALOMELocalTrace}
${KERNEL_OpUtil}
${OpenCASCADE_ModelingAlgorithms_LIBRARIES}
# ${OpenCASCADE_ModelingAlgorithms_LIBRARIES}
TKGeomAlgo TKTopAlgo TKPrim TKBO TKShHealing TKBool TKHLR TKFillet TKOffset TKFeat TKMesh
${OpenCASCADE_ModelingData_LIBRARIES}
${GEOM_GEOMUtils}
SMESHimpl

View File

@ -57,7 +57,8 @@ ADD_DEFINITIONS(
# libraries to link to
SET(_link_LIBRARIES
${OpenCASCADE_FoundationClasses_LIBRARIES}
${OpenCASCADE_ModelingAlgorithms_LIBRARIES}
# ${OpenCASCADE_ModelingAlgorithms_LIBRARIES}
TKGeomAlgo TKTopAlgo TKPrim TKBO TKShHealing TKBool TKHLR TKFillet TKOffset TKFeat TKMesh
${QWT_LIBRARY}
SalomeIDLSMESH
SMESHFiltersSelection

View File

@ -1,14 +1,43 @@
add_executable(smeshjs Bindings.cxx)
INCLUDE(${SWIG_USE_FILE})
set_target_properties(smeshjs PROPERTIES
OUTPUT_NAME smesh
# add_executable(smeshjs Bindings.cxx)
set_source_files_properties(smeshpy.i PROPERTIES CPLUSPLUS ON)
SWIG_ADD_LIBRARY(smeshpy TYPE MODULE LANGUAGE python SOURCES smeshpy.i)
target_compile_options(${SWIG_MODULE_smeshpy_REAL_NAME} PRIVATE "-sSIDE_MODULE=2")
target_link_options(${SWIG_MODULE_smeshpy_REAL_NAME} PRIVATE "-sSIDE_MODULE=2")
target_link_libraries(${SWIG_MODULE_smeshpy_REAL_NAME} PRIVATE GEOMImpl SMESHEngine)
# set_target_properties(smeshjs PROPERTIES
# OUTPUT_NAME smesh
# )
set_target_properties(${SWIG_MODULE_smeshpy_REAL_NAME} PROPERTIES
OUTPUT_NAME smesh
)
target_link_libraries(smeshjs PRIVATE SalomeIDLKernel GEOMImpl SMESHDS SMESHimpl StdMeshers SMESHEngine)
target_include_directories(smeshjs PRIVATE
# target_link_libraries(smeshjs PRIVATE SalomeIDLKernel GEOMImpl SMESHDS SMESHimpl StdMeshers SMESHEngine)
# target_include_directories(smeshjs PRIVATE
# ${OpenCASCADE_INCLUDE_DIR}
# ${KERNEL_INCLUDE_DIRS}
# ${KERNEL_INCLUDE_DIRS}
# ${MEDFILE_INCLUDE_DIRS}
# ${MEDCOUPLING_INCLUDE_DIRS}
# ${PROJECT_SOURCE_DIR}/src/Controls
# ${PROJECT_SOURCE_DIR}/src/SMDS
# ${PROJECT_SOURCE_DIR}/src/SMESH
# ${PROJECT_SOURCE_DIR}/src/SMESHDS
# ${PROJECT_SOURCE_DIR}/src/StdMeshers
# ${PROJECT_SOURCE_DIR}/src/SMESHUtils
# )
target_include_directories(${SWIG_MODULE_smeshpy_REAL_NAME} PRIVATE
${OpenCASCADE_INCLUDE_DIR}
${KERNEL_INCLUDE_DIRS}
${KERNEL_INCLUDE_DIRS}
${MEDFILE_INCLUDE_DIRS}
${MEDCOUPLING_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}/src/Controls
@ -17,42 +46,49 @@ target_include_directories(smeshjs PRIVATE
${PROJECT_SOURCE_DIR}/src/SMESHDS
${PROJECT_SOURCE_DIR}/src/StdMeshers
${PROJECT_SOURCE_DIR}/src/SMESHUtils
${PYTHONWASM_INCLUDE_DIR}
)
target_link_options(smeshjs PRIVATE
"-O0"
"--bind"
"--closure 1"
"SHELL:-sEXPORT_NAME=smesh"
"SHELL:-sALLOW_MEMORY_GROWTH=1"
"SHELL:-sEMULATE_FUNCTION_POINTER_CASTS=0"
"SHELL:-sMODULARIZE=1"
"SHELL:-sWASM=1"
"SHELL:-sFORCE_FILESYSTEM"
"SHELL:-sEXPORTED_RUNTIME_METHODS=FS"
"SHELL:-sWASM_BIGINT"
"SHELL:-sNO_DISABLE_EXCEPTION_CATCHING"
)
target_compile_options(smeshjs PRIVATE
"-Oz" "-flto"
)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/app.html"
"${CMAKE_BINARY_DIR}/webassembly/index.html"
COPYONLY)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/server.py"
"${CMAKE_BINARY_DIR}/webassembly/server.py"
COPYONLY)
install(FILES
${CMAKE_BINARY_DIR}/webassembly/index.html
${CMAKE_BINARY_DIR}/webassembly/server.py
${CMAKE_BINARY_DIR}/webassembly/server.py
${CMAKE_BINARY_DIR}/src/webassembly/smesh.wasm
${CMAKE_BINARY_DIR}/src/webassembly/smesh.js
${CMAKE_BINARY_DIR}/src/webassembly/smesh.so
${CMAKE_BINARY_DIR}/src/webassembly/smeshpy.py
DESTINATION smeshpywheel
)
# target_link_options(smeshjs PRIVATE
# "-O0"
# "--bind"
# "--closure 1"
# "SHELL:-sEXPORT_NAME=smesh"
# "SHELL:-sALLOW_MEMORY_GROWTH=1"
# "SHELL:-sEMULATE_FUNCTION_POINTER_CASTS=0"
# "SHELL:-sMODULARIZE=1"
# "SHELL:-sWASM=1"
# "SHELL:-sFORCE_FILESYSTEM"
# "SHELL:-sEXPORTED_RUNTIME_METHODS=FS"
# "SHELL:-sWASM_BIGINT"
# "SHELL:-sNO_DISABLE_EXCEPTION_CATCHING"
# )
# target_compile_options(smeshjs PRIVATE
# "-Oz" "-flto"
# )
# configure_file(
# "${CMAKE_CURRENT_SOURCE_DIR}/app.html"
# "${CMAKE_BINARY_DIR}/webassembly/index.html"
# COPYONLY)
# configure_file(
# "${CMAKE_CURRENT_SOURCE_DIR}/server.py"
# "${CMAKE_BINARY_DIR}/webassembly/server.py"
# COPYONLY)
# install(FILES
# ${CMAKE_BINARY_DIR}/webassembly/index.html
# ${CMAKE_BINARY_DIR}/webassembly/server.py
# ${CMAKE_BINARY_DIR}/webassembly/server.py
# ${CMAKE_BINARY_DIR}/src/webassembly/smesh.wasm
# ${CMAKE_BINARY_DIR}/src/webassembly/smesh.js
DESTINATION webassembly)
# DESTINATION webassembly)

12
src/webassembly/smeshpy.i Normal file
View File

@ -0,0 +1,12 @@
%module "smeshpy"%{
#include "GEOMImpl_Gen.hxx"
#include "SMESHDS_Mesh.hxx"
#include "SMESH_ControlsDef.hxx"
#include "SMESH_Gen.hxx"
#include "SMESH_Mesh.hxx"
#include "StdMeshers_Hexa_3D.hxx"
#include "StdMeshers_NumberOfSegments.hxx"
#include "StdMeshers_Quadrangle_2D.hxx"
#include "StdMeshers_Regular_1D.hxx"
%}
%include "GEOMImpl_Gen.hxx"