solved critical bug for MESHLAB_VERSION under cmake, add checker for plugin versions

This commit is contained in:
alemuntoni 2021-02-10 11:57:03 +01:00
parent 33c7986bed
commit df3aaaab69
4 changed files with 35 additions and 10 deletions

View File

@ -52,14 +52,6 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
### Build Settings
if (BUILD_WITH_DOUBLE_SCALAR)
message(STATUS "Building with double precision")
add_definitions(-DMESHLAB_SCALAR=double)
else()
message(STATUS "Building with single precision")
add_definitions(-DMESHLAB_SCALAR=float)
endif()
if(WIN32)
add_definitions(-DNOMINMAX)
if(MSVC)

View File

@ -3,10 +3,20 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../ML_VERSION")
if (BUILD_WITH_DOUBLE_SCALAR)
set(MESHLAB_VERSION "${MESHLAB_VERSION}d")
endif()
add_definitions(-DMESHLAB_VERSION=${MESHLAB_VERSION})
#add_definitions(-DMESHLAB_VERSION=${MESHLAB_VERSION})
message(STATUS "MeshLab version: ${MESHLAB_VERSION}")
endif()
if (BUILD_WITH_DOUBLE_SCALAR)
message(STATUS "Building with double precision")
set(MESHLAB_SCALAR "double")
#add_definitions(-DMESHLAB_SCALAR=double)
else()
message(STATUS "Building with single precision")
set(MESHLAB_SCALAR "float")
#add_definitions(-DMESHLAB_SCALAR=float)
endif()
set(HEADERS
globals.h
plugins/interfaces/plugin_file_interface.h
@ -81,6 +91,11 @@ if(WIN32)
endif()
add_library(meshlab-common ${TARGET_TYPE} ${SOURCES} ${HEADERS} ${RESOURCES})
target_compile_definitions(meshlab-common
PUBLIC
MESHLAB_VERSION=${MESHLAB_VERSION}
MESHLAB_SCALAR=${MESHLAB_SCALAR})
target_include_directories(meshlab-common
PRIVATE
${EXTERNAL_DIR}/easyexif/

View File

@ -29,6 +29,13 @@
#include <QString>
#ifndef MESHLAB_VERSION
#error "MESHLAB_VERSION needs to be defined!"
#endif
#ifndef MESHLAB_SCALAR
#error "MESHLAB_SCALAR needs to be defined!"
#endif
class RichParameterList;
class PluginManager;

View File

@ -130,9 +130,20 @@ void PluginManager::loadPlugin(const QString& fileName)
if (!ifp){
throw MLException(fin.fileName() + " is not a MeshLab plugin.");
}
if (ifp && ifp->getMLVersion().second != MeshLabScalarTest<Scalarm>::doublePrecision()) {
if (ifp->getMLVersion().second != MeshLabScalarTest<Scalarm>::doublePrecision()) {
throw MLException(fin.fileName() + " has different floating point precision from the running MeshLab version.");
}
std::string mlVersionPlug = ifp->getMLVersion().first;
std::string majorVersionPlug = mlVersionPlug.substr(0, 4); //4 is the position of '.' in meshlab version
std::string majorVersionML = meshlab::meshlabVersion().substr(0, 4);
if (majorVersionML != majorVersionPlug){
throw MLException(fin.fileName() + " has different major version from the running MeshLab version.");
}
std::string minorVersionPlug = mlVersionPlug.substr(5, mlVersionPlug.size());
std::string minorVersionML = meshlab::meshlabVersion().substr(5, meshlab::meshlabVersion().size());
if (std::stoi(minorVersionPlug) > std::stoi(minorVersionML)){
throw MLException(fin.fileName() + " has greater version from the running MeshLab version. Please update MeshLab to use it.");
}
//TODO: check in some way also the meshlab version of the plugin