From b022ca7e70f2cacfb5f39704fd655d4443d0f4b8 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Tue, 21 Apr 2026 16:18:59 +0200 Subject: [PATCH] Some plug-in work --- cmake/CMakeLists.txt | 1 + src/ifcconvert/CMakeLists.txt | 2 +- src/ifcconvert/IfcConvert.cpp | 13 +---- src/ifcgeom/CMakeLists.txt | 5 +- src/ifcparse/CMakeLists.txt | 6 ++- src/ifcwrap/CMakeLists.txt | 43 +++++++++++----- src/ifcwrap/IfcGeomWrapper.i | 35 +------------ src/ifcwrap/IfcPython.i | 96 +++-------------------------------- 8 files changed, 50 insertions(+), 151 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 2207c96dc8..25f31cd5db 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -60,6 +60,7 @@ option(MSVC_PARALLEL_BUILD "Multi-threaded compilation in Microsoft Visual Studi option(USE_VLD "Use Visual Leak Detector for debugging memory leaks, MSVC-only." OFF) option(USE_MMAP "Adds a command line options to parse IFC files from memory mapped files using Boost.Iostreams" OFF) option(NO_WARN "Disable all warnings" OFF) +option(CREATE_BUNDLE "Copy .so files and don't create RPATHS or SOVERSION symlinks" ) option(BUILD_IFCGEOM "Build IfcGeom." ON) option(BUILD_IFCPYTHON "Build IfcPython." ON) diff --git a/src/ifcconvert/CMakeLists.txt b/src/ifcconvert/CMakeLists.txt index a60eb17e76..3c594b187c 100644 --- a/src/ifcconvert/CMakeLists.txt +++ b/src/ifcconvert/CMakeLists.txt @@ -1,7 +1,7 @@ # IfcConvert add_executable(IfcConvert IfcConvert.cpp) -target_link_libraries(IfcConvert PRIVATE IfcGeom IfcParse ${OpenCASCADE_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(IfcConvert PRIVATE IfcGeom IfcParse ${Boost_LIBRARIES}) if(kernel_libraries OR mapping_libraries OR geometry_serializer_libraries OR document_serializer_libraries) add_dependencies(IfcConvert ${kernel_libraries} ${mapping_libraries} ${geometry_serializer_libraries} ${document_serializer_libraries}) endif() diff --git a/src/ifcconvert/IfcConvert.cpp b/src/ifcconvert/IfcConvert.cpp index 50263a654f..e2aac015e5 100644 --- a/src/ifcconvert/IfcConvert.cpp +++ b/src/ifcconvert/IfcConvert.cpp @@ -40,12 +40,6 @@ #include "../ifcparse/utils.h" -#ifdef IFOPSH_WITH_OPENCASCADE - -#include - -#endif - #include #include #include @@ -174,11 +168,8 @@ std::vector document_serializer_usage_lines() { void print_version() { - cout_ << "IfcOpenShell IfcConvert " << IFCOPENSHELL_VERSION; -#ifdef IFOPSH_WITH_OPENCASCADE - cout_ << " (OCC " << OCC_VERSION_STRING_EXT << ")"; -#endif - cout_ << "\n"; + // @todo print plug-in versions + cout_ << "IfcOpenShell IfcConvert " << IFCOPENSHELL_VERSION << "\n"; } void print_usage(bool suggest_help = true) diff --git a/src/ifcgeom/CMakeLists.txt b/src/ifcgeom/CMakeLists.txt index a179a659cc..b9a364c9fd 100644 --- a/src/ifcgeom/CMakeLists.txt +++ b/src/ifcgeom/CMakeLists.txt @@ -12,7 +12,10 @@ set(SCHEMA_AGNOSTIC_FILES ${SCHEMA_AGNOSTIC_H_FILES} ${SCHEMA_AGNOSTIC_CPP_FILES add_library(IfcGeom ${SCHEMA_AGNOSTIC_FILES}) add_library(geometry ALIAS IfcGeom) -set_target_properties(IfcGeom PROPERTIES COMPILE_FLAGS -DIFC_GEOM_EXPORTS VERSION "${PROJECT_VERSION}" SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}") +set_target_properties(IfcGeom PROPERTIES COMPILE_FLAGS -DIFC_GEOM_EXPORTS) +if (NOT CREATE_BUNDLE) +set_target_properties(IfcGeom PROPERTIES VERSION "${PROJECT_VERSION}" SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}") +endif() target_compile_definitions(IfcGeom PRIVATE BOOST_DLL_USE_STD_FS SERIALIZERS_EXPORTS) if(WITH_CGAL) target_compile_definitions(IfcGeom PUBLIC IFOPSH_WITH_CGAL) diff --git a/src/ifcparse/CMakeLists.txt b/src/ifcparse/CMakeLists.txt index b9113fa4db..44597f5502 100644 --- a/src/ifcparse/CMakeLists.txt +++ b/src/ifcparse/CMakeLists.txt @@ -43,8 +43,10 @@ if(WITH_ROCKSDB) target_compile_definitions(IfcParse PUBLIC IFOPSH_WITH_ROCKSDB) set(SWIG_DEFINES ${SWIG_DEFINES} -DIFOPSH_WITH_ROCKSDB PARENT_SCOPE) endif() -set_target_properties(IfcParse PROPERTIES COMPILE_FLAGS -DIFC_PARSE_EXPORTS VERSION "${PROJECT_VERSION}" SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}") - +set_target_properties(IfcParse PROPERTIES COMPILE_FLAGS -DIFC_PARSE_EXPORTS) +if (NOT CREATE_BUNDLE) + set_target_properties(IfcParse PROPERTIES VERSION "${PROJECT_VERSION}" SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}") +endif() if(WASM_BUILD) target_link_libraries(IfcParse plugin ${BCRYPT_LIBRARIES}) else() diff --git a/src/ifcwrap/CMakeLists.txt b/src/ifcwrap/CMakeLists.txt index 13c0e0113a..889fee0dc1 100644 --- a/src/ifcwrap/CMakeLists.txt +++ b/src/ifcwrap/CMakeLists.txt @@ -120,6 +120,10 @@ else() endif() target_link_libraries(ifcopenshell_wrapper PRIVATE Python::Module) +if(WITH_ROCKSDB) + message(STATUS TK) + target_link_libraries(ifcopenshell_wrapper PRIVATE document_serializer_rdb) +endif() SET_PROPERTY(TARGET ifcopenshell_wrapper PROPERTY SWIG_DEPENDS ${IFCOPENSHELL_LIBRARIES}) if (WASM_BUILD) # SIDE_MODULE=1 - add to .so all symbols from linked archives (default used by pyodide). @@ -141,18 +145,7 @@ if (WASM_BUILD) PRIVATE "SHELL:-s EXPORTED_FUNCTIONS=_PyInit__ifcopenshell_wrapper -s SIDE_MODULE=2" ) endif() -if("$ENV{LDFLAGS}" MATCHES ".undefined.suppress") -# On osx there is some state in the python dylib. With `-Wl,undefined,suppress` we can ignore the missing symbols at compile time. -target_link_libraries(ifcopenshell_wrapper PRIVATE ${IFCOPENSHELL_LIBRARIES} ${OpenCASCADE_LIBRARIES} ${Boost_LIBRARIES} ${LIBSVGFILL}) -else() -target_link_libraries(ifcopenshell_wrapper PRIVATE ${IFCOPENSHELL_LIBRARIES} ${LIBSVGFILL}) -endif() -if(geometry_serializer_libraries) - target_link_libraries(ifcopenshell_wrapper PRIVATE ${geometry_serializer_libraries}) -endif() -if(TARGET document_serializer_rdb) - target_link_libraries(ifcopenshell_wrapper PRIVATE document_serializer_rdb) -endif() +target_link_libraries(ifcopenshell_wrapper PRIVATE IfcGeom IfcParse ${Boost_LIBRARIES} ${LIBSVGFILL}) if(kernel_libraries OR tree_libraries OR mapping_libraries OR geometry_serializer_libraries OR document_serializer_libraries) add_dependencies(ifcopenshell_wrapper ${kernel_libraries} ${tree_libraries} ${mapping_libraries} ${geometry_serializer_libraries} ${document_serializer_libraries}) endif() @@ -218,6 +211,32 @@ IF(Python_Interpreter_FOUND OR PYTHON_MODULE_INSTALL_DIR) DESTINATION "${python_package_dir}/ifcopenshell") INSTALL(TARGETS ifcopenshell_wrapper DESTINATION "${python_package_dir}/ifcopenshell") + + if (CREATE_BUNDLE) + set(_ifcopenshell_python_runtime_targets + IfcGeom + IfcParse + ${kernel_libraries} + ${tree_libraries} + ${mapping_libraries} + ${geometry_serializer_libraries} + ${document_serializer_libraries} + ) + + list(REMOVE_DUPLICATES _ifcopenshell_python_runtime_targets) + + if(_ifcopenshell_python_runtime_targets) + INSTALL(TARGETS ${_ifcopenshell_python_runtime_targets} + LIBRARY DESTINATION "${python_package_dir}/ifcopenshell" + RUNTIME DESTINATION "${python_package_dir}/ifcopenshell") + endif() + + if(NOT WIN32 AND NOT WASM_BUILD) + set_target_properties(ifcopenshell_wrapper PROPERTIES + INSTALL_RPATH "$ORIGIN" + ) + endif() + endif() if (MSVC) INSTALL(FILES $ DESTINATION bin OPTIONAL) endif() diff --git a/src/ifcwrap/IfcGeomWrapper.i b/src/ifcwrap/IfcGeomWrapper.i index e432564a84..66dd8d284b 100644 --- a/src/ifcwrap/IfcGeomWrapper.i +++ b/src/ifcwrap/IfcGeomWrapper.i @@ -265,15 +265,6 @@ namespace { %include "../ifcgeom/taxonomy.h" %include "../ifcgeom/function_item_evaluator.h" -%include "../serializers/SvgSerializer.h" -%include "../serializers/HdfSerializer.h" -%include "../serializers/WavefrontObjSerializer.h" -%include "../serializers/ColladaSerializer.h" -%include "../serializers/XmlSerializer.h" -%include "../serializers/GltfSerializer.h" -%include "../serializers/TtlWktSerializer.h" -%include "../serializers/JsonSerializer.h" - %extend ifcopenshell::geometry::taxonomy::style { size_t instance_id() const { if (!self->instance) { @@ -916,31 +907,7 @@ ifcopenshell::geometry::taxonomy::item::ptr try_upcast(PyObject* obj0, swig_type } %} -#ifdef IFOPSH_WITH_OPENCASCADE - -%inline %{ - #include - - express::Base serialise(ifcopenshell::file& f, const std::string& shape_str, bool advanced=true) { - std::stringstream stream(shape_str); - BRepTools_ShapeSet shapes; - shapes.Read(stream); - const TopoDS_Shape& shp = shapes.Shape(shapes.NbShapes()); - - return IfcGeom::serialise(f, shp, advanced); - } - - express::Base tesselate(ifcopenshell::file& f, const std::string& shape_str, double d) { - std::stringstream stream(shape_str); - BRepTools_ShapeSet shapes; - shapes.Read(stream); - const TopoDS_Shape& shp = shapes.Shape(shapes.NbShapes()); - - return IfcGeom::tesselate(f, shp, d); - } -%} - -#endif +// @todo bring back serialization OCCT -> IFC by means of opencascade_geometry_ifc_writer_registry %template(OpaqueCoordinate_3) IfcGeom::OpaqueCoordinate<3>; %template(OpaqueCoordinate_4) IfcGeom::OpaqueCoordinate<4>; diff --git a/src/ifcwrap/IfcPython.i b/src/ifcwrap/IfcPython.i index f466a3120b..52524315af 100644 --- a/src/ifcwrap/IfcPython.i +++ b/src/ifcwrap/IfcPython.i @@ -198,49 +198,6 @@ #include "../ifcgeom/taxonomy.h" #include "../ifcgeom/function_item_evaluator.h" - #include "../serializers/SvgSerializer.h" - #include "../serializers/WavefrontObjSerializer.h" - #include "../serializers/ColladaSerializer.h" - #include "../serializers/HdfSerializer.h" - #include "../serializers/RocksDbSerializer.h" - -#ifdef HAS_SCHEMA_2x3 - #include "../ifcparse/schemas/Ifc2x3.h" -#endif -#ifdef HAS_SCHEMA_4 - #include "../ifcparse/schemas/Ifc4.h" -#endif -#ifdef HAS_SCHEMA_4x1 - #include "../ifcparse/schemas/Ifc4x1.h" -#endif -#ifdef HAS_SCHEMA_4x2 - #include "../ifcparse/schemas/Ifc4x2.h" -#endif -#ifdef HAS_SCHEMA_4x3_rc1 - #include "../ifcparse/schemas/Ifc4x3_rc1.h" -#endif -#ifdef HAS_SCHEMA_4x3_rc2 - #include "../ifcparse/schemas/Ifc4x3_rc2.h" -#endif -#ifdef HAS_SCHEMA_4x3_rc3 -#include "../ifcparse/schemas/Ifc4x3_rc3.h" -#endif -#ifdef HAS_SCHEMA_4x3_rc4 -#include "../ifcparse/schemas/Ifc4x3_rc4.h" -#endif -#ifdef HAS_SCHEMA_4x3 -#include "../ifcparse/schemas/Ifc4x3.h" -#endif -#ifdef HAS_SCHEMA_4x3_tc1 -#include "../ifcparse/schemas/Ifc4x3_tc1.h" -#endif -#ifdef HAS_SCHEMA_4x3_add1 -#include "../ifcparse/schemas/Ifc4x3_add1.h" -#endif -#ifdef HAS_SCHEMA_4x3_add2 -#include "../ifcparse/schemas/Ifc4x3_add2.h" -#endif - #include "../ifcparse/express.h" #include "../ifcparse/file.h" #include "../ifcparse/schema.h" @@ -250,6 +207,9 @@ #include "../ifcgeom/ConversionResult.h" #include "../svgfill/src/svgfill.h" + + // @todo abstract into plug-in interface + #include "../serializers/RocksDbSerializer.h" %} // Create docstrings for generated python code. @@ -271,53 +231,6 @@ #include "../ifcgeom/ConversionResult.h" #include "../ifcgeom/hybrid_kernel.h" - #include "../serializers/SvgSerializer.h" - #include "../serializers/WavefrontObjSerializer.h" - #include "../serializers/ColladaSerializer.h" - #include "../serializers/HdfSerializer.h" - #include "../serializers/XmlSerializer.h" - #include "../serializers/GltfSerializer.h" - #include "../serializers/TtlWktSerializer.h" - #include "../serializers/RocksDbSerializer.h" - #include "../serializers/JsonSerializer.h" - -#ifdef HAS_SCHEMA_2x3 - #include "../ifcparse/schemas/Ifc2x3.h" -#endif -#ifdef HAS_SCHEMA_4 - #include "../ifcparse/schemas/Ifc4.h" -#endif -#ifdef HAS_SCHEMA_4x1 - #include "../ifcparse/schemas/Ifc4x1.h" -#endif -#ifdef HAS_SCHEMA_4x2 - #include "../ifcparse/schemas/Ifc4x2.h" -#endif -#ifdef HAS_SCHEMA_4x3_rc1 - #include "../ifcparse/schemas/Ifc4x3_rc1.h" -#endif -#ifdef HAS_SCHEMA_4x3_rc2 - #include "../ifcparse/schemas/Ifc4x3_rc2.h" -#endif -#ifdef HAS_SCHEMA_4x3_rc3 - #include "../ifcparse/schemas/Ifc4x3_rc3.h" -#endif -#ifdef HAS_SCHEMA_4x3_rc4 - #include "../ifcparse/schemas/Ifc4x3_rc4.h" -#endif -#ifdef HAS_SCHEMA_4x3 - #include "../ifcparse/schemas/Ifc4x3.h" -#endif -#ifdef HAS_SCHEMA_4x3_tc1 - #include "../ifcparse/schemas/Ifc4x3_tc1.h" -#endif -#ifdef HAS_SCHEMA_4x3_add1 - #include "../ifcparse/schemas/Ifc4x3_add1.h" -#endif -#ifdef HAS_SCHEMA_4x3_add2 - #include "../ifcparse/schemas/Ifc4x3_add2.h" -#endif - #include "../ifcparse/express.h" #include "../ifcparse/file.h" #include "../ifcparse/schema.h" @@ -327,6 +240,9 @@ #include "../ifcgeom/ConversionResult.h" #include "../svgfill/src/svgfill.h" + + // @todo abstract into plug-in interface + #include "../serializers/RocksDbSerializer.h" %} %include "IfcGeomWrapper.i"