diff --git a/src/external/u3d.cmake b/src/external/u3d.cmake index fb446a929..cc6d7b152 100644 --- a/src/external/u3d.cmake +++ b/src/external/u3d.cmake @@ -5,19 +5,18 @@ option(MESHLAB_ALLOW_DOWNLOAD_SOURCE_U3D "Allow download and use of u3d source" ON) if(MESHLAB_ALLOW_DOWNLOAD_SOURCE_U3D) - # todo - make release of u3d - set(U3D_DIR "${MESHLAB_EXTERNAL_DOWNLOAD_DIR}/u3d-master") + set(U3D_DIR "${MESHLAB_EXTERNAL_DOWNLOAD_DIR}/u3d-1.5.0") set(U3D_CHECK "${U3D_DIR}/CMakeLists.txt") if (NOT EXISTS ${U3D_CHECK}) set(U3D_LINK - https://github.com/alemuntoni/u3d/archive/refs/heads/master.zip - https://www.meshlab.net/data/libs/u3d-master.zip) - #set(U3D_MD5 3b15b2f75206ea24b8991333562aa9ca) + https://github.com/alemuntoni/u3d/archive/refs/tags/1.5.0.zip + https://www.meshlab.net/data/libs/u3d-1.5.0.zip) + set(U3D_MD5 9f940835cfc08d17169b8003fabec1c6) download_and_unzip( NAME "u3d" LINK ${U3D_LINK} - #MD5 ${U3D_MD5} + MD5 ${U3D_MD5} DIR ${MESHLAB_EXTERNAL_DOWNLOAD_DIR}) if (NOT download_and_unzip_SUCCESS) message(STATUS "- u3d - download failed.") @@ -25,17 +24,22 @@ if(MESHLAB_ALLOW_DOWNLOAD_SOURCE_U3D) endif() if (EXISTS ${U3D_CHECK}) - message(STATUS "- u3d - using bundled source") + message(STATUS "- u3d - using downloaded source") + set(U3D_BUILD_LIBIDTF_TEST OFF) + set(U3D_BUILD_IDTF_TO_U3D_BIN OFF) + set(U3D_BUILD_STATIC_IDTF_LIB OFF) set(MESSAGE_QUIET ON) add_subdirectory(${U3D_DIR}) unset(MESSAGE_QUIET) + unset(U3D_BUILD_LIBIDTF_TEST) + unset(U3D_BUILD_IDTF_TO_U3D_BIN) install( TARGETS + IDTF IFXCore IFXExporting IFXScheduling - IDTF-to-U3D-converter DESTINATION ${MESHLAB_LIB_INSTALL_DIR}) endif() diff --git a/src/meshlabplugins/io_u3d/CMakeLists.txt b/src/meshlabplugins/io_u3d/CMakeLists.txt index 77d8b98f2..9dbc57717 100644 --- a/src/meshlabplugins/io_u3d/CMakeLists.txt +++ b/src/meshlabplugins/io_u3d/CMakeLists.txt @@ -1,18 +1,27 @@ # Copyright 2019-2020, Collabora, Ltd. # SPDX-License-Identifier: BSL-1.0 - # Only build if we have u3d -if(TARGET IDTF-to-U3D-converter) +if(TARGET IDTF) + # IDTF to U3D converter loads some dll/so files at runtime, thar may be placed in different + # places, depending on: + # - build or deploy stage + # - operative system + # The default paths are set for deploy stage (OS is detected automatically). + # If you are building (not deploying) MeshLab and you want to test the U3D exporter, enable this + # option. + # Without enabling this option, the U3D exporter WILL NOT WORK ON BUILD STAGE. + option(MESHLAB_U3D_BUILD_MODE "If you need to test u3d exporter in build mode (not deploy), enable this" OFF) set(SOURCES io_u3d.cpp) - set(HEADERS io_u3d.h) add_meshlab_plugin(io_u3d ${SOURCES} ${HEADERS}) + target_link_libraries(io_u3d PUBLIC IDTF) - target_link_libraries(io_u3d PUBLIC IDTF-to-U3D-converter IFXCoreStatic ${CMAKE_DL_LIBS}) - + if(MESHLAB_U3D_BUILD_MODE) + target_compile_definitions(io_u3d PRIVATE BUILD_MODE) + endif() else() message(STATUS "Skipping io_u3d - missing u3d in external directory.") endif() diff --git a/src/meshlabplugins/io_u3d/io_u3d.cpp b/src/meshlabplugins/io_u3d/io_u3d.cpp index bf9b876ed..bff0358ff 100644 --- a/src/meshlabplugins/io_u3d/io_u3d.cpp +++ b/src/meshlabplugins/io_u3d/io_u3d.cpp @@ -33,11 +33,23 @@ #include #include -#include "Converter.h" +#include using namespace std; using namespace vcg; +#ifdef BUILD_MODE +const std::string LIB_IDTF_PATH = "../external/downloads/u3d-1.5.0"; +#else +#ifdef __APPLE__ +const std::string LIB_IDTF_PATH = "../Frameworks"; +#elif __linux__ +const std::string LIB_IDTF_PATH = "../lib"; +#else +const std::string LIB_IDTF_PATH = "."; +#endif +#endif + U3DIOPlugin::U3DIOPlugin() : QObject(), IOPlugin() @@ -94,7 +106,12 @@ void U3DIOPlugin::save( //conversion from idtf to u3d int resCode = 0; - bool result = IDTFConverter::IDTFToU3d(tmp.toStdString(), filename, resCode, _param.positionQuality); + bool result = IDTFConverter::IDTFToU3d( + tmp.toStdString(), + filename, + resCode, + LIB_IDTF_PATH, + _param.positionQuality); if(result==false) { throw MLException("Error saving " + QString::fromStdString(filename) + ": \n" + vcg::tri::io::ExporterU3D::ErrorMsg(resCode) + " (" + QString::number(resCode) + ")");