diff --git a/CMakeLists.txt b/CMakeLists.txt index e835af60a..7027af5c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/src/Controls/CMakeLists.txt b/src/Controls/CMakeLists.txt index b691d19de..e107d76ff 100644 --- a/src/Controls/CMakeLists.txt +++ b/src/Controls/CMakeLists.txt @@ -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 diff --git a/src/Driver/CMakeLists.txt b/src/Driver/CMakeLists.txt index d2920206b..87fa4bf3f 100644 --- a/src/Driver/CMakeLists.txt +++ b/src/Driver/CMakeLists.txt @@ -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 ) diff --git a/src/DriverSTL/CMakeLists.txt b/src/DriverSTL/CMakeLists.txt index aeccca35b..d00ce22a0 100644 --- a/src/DriverSTL/CMakeLists.txt +++ b/src/DriverSTL/CMakeLists.txt @@ -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 ) diff --git a/src/SMESH/CMakeLists.txt b/src/SMESH/CMakeLists.txt index 6cc676e54..086a48b92 100644 --- a/src/SMESH/CMakeLists.txt +++ b/src/SMESH/CMakeLists.txt @@ -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} diff --git a/src/SMESHUtils/CMakeLists.txt b/src/SMESHUtils/CMakeLists.txt index cb34dffb5..cd91d1286 100644 --- a/src/SMESHUtils/CMakeLists.txt +++ b/src/SMESHUtils/CMakeLists.txt @@ -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} diff --git a/src/SMESH_I/CMakeLists.txt b/src/SMESH_I/CMakeLists.txt index 3a948e618..6c7ea67d6 100644 --- a/src/SMESH_I/CMakeLists.txt +++ b/src/SMESH_I/CMakeLists.txt @@ -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 diff --git a/src/StdMeshers/CMakeLists.txt b/src/StdMeshers/CMakeLists.txt index 349b74825..9328a6b3f 100644 --- a/src/StdMeshers/CMakeLists.txt +++ b/src/StdMeshers/CMakeLists.txt @@ -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 diff --git a/src/StdMeshersGUI/CMakeLists.txt b/src/StdMeshersGUI/CMakeLists.txt index 46c3248d7..dd4c9fb5d 100644 --- a/src/StdMeshersGUI/CMakeLists.txt +++ b/src/StdMeshersGUI/CMakeLists.txt @@ -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 diff --git a/src/webassembly/CMakeLists.txt b/src/webassembly/CMakeLists.txt index 1a58c4df0..446fac5b5 100644 --- a/src/webassembly/CMakeLists.txt +++ b/src/webassembly/CMakeLists.txt @@ -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) diff --git a/src/webassembly/smeshpy.i b/src/webassembly/smeshpy.i new file mode 100644 index 000000000..f577ac90e --- /dev/null +++ b/src/webassembly/smeshpy.i @@ -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"