diff --git a/cMake/FreeCAD_Helpers/ConfigureCMakeVariables.cmake b/cMake/FreeCAD_Helpers/ConfigureCMakeVariables.cmake index ce429c9324..708bad0697 100644 --- a/cMake/FreeCAD_Helpers/ConfigureCMakeVariables.cmake +++ b/cMake/FreeCAD_Helpers/ConfigureCMakeVariables.cmake @@ -24,6 +24,7 @@ macro(ConfigureCMakeVariables) # used as compiler defines set(RESOURCEDIR "${CMAKE_INSTALL_DATADIR}") + set(LIBRARYDIR "${CMAKE_INSTALL_LIBDIR}") set(DOCDIR "${CMAKE_INSTALL_DOCDIR}") message(STATUS "prefix: ${CMAKE_INSTALL_PREFIX}") diff --git a/src/App/Application.cpp b/src/App/Application.cpp index 0cf66135a5..fb1a577356 100644 --- a/src/App/Application.cpp +++ b/src/App/Application.cpp @@ -1139,6 +1139,16 @@ std::string Application::getResourceDir() #endif } +std::string Application::getLibraryDir() +{ +#ifdef LIBRARYDIR + std::string path(LIBRARYDIR); + return mConfig["AppHomePath"] + path; +#else + return mConfig["AppHomePath"] + "lib"; +#endif +} + std::string Application::getHelpDir() { #ifdef DOCDIR diff --git a/src/App/Application.h b/src/App/Application.h index 719961def1..6b86d9b843 100644 --- a/src/App/Application.h +++ b/src/App/Application.h @@ -410,6 +410,7 @@ public: static std::string getUserAppDataDir(); static std::string getUserMacroDir(); static std::string getResourceDir(); + static std::string getLibraryDir(); static std::string getHelpDir(); //@} @@ -519,6 +520,7 @@ private: static PyObject* sChangeExportModule(PyObject *self,PyObject *args); static PyObject* sGetExportType (PyObject *self,PyObject *args); static PyObject* sGetResourcePath (PyObject *self,PyObject *args); + static PyObject* sGetLibraryPath (PyObject *self,PyObject *args); static PyObject* sGetTempPath (PyObject *self,PyObject *args); static PyObject* sGetUserCachePath (PyObject *self,PyObject *args); static PyObject* sGetUserConfigPath (PyObject *self,PyObject *args); diff --git a/src/App/ApplicationPy.cpp b/src/App/ApplicationPy.cpp index 6d04d72405..e9f8e27e4b 100644 --- a/src/App/ApplicationPy.cpp +++ b/src/App/ApplicationPy.cpp @@ -78,6 +78,8 @@ PyMethodDef Application::Methods[] = { "Get the name of the module that can export the filetype"}, {"getResourceDir", (PyCFunction) Application::sGetResourcePath, METH_VARARGS, "Get the root directory of all resources"}, + {"getLibraryDir", (PyCFunction) Application::sGetLibraryPath, METH_VARARGS, + "Get the directory of all extension modules"}, {"getTempPath", (PyCFunction) Application::sGetTempPath, METH_VARARGS, "Get the root directory of cached files"}, {"getUserCachePath", (PyCFunction) Application::sGetUserCachePath, METH_VARARGS, @@ -647,6 +649,15 @@ PyObject* Application::sGetResourcePath(PyObject * /*self*/, PyObject *args) return Py::new_reference_to(datadir); } +PyObject* Application::sGetLibraryPath(PyObject * /*self*/, PyObject *args) +{ + if (!PyArg_ParseTuple(args, "")) + return nullptr; + + Py::String datadir(Application::getLibraryDir(),"utf-8"); + return Py::new_reference_to(datadir); +} + PyObject* Application::sGetTempPath(PyObject * /*self*/, PyObject *args) { if (!PyArg_ParseTuple(args, "")) diff --git a/src/App/CMakeLists.txt b/src/App/CMakeLists.txt index cf28254422..7ebe15135e 100644 --- a/src/App/CMakeLists.txt +++ b/src/App/CMakeLists.txt @@ -12,6 +12,10 @@ IF(RESOURCEDIR) add_definitions(-DRESOURCEDIR="${RESOURCEDIR}") ENDIF(RESOURCEDIR) +IF(LIBRARYDIR) + add_definitions(-DLIBRARYDIR="${LIBRARYDIR}") +ENDIF(LIBRARYDIR) + IF(DOCDIR) add_definitions(-DDOCDIR="${DOCDIR}") ENDIF(DOCDIR) diff --git a/src/App/FreeCADInit.py b/src/App/FreeCADInit.py index be22a7d83b..1972f8a4dd 100644 --- a/src/App/FreeCADInit.py +++ b/src/App/FreeCADInit.py @@ -104,6 +104,10 @@ def InitApplications(): LibPyDir = os.path.realpath(LibPyDir) if (os.path.exists(LibPyDir)): libpaths.append(LibPyDir) + LibFcDir = FreeCAD.getLibraryDir() + LibFcDir = os.path.realpath(LibFcDir) + if (os.path.exists(LibFcDir) and not LibFcDir in libpaths): + libpaths.append(LibFcDir) AddPath = FreeCAD.ConfigGet("AdditionalModulePaths").split(";") HomeMod = FreeCAD.getUserAppDataDir()+"Mod" HomeMod = os.path.realpath(HomeMod)