Stephen Kelly wrote:

> Alexander Neundorf wrote:
> 
>> On Monday 02 February 2009, Stephen Kelly wrote:
>>> Hi,
>>>
>>> I'm trying to make it easier to build KJots.
>>>
>>> Currently it is necessary to checkout the entire kdepim module to build
>>> it because the main application needs to be a KPIM::UniqueApplication so
>>> that it functions as a kontact plugin.
>>>
>>> To make it simpler, I want to make building the kontact plugin optional.
>>> The aim is to be able to tell new contributors to:
>>>
>>> svn co svn://anonsvn.kde.org/home/kde/trunk/KDE/kdepim/kjots
>>> mkdir build && cd build
>>> cmake ..
>>> make
>> 
>> Making modular builds easier is on my TODO for 4.3, so I will have a look
>> at this in the next weeks.
>> We need a nice way to do this, so it can be used easily everywhere.
> 
> As a stop-gap solution, I'd like to use the attached patch, and let new
> contributors know that they can use -DNOKONTACTPLUGIN to compile only
> kjots.
> 
> Is there anything wrong with it? Is this the right/wrong way to do this
> stuff?
> 
> Steve.
> 
> PS: Why is this list unidirectional through gmane? Any objection to
> getting that changed so I can post through knode easily?
> 
>> 
>> Alex

Patch attached.
Index: main.cpp
===================================================================
--- main.cpp	(revision 920269)
+++ main.cpp	(working copy)
@@ -26,10 +26,13 @@
 #include "KJotsMain.h"
 #include "aboutdata.h"
 
-// if building kontact plugin:
+// Make KJots a KPIMApplication if we are building the kontact plugin.
+#ifdef NOKONTACTPLUGIN
 #include <libkdepim/pimapplication.h>
-// #else
-// #include <kuniqueapplication.h>
+#else
+#include <kuniqueapplication.h>
+#endif
+
 #include <kcmdlineargs.h>
 #include <kconfig.h>
 #include <kdebug.h>
@@ -42,24 +45,23 @@
     AboutData aboutData;
     KCmdLineArgs::init(argc, argv, &aboutData);
 
-    // if building kontact plugin:
+#ifdef NOKONTACTPLUGIN
     KPIM::PimApplication::addCmdLineOptions();
     if (!KPIM::PimApplication::start()) {
         kWarning() << "kjots is already running!";
         exit(0);
     }
     KPIM::PimApplication a;
-    // else:
-    //
-//     KUniqueApplication::addCmdLineOptions();
-//     if (!KUniqueApplication::start()) {
-//         fprintf(stderr, "kjots is already running!\n");
-//         exit(0);
-//     }
-//     KUniqueApplication a;
+#else
+    KUniqueApplication::addCmdLineOptions();
+    if (!KUniqueApplication::start()) {
+       fprintf(stderr, "kjots is already running!\n");
+       exit(0);
+    }
+    KUniqueApplication a;
+#endif
 
 
-
     // backwards compatibility code to convert "old" user font settings
     // to the new config settings
     KConfigGroup config(KGlobal::config(), "kjots");
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt	(revision 920269)
+++ CMakeLists.txt	(working copy)
@@ -9,10 +9,15 @@
 
 include_directories( ${KDE4_INCLUDES} )
 
-# Make sure libkdepim/pimapplication.h can be found.
-# If building kontact plugin:
-include_directories( ${PROJECT_BINARY_DIR}/../ ${PROJECT_SOURCE_DIR}/../ )
+option(NOKONTACTPLUGIN
+  "Define this to build without the kontact plugin. Not recommended for distributors. Only used to simplify requirements for new contributors."
+)
 
+if ( NOKONTACTPLUGIN )
+  # Make sure libkdepim/pimapplication.h can be found.
+  include_directories( ${PROJECT_BINARY_DIR}/../ ${PROJECT_SOURCE_DIR}/../ )
+endif ( NOKONTACTPLUGIN )
+
 #########################################################################
 # Code common to the kjots application and the kontact plugin
 #########################################################################
@@ -36,20 +41,11 @@
 
 kde4_add_ui_files(kjots_common_SRCS confpagemisc.ui )
 
-kde4_add_library(kjots_common ${kjots_common_SRCS} )
-
-
-
-
-
-#########################################################################
-# D-Bus interface
-#########################################################################
-
 qt4_generate_dbus_interface( kjotscomponent.h org.kde.KJotsComponent.xml OPTIONS -m )
-qt4_add_dbus_interfaces(kjots_SRCS
+qt4_add_dbus_interfaces(kjots_common_SRCS
     ${PROJECT_BINARY_DIR}/org.kde.KJotsComponent.xml)
 
+kde4_add_library(kjots_common ${kjots_common_SRCS} )
 
 #########################################################################
 # Main Application SECTION
@@ -67,10 +63,11 @@
   ${KDE4_KIO_LIBS}
 )
 
-# If building kontact plugin:
-target_link_libraries(kjots
-  kdepim
-)
+if (NOT NOKONTACTPLUGIN )
+  target_link_libraries(kjots
+    kdepim
+  )
+endif (NOT NOKONTACTPLUGIN )
 
 install(TARGETS kjots  ${INSTALL_TARGETS_DEFAULT_ARGS} )
 
@@ -82,25 +79,26 @@
 install( FILES kjotsui.rc  DESTINATION ${DATA_INSTALL_DIR}/kjots)
 
 
+# This stuff is only used for building the kontact plugin.
+if (NOT NOKONTACTPLUGIN )
+  #########################################################################
+  # KPART SECTION
+  #########################################################################
 
-# If building kontact plugin:
-#########################################################################
-# KPART SECTION
-#########################################################################
+  # This part is loaded by kontact if kjots is embedded in it.
 
-# This part is loaded by kontact if kjots is embedded in it.
+  set(kjotspart_PART_SRCS
+     kjotspart.cpp
+   )
 
-set(kjotspart_PART_SRCS
-   kjotspart.cpp
- )
+  kde4_add_plugin(kjotspart ${kjotspart_PART_SRCS}
+  )
 
-kde4_add_plugin(kjotspart ${kjotspart_PART_SRCS}
-)
 
+  target_link_libraries(kjotspart kjots_common ${KDE4_KPARTS_LIBS} kdepim)
 
-target_link_libraries(kjotspart kjots_common ${KDE4_KPARTS_LIBS} kdepim)
+  install( FILES kjotspart.desktop  DESTINATION ${SERVICES_INSTALL_DIR} )
+  install( FILES kjotspartui.rc  DESTINATION ${DATA_INSTALL_DIR}/kjots)
 
-install( FILES kjotspart.desktop  DESTINATION ${SERVICES_INSTALL_DIR} )
-install( FILES kjotspartui.rc  DESTINATION ${DATA_INSTALL_DIR}/kjots)
-
-install(TARGETS kjotspart  DESTINATION ${PLUGIN_INSTALL_DIR} )
+  install(TARGETS kjotspart  DESTINATION ${PLUGIN_INSTALL_DIR} )
+endif (NOT NOKONTACTPLUGIN )

_______________________________________________
Kde-buildsystem mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/kde-buildsystem

Reply via email to