Browse files

install/uninstall scripts.

- cmake scripts for installing to unix standard dirs
- loading plugins from ${_prefix}/lib/kdots/plugins
  • Loading branch information...
1 parent 60f1aa0 commit 38e67a1b480e6b74fb70ccf0a4eab9886c45147c @Ignotus committed Aug 6, 2012
Showing with 72 additions and 11 deletions.
  1. +19 −2 CMakeLists.txt
  2. +22 −0 cmake_uninstall.cmake.in
  3. +3 −0 include/plugincontainer.hpp
  4. +23 −7 plugincontainer.cpp
  5. +5 −2 plugins/singlepc/CMakeLists.txt
View
21 CMakeLists.txt
@@ -18,10 +18,15 @@ INCLUDE_DIRECTORIES (
)
SET (PLUGIN_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/plugins)
-
-
SET (KDOTS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+IF (UNIX)
+ SET (LIBDIR ${INSTALL_PREFIX}/lib${LIB_SUFFIX})
+ SET (PLUGINS_DIR ${LIBDIR}/kdots/plugins)
+ SET (BINDIR bin)
+ ADD_DEFINITIONS (-DPLUGINS_DIR="${PLUGINS_DIR}")
+ENDIF (UNIX)
+
SET (SRCS
graphpoint.cpp
graph.cpp
@@ -87,4 +92,16 @@ TARGET_LINK_LIBRARIES (kdots
${QT_LIBRARIES}
)
+IF (UNIX)
+ INSTALL (TARGETS kdots DESTINATION ${BINDIR})
+ENDIF (UNIX)
+# uninstall target
+CONFIGURE_FILE (
+ "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
+ IMMEDIATE @ONLY)
+
+ADD_CUSTOM_TARGET (uninstall
+ COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
+
ADD_SUBDIRECTORY (plugins)
View
22 cmake_uninstall.cmake.in
@@ -0,0 +1,22 @@
+if (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+ message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
+endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+
+file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
+string(REGEX REPLACE "\n" ";" files "${files}")
+list(REVERSE files)
+foreach (file ${files})
+ message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
+ if (EXISTS "$ENV{DESTDIR}${file}")
+ execute_process(
+ COMMAND @CMAKE_COMMAND@ -E remove "$ENV{DESTDIR}${file}"
+ OUTPUT_VARIABLE rm_out
+ RESULT_VARIABLE rm_retval
+ )
+ if(NOT ${rm_retval} EQUAL 0)
+ message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
+ endif (NOT ${rm_retval} EQUAL 0)
+ else (EXISTS "$ENV{DESTDIR}${file}")
+ message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
+ endif (EXISTS "$ENV{DESTDIR}${file}")
+endforeach(file)
View
3 include/plugincontainer.hpp
@@ -19,6 +19,8 @@
#define KDOTS_PLUGINCONTAINER_HPP
#include <QMap>
+class QDir;
+
namespace KDots
{
class IPlugin;
@@ -47,6 +49,7 @@ namespace KDots
private:
void loadPlugins ();
+ bool findPlugin (const QDir& dir);
};
}
View
30 plugincontainer.cpp
@@ -30,21 +30,18 @@ namespace KDots
static PluginContainer obj;
return obj;
}
-
- void PluginContainer::loadPlugins ()
+
+ bool PluginContainer::findPlugin (const QDir& pluginsDir)
{
- //TODO: Plugins must be situated in the system unix directory
- QDir pluginsDir (qApp->applicationDirPath ());
- pluginsDir.cd ("plugins");
- qDebug () << Q_FUNC_INFO << "Loading plugins...";
-
+ bool foundFlag = false;
for (const QString& fileName : pluginsDir.entryList ({PLUGIN_SUFFIX + "*"}, QDir::Files))
{
QPluginLoader pluginLoader (pluginsDir.absoluteFilePath (fileName));
IPlugin *iplugin = qobject_cast<IPlugin *> (pluginLoader.instance ());
if (iplugin)
{
+ foundFlag = true;
qDebug () << Q_FUNC_INFO << "Loading the plugin:" << iplugin->name ();
m_pluginMap.insert (iplugin->name (), iplugin);
}
@@ -54,5 +51,24 @@ namespace KDots
qDebug () << Q_FUNC_INFO << "Cannot load the plugin " << fileName;
}
}
+
+ return foundFlag;
+ }
+
+ void PluginContainer::loadPlugins ()
+ {
+ QDir currentDir (qApp->applicationDirPath ());
+ if (!currentDir.cd ("plugins") || !findPlugin (currentDir))
+ {
+#ifdef Q_OS_UNIX
+ QDir libdir (PLUGINS_DIR);
+ if (!libdir.exists () || !findPlugin (libdir))
+ qDebug () << Q_FUNC_INFO << "Plugins not found in " << libdir.absolutePath ();
+#else
+ qDebug () << Q_FUNC_INFO << "Plugins not found";
+#endif
+ }
+
+
}
}
View
7 plugins/singlepc/CMakeLists.txt
@@ -27,19 +27,22 @@ TARGET_LINK_LIBRARIES (kdots_singlepc
${QT_LIBRARIES}
)
+IF (UNIX)
+ INSTALL (TARGETS kdots_singlepc DESTINATION ${PLUGINS_DIR})
+ENDIF (UNIX)
IF (UNIX)
ADD_CUSTOM_COMMAND(
TARGET kdots_singlepc
POST_BUILD
- COMMAND mv ARGS ${CMAKE_CURRENT_BINARY_DIR}/libkdots_singlepc.so
+ COMMAND cp ARGS ${CMAKE_CURRENT_BINARY_DIR}/libkdots_singlepc.so
${PLUGIN_BUILD_DIR}
)
ELSE (UNIX)
ADD_CUSTOM_COMMAND(
TARGET kdots_singlepc
POST_BUILD
- COMMAND move ARGS ${CMAKE_CURRENT_BINARY_DIR}/libkdots_singlepc.so
+ COMMAND copy ARGS ${CMAKE_CURRENT_BINARY_DIR}/libkdots_singlepc.so
${PLUGIN_BUILD_DIR}
)
ENDIF (UNIX)

0 comments on commit 38e67a1

Please sign in to comment.