diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 78a006ce1..5e6e14e70 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -105,8 +105,13 @@ else() endif() set(MESHLAB_BUILD_DISTRIB_DIR ${CMAKE_CURRENT_BINARY_DIR}/distrib) -set(MESHLAB_PLUGIN_OUTPUT_DIR ${MESHLAB_BUILD_DISTRIB_DIR}/plugins) -set(MESHLAB_SHADER_OUTPUT_DIR ${MESHLAB_BUILD_DISTRIB_DIR}/shaders) +if (APPLE) + set(MESHLAB_PLUGIN_OUTPUT_DIR ${MESHLAB_BUILD_DISTRIB_DIR}/meshlab.app/Contents/PlugIns) + set(MESHLAB_SHADER_OUTPUT_DIR ${MESHLAB_BUILD_DISTRIB_DIR}/meshlab.app/Contents/shaders) +else() + set(MESHLAB_PLUGIN_OUTPUT_DIR ${MESHLAB_BUILD_DISTRIB_DIR}/plugins) + set(MESHLAB_SHADER_OUTPUT_DIR ${MESHLAB_BUILD_DISTRIB_DIR}/shaders) +endif() set(MESHLAB_SAMPLE_OUTPUT_DIR ${MESHLAB_BUILD_DISTRIB_DIR}/sample) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${MESHLAB_BUILD_DISTRIB_DIR}) @@ -119,16 +124,21 @@ include_directories(${EIGEN_INCLUDE_DIRS}) add_definitions(-DMESHLAB_SCALAR=float) -if(BUILD_STRICT AND NOT MSVC) +if(BUILD_STRICT AND NOT MSVC AND NOT APPLE) # Make sure that our shared libraries were appropriately linked set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined") set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined") endif() +if (BUILD_STRICT AND APPLE) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-undefined,error") + set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-undefined,error") +endif() + if(WIN32) add_definitions(-DNOMINMAX) if(MSVC) - add_definitions(-D_CRT_SECURE_NO_DEPRECATE) + add_definitions(-D_CRT_SECURE_NO_DEPRECATE) endif() endif() diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 1a8da3eea..6de180650 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -78,6 +78,16 @@ target_link_libraries( set_property(TARGET common PROPERTY FOLDER Core) +if (APPLE) + set_property( + TARGET common + PROPERTY RUNTIME_OUTPUT_DIRECTORY ${MESHLAB_BUILD_DISTRIB_DIR}/meshlab.app/Contents/Frameworks) + + set_property( + TARGET common + PROPERTY LIBRARY_OUTPUT_DIRECTORY ${MESHLAB_BUILD_DISTRIB_DIR}/meshlab.app/Contents/Frameworks) +endif() + if(NOT WIN32) install(TARGETS common DESTINATION ${MESHLAB_LIB_INSTALL_DIR}) endif() diff --git a/src/common/pluginmanager.cpp b/src/common/pluginmanager.cpp index 477e47256..884c466d8 100644 --- a/src/common/pluginmanager.cpp +++ b/src/common/pluginmanager.cpp @@ -7,38 +7,35 @@ #include "mlexception.h" - - -static QString DLLExtension() { +static QStringList fileNamePluginDLLs() { + QStringList l; #if defined(Q_OS_WIN) - return QString("dll"); + l.push_back("*.dll"); + return l; #elif defined(Q_OS_MAC) - return QString("dylib"); -#else - return QString("so"); + l.push_back("*.dylib"); + l.push_back("*.so"); + return l; +#else //linux + l.push_back("*.so"); + return l; #endif - assert(0 && "Unknown Operative System. Please Define the appropriate dynamic library extension"); - return QString(); } -static QString DLLFileNamePreamble() { +static QString fileNamePrefixPluginDLLs() { #if defined(Q_OS_WIN) - return QString(""); -#elif defined(Q_OS_MAC) - return QString("lib"); -#else - return QString("lib"); + return QString(""); +#else //macos and linux + return QString("lib"); #endif - assert(0 && "Unknown Operative System. Please Define the appropriate dynamic library preamble"); - return QString(); } PluginManager::PluginManager() { - //pluginsDir=QDir(getPluginDirPath()); - // without adding the correct library path in the mac the loading of jpg (done via qt plugins) fails - //qApp->addLibraryPath(getPluginDirPath()); - //qApp->addLibraryPath(getBaseDirPath()); + //pluginsDir=QDir(getPluginDirPath()); + // without adding the correct library path in the mac the loading of jpg (done via qt plugins) fails + //qApp->addLibraryPath(getPluginDirPath()); + //qApp->addLibraryPath(getBaseDirPath()); } PluginManager::~PluginManager() @@ -50,7 +47,7 @@ PluginManager::~PluginManager() for (PluginInterface* plugin : ownerPlug) delete plugin; ownerPlug.clear(); - + for (int ii = 0; ii < meshEditInterfacePlug.size(); ++ii) delete meshEditInterfacePlug[ii]; meshEditInterfacePlug.clear(); @@ -69,13 +66,11 @@ void PluginManager::loadPlugins(RichParameterList& defaultGlobal, const QDir& pl // without adding the correct library path in the mac the loading of jpg (done via qt plugins) fails qApp->addLibraryPath(getDefaultPluginDirPath()); qApp->addLibraryPath(getBaseDirPath()); - QStringList pluginfilters; - - pluginfilters << QString("*." + DLLExtension()); - + QStringList nameFiltersPlugins = fileNamePluginDLLs(); + //only the file with extension pluginfilters will be listed by function entryList() - pluginsDir.setNameFilters(pluginfilters); - + pluginsDir.setNameFilters(nameFiltersPlugins); + qDebug("Current Plugins Dir is: %s ", qUtf8Printable(pluginsDir.absolutePath())); for(QString fileName : pluginsDir.entryList(QDir::Files)) { @@ -116,7 +111,7 @@ void PluginManager::loadPlugins(RichParameterList& defaultGlobal, const QDir& pl iCommon = iIO; meshIOPlug.push_back(iIO); } - + DecoratePluginInterface *iDecorator = qobject_cast(plugin); if (iDecorator) { @@ -128,14 +123,14 @@ void PluginManager::loadPlugins(RichParameterList& defaultGlobal, const QDir& pl iDecorator->initGlobalParameterList(decoratorAction, defaultGlobal); } } - + RenderPluginInterface *iRender = qobject_cast(plugin); if (iRender) { iCommon = iRender; meshRenderPlug.push_back(iRender); } - + EditPluginInterfaceFactory *iEditFactory = qobject_cast(plugin); if (iEditFactory) { @@ -164,13 +159,13 @@ int PluginManager::numberIOPlugins() const // Search among all the decorator plugins the one that contains a decoration with the given name DecoratePluginInterface *PluginManager::getDecoratorInterfaceByName(const QString& name) { - foreach(DecoratePluginInterface *tt, this->meshDecoratePlugins()) - { - foreach( QAction *ac, tt->actions()) - if( name == tt->decorationName(ac) ) return tt; - } - assert(0); - return 0; + foreach(DecoratePluginInterface *tt, this->meshDecoratePlugins()) + { + foreach( QAction *ac, tt->actions()) + if( name == tt->decorationName(ac) ) return tt; + } + assert(0); + return 0; } /* @@ -188,7 +183,7 @@ QMap PluginManager::generateFilterParameterMap() for (ai = this->actionFilterMap.begin(); ai != this->actionFilterMap.end(); ++ai) { QString filterName = ai.key();// ->filterName(); - //QAction act(filterName,NULL); + //QAction act(filterName,NULL); RichParameterList rp; stringFilterMap[filterName]->initParameterList(ai.value(), md, rp); FPM[filterName] = rp; @@ -196,31 +191,26 @@ QMap PluginManager::generateFilterParameterMap() return FPM; } -QString PluginManager::osDependentFileBaseName(const QString &plname) -{ - return (DLLFileNamePreamble() + plname + "." + DLLExtension()); -} - QString PluginManager::getBaseDirPath() { QDir baseDir(qApp->applicationDirPath()); - + #if defined(Q_OS_WIN) // Windows: // during development with visual studio binary could be in the debug/release subdir. // once deployed plugins dir is in the application directory, so if (baseDir.dirName() == "debug" || baseDir.dirName() == "release") baseDir.cdUp(); #endif - + #if defined(Q_OS_MAC) - // Mac: during developmentwith xcode and well deployed the binary is well buried. - for(int i=0;i<6;++i){ - if(baseDir.exists("plugins")) break; - baseDir.cdUp(); - } - qDebug("The base dir is %s", qUtf8Printable(baseDir.absolutePath())); + // Mac: during developmentwith xcode and well deployed the binary is well buried. + for(int i=0;i<6;++i){ + if(baseDir.exists("plugins")) break; + baseDir.cdUp(); + } + qDebug("The base dir is %s", qUtf8Printable(baseDir.absolutePath())); #endif - return baseDir.absolutePath(); + return baseDir.absolutePath(); } QString PluginManager::getDefaultPluginDirPath() @@ -230,7 +220,7 @@ QString PluginManager::getDefaultPluginDirPath() QString d = pluginsDir.dirName(); QString dLower = d.toLower(); if (dLower == "release" || dLower == "relwithdebinfo" || dLower == "debug" || - dLower == "minsizerel") { + dLower == "minsizerel") { // This is a configuration directory for MS Visual Studio. pluginsDir.cdUp(); } else { @@ -239,18 +229,18 @@ QString PluginManager::getDefaultPluginDirPath() #endif if (pluginsDir.exists("plugins")) { pluginsDir.cd("plugins"); - + #if defined(Q_OS_WIN) // Re-apply the configuration dir, if any. if (!d.isEmpty() && pluginsDir.exists(d)) { pluginsDir.cd(d); } #endif - + return pluginsDir.absolutePath(); } #if !defined(Q_OS_MAC) && !defined(Q_OS_WIN) - else if (pluginsDir.dirName() == "bin") { + else if (pluginsDir.dirName() == "bin") { pluginsDir.cdUp(); pluginsDir.cd("lib"); pluginsDir.cd("meshlab"); @@ -293,9 +283,9 @@ void PluginManager::knownIOFormats() for (QList::iterator itf = format.begin(); itf != format.end(); ++itf) { IOPluginInterface::Format currentFormat = *itf; - + QString currentFilterEntry = currentFormat.description + " ("; - + //a particular file format could be associated with more than one file extension QStringListIterator itExtension(currentFormat.extensions); while (itExtension.hasNext()) @@ -313,7 +303,7 @@ void PluginManager::knownIOFormats() currentFilterEntry.append(')'); formatFilters->append(currentFilterEntry); } - + } allKnownFormatsFilter.append(')'); if (formatFilters != NULL) @@ -325,7 +315,7 @@ QString PluginManager::osIndependentPluginName(const QString& plname) { QFileInfo fi(plname); QString res = fi.baseName(); - QString pref = DLLFileNamePreamble(); + QString pref = fileNamePrefixPluginDLLs(); return res.remove(0, pref.size()); } diff --git a/src/common/pluginmanager.h b/src/common/pluginmanager.h index f10982470..fc5fb60bc 100644 --- a/src/common/pluginmanager.h +++ b/src/common/pluginmanager.h @@ -82,7 +82,6 @@ public: QStringList pluginsLoaded; - static QString osDependentFileBaseName(const QString& plname); static QString osIndependentPluginName(const QString& plname); private: diff --git a/src/meshlab/CMakeLists.txt b/src/meshlab/CMakeLists.txt index d931250da..978b21449 100644 --- a/src/meshlab/CMakeLists.txt +++ b/src/meshlab/CMakeLists.txt @@ -74,10 +74,6 @@ set(UI ui/savesnapshotDialog.ui) set(CMAKE_AUTOUIC_SEARCH_PATHS ${CMAKE_CURRENT_SOURCE_DIR}/ui) -#if(APPLE) -# list(APPEND SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../install/macx/info.plist -# images/meshlab.icns) -#endif() if(WIN32) list(APPEND SOURCES meshlab.rc) @@ -95,6 +91,8 @@ target_link_libraries( ) set_property(TARGET meshlab PROPERTY FOLDER Core) +set_target_properties(meshlab PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist) +set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/images/meshlab.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") install( TARGETS meshlab