From 15d0a434fa4f2255593d6cc62fa2223fd0247b86 Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Sun, 24 Jun 2007 14:24:44 +0000 Subject: [PATCH] Some modifications to the build system, that allow us to only use one main.cpp in the future. Of course, we will need a lot of #ifdefs there... I could not find out how to specify per-target #defines in cmake, so I use different source files named build_*.cpp that set a #define and #include main.cpp (actually, main_mono.cpp, which is to be renamed in the next commit). --- Quassel.kdevelop.filelist | 24 ++++++++---- src/CMakeLists.txt | 40 +++++++++----------- src/common/build_core.cpp | 22 +++++++++++ src/common/build_mono.cpp | 22 +++++++++++ src/common/build_qtgui.cpp | 22 +++++++++++ src/common/global.h | 2 +- src/common/main_mono.cpp | 76 ++++++++++++++++---------------------- 7 files changed, 132 insertions(+), 76 deletions(-) create mode 100644 src/common/build_core.cpp create mode 100644 src/common/build_mono.cpp create mode 100644 src/common/build_qtgui.cpp diff --git a/Quassel.kdevelop.filelist b/Quassel.kdevelop.filelist index 572f4e00..83a2e94b 100644 --- a/Quassel.kdevelop.filelist +++ b/Quassel.kdevelop.filelist @@ -1,13 +1,21 @@ # KDevelop Custom Project File List +dev-notes +dev-notes/builtin_cmds.obsolete.cpp +dev-notes/paulk-mainwindow.ui Makefile src src/client src/client/buffer.cpp src/client/buffer.h +src/client/buffertreemodel.cpp +src/client/buffertreemodel.h src/client/client.cpp src/client/client.h src/client/clientproxy.cpp src/client/clientproxy.h +src/client/CMakeLists.txt +src/client/treemodel.cpp +src/client/treemodel.h src/CMakeLists.txt src/common src/common/CMakeLists.txt @@ -21,6 +29,7 @@ src/common/main_mono.cpp src/common/message.cpp src/common/message.h src/common/proxy_common.h +src/common/quasselui.h src/common/settings.cpp src/common/settings.h src/common/util.cpp @@ -43,6 +52,8 @@ src/plugins src/plugins/plugin.h src/qtgui src/qtgui/bufferview.cpp +src/qtgui/bufferviewfilter.cpp +src/qtgui/bufferviewfilter.h src/qtgui/bufferview.h src/qtgui/bufferviewwidget.cpp src/qtgui/bufferviewwidget.h @@ -50,6 +61,8 @@ src/qtgui/bufferwidget.cpp src/qtgui/bufferwidget.h src/qtgui/channelwidgetinput.cpp src/qtgui/channelwidgetinput.h +src/qtgui/chatline.cpp +src/qtgui/chatline.h src/qtgui/chatwidget.cpp src/qtgui/chatwidget.h src/qtgui/CMakeLists.txt @@ -87,11 +100,6 @@ src/qtgui/ui/nickeditdlg.ui src/qtgui/ui/servereditdlg.ui src/qtgui/ui/serverlistdlg.ui src/qtgui/ui/settingsdlg.ui -src/common/quasselui.h -src/client/CMakeLists.txt -src/qtgui/chatline.cpp -src/qtgui/chatline.h -src/client/buffertreemodel.h -src/client/buffertreemodel.cpp -src/client/treemodel.cpp -src/client/treemodel.h +src/common/build_mono.cpp +src/common/build_qtgui.cpp +src/common/build_core.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 24713921..d84f7dfe 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,16 +6,16 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.4.3 FATAL_ERROR) # Select if Quassel should be built in client, server or monolithic mode SET(BUILD "mono" CACHE STRING "Defines which Quassel parts are to be built. Can contain 'core', 'gui' and/or 'monolithic' (which is the default), or 'all' to build everything.") SET(BUILD_CORE ) -SET(BUILD_CLIENT ) +SET(BUILD_QTGUI ) SET(BUILD_MONO ) IF(BUILD MATCHES "core" OR BUILD MATCHES "all") SET(BUILD_CORE true) MESSAGE("Building Quassel core.") ENDIF(BUILD MATCHES "core" OR BUILD MATCHES "all") -IF(BUILD MATCHES "client" OR BUILD MATCHES "all") - SET(BUILD_CLIENT true) - MESSAGE("Building Quassel GUI.") -ENDIF(BUILD MATCHES "client" OR BUILD MATCHES "all") +IF(BUILD MATCHES "gui" OR BUILD MATCHES "all") + SET(BUILD_QTGUI true) + MESSAGE("Building Quassel GUI for Qt.") +ENDIF(BUILD MATCHES "gui" OR BUILD MATCHES "all") IF(BUILD MATCHES "mono" OR BUILD MATCHES "all") SET(BUILD_MONO true) MESSAGE("Building monolithic Quassel.") @@ -24,16 +24,16 @@ IF(NOT BUILD_MONO AND NOT BUILD_CORE AND NOT BUILD_GUI) MESSAGE(FATAL_ERROR "\nYou have not selected which parts of Quassel I should build. Aborting.\nRun 'cmake -DBUILD=', where contains one or more of 'core', 'gui' or 'monolithic', or 'all' to build everything.\n") ENDIF(NOT BUILD_MONO AND NOT BUILD_CORE AND NOT BUILD_GUI) -IF(BUILD_CORE OR BUILD_CLIENT) +IF(BUILD_CORE OR BUILD_QTGUI) MESSAGE(FATAL_ERROR "\nBuilding of standalone core or GUI not supported at this time. Please check back later.\n") -ENDIF(BUILD_CORE OR BUILD_CLIENT) +ENDIF(BUILD_CORE OR BUILD_QTGUI) SET(CMAKE_BUILD_TYPE Debug) # Define files -SET(quassel_mono_SRCS common/main_mono.cpp) -SET(quassel_core_SRCS common/main_core.cpp) -SET(quassel_client_SRCS common/main_gui.cpp ${common_SRCS}) +SET(quassel_mono_SRCS common/build_mono.cpp) +SET(quassel_core_SRCS common/build_core.cpp) +SET(quassel_qtgui_SRCS common/build_qtgui.cpp) SET(quassel_RCCS images/icons.qrc) SET(quassel_DIRS common client core qtgui) @@ -43,7 +43,7 @@ FOREACH(dir ${quassel_DIRS}) SET(SDIRS ${SDIRS} "${CMAKE_CURRENT_SOURCE_DIR}/${dir}") ENDFOREACH(dir) INCLUDE_DIRECTORIES(${SDIRS} plugins) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/qtgui) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/qtgui) # so that ui files are found # We need Qt4 support. SET(QT_MIN_VERSION "4.3.0") # 4.3 is required for SSL, crypto and some other stuff @@ -72,14 +72,12 @@ QT4_ADD_RESOURCES(_RCCS ${quassel_RCCS}) SET(TARGET_LIST ) IF(BUILD_CORE) - ADD_DEFINITIONS(-DBUILD_CORE) ADD_EXECUTABLE(quasselcore ${quassel_core_SRCS} ${_RCCS}) TARGET_LINK_LIBRARIES(quasselcore common core ${QT_LIBRARIES}) SET(TARGET_LIST ${TARGET_LIST} quasselcore) - REMOVE_DEFINITIONS(-DBUILD_CORE) ENDIF(BUILD_CORE) -IF(BUILD_CLIENT OR BUILD_MONO) # OK, now we need QtGui! +IF(BUILD_QTGUI OR BUILD_MONO) # OK, now we need QtGui! REMOVE_DEFINITIONS(-DQT_CORE_LIB -DQT_GUI_LIB ${QT_DEFINITIONS}) SET(QT_DONT_USE_QTGUI "") SET(QT_INCLUDE_DIR "") @@ -89,22 +87,18 @@ IF(BUILD_CLIENT OR BUILD_MONO) # OK, now we need QtGui! ADD_SUBDIRECTORY(qtgui) IF(BUILD_MONO) - ADD_DEFINITIONS(-DBUILD_MONO) ADD_EXECUTABLE(quassel ${quassel_mono_SRCS} ${_RCCS}) TARGET_LINK_LIBRARIES(quassel common client core qtgui ${QT_LIBRARIES}) SET(TARGET_LIST ${TARGET_LIST} quassel) - REMOVE_DEFINITIONS(-DBUILD_MONO) ENDIF(BUILD_MONO) - IF(BUILD_CLIENT) - ADD_DEFINITIONS(-DBUILD_CLIENT) - ADD_EXECUTABLE(quasselgui ${quassel_gui_SRCS} ${_RCCS}) + IF(BUILD_QTGUI) + ADD_EXECUTABLE(quasselclient ${quassel_gui_SRCS} ${_RCCS}) TARGET_LINK_LIBRARIES(quasselclient common client qtgui ${QT_LIBRARIES}) - SET(TARGET_LIST ${TARGET_LIST} quasselgui) - REMOVE_DEFINITIONS(-DBUILD_CLIENT) - ENDIF(BUILD_CLIENT) + SET(TARGET_LIST ${TARGET_LIST} quasselclient) + ENDIF(BUILD_QTGUI) -ENDIF(BUILD_CLIENT OR BUILD_MONO) +ENDIF(BUILD_QTGUI OR BUILD_MONO) INSTALL(TARGETS ${TARGET_LIST} RUNTIME DESTINATION bin diff --git a/src/common/build_core.cpp b/src/common/build_core.cpp new file mode 100644 index 00000000..f5a3a443 --- /dev/null +++ b/src/common/build_core.cpp @@ -0,0 +1,22 @@ +/*************************************************************************** + * Copyright (C) 2005-07 by The Quassel IRC Development Team * + * devel@quassel-irc.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#define BUILD_CORE +#include "main.cpp" diff --git a/src/common/build_mono.cpp b/src/common/build_mono.cpp new file mode 100644 index 00000000..626ad2b2 --- /dev/null +++ b/src/common/build_mono.cpp @@ -0,0 +1,22 @@ +/*************************************************************************** + * Copyright (C) 2005-07 by The Quassel IRC Development Team * + * devel@quassel-irc.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#define BUILD_MONO +#include "main_mono.cpp" diff --git a/src/common/build_qtgui.cpp b/src/common/build_qtgui.cpp new file mode 100644 index 00000000..839850b8 --- /dev/null +++ b/src/common/build_qtgui.cpp @@ -0,0 +1,22 @@ +/*************************************************************************** + * Copyright (C) 2005-07 by The Quassel IRC Development Team * + * devel@quassel-irc.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#define BUILD_QTGUI +#include "main.cpp" diff --git a/src/common/global.h b/src/common/global.h index 42856068..1f4eb688 100644 --- a/src/common/global.h +++ b/src/common/global.h @@ -77,7 +77,7 @@ class Global : public QObject { void dataUpdatedRemotely(UserId, QString key); // sent by remote update only! public: - enum RunMode { Monolithic, GuiOnly, CoreOnly }; + enum RunMode { Monolithic, ClientOnly, CoreOnly }; static RunMode runMode; static QString quasselDir; diff --git a/src/common/main_mono.cpp b/src/common/main_mono.cpp index 84e6fae8..b77c2cd3 100644 --- a/src/common/main_mono.cpp +++ b/src/common/main_mono.cpp @@ -20,55 +20,69 @@ #include -#include +#include "global.h" +#include "settings.h" -#include "client.h" +#if defined BUILD_CORE +#include #include "core.h" + +#elif defined BUILD_QTGUI +#include #include "style.h" -#include "global.h" +#include "client.h" #include "clientproxy.h" +#include "mainwin.h" + +#elif defined BUILD_MONO +#include +#include "core.h" #include "coreproxy.h" -#include "settings.h" -#include "chatwidget.h" +#include "style.h" +#include "client.h" +#include "clientproxy.h" #include "mainwin.h" +#else +#error "Something is wrong - you need to #define a build mode!" +#endif + int main(int argc, char **argv) { +#if defined BUILD_CORE + Global::runMode = Global::CoreOnly; + QCoreApplication app(argc, argv); +#elif defined BUILD_QTGUI + Global::runMode = Global::ClientOnly; QApplication app(argc, argv); +#else + Global::runMode = Global::Monolithic; + QApplication app(argc, argv); +#endif + QCoreApplication::setOrganizationDomain("quassel-irc.org"); QCoreApplication::setApplicationName("Quassel IRC"); QCoreApplication::setOrganizationName("Quassel IRC Development Team"); - Global::runMode = Global::Monolithic; Global::quasselDir = QDir::homePath() + "/.quassel"; - //settings = new Settings(); - //global = new Global(); - //guiProxy = new GUIProxy(); - //coreProxy = new CoreProxy(); +#ifdef BUILD_MONO QObject::connect(Core::localSession(), SIGNAL(proxySignal(CoreSignal, QVariant, QVariant, QVariant)), ClientProxy::instance(), SLOT(recv(CoreSignal, QVariant, QVariant, QVariant))); QObject::connect(ClientProxy::instance(), SIGNAL(send(ClientSignal, QVariant, QVariant, QVariant)), Core::localSession(), SLOT(processSignal(ClientSignal, QVariant, QVariant, QVariant))); +#endif Settings::init(); Style::init(); MainWin *mainWin = new MainWin(); - //mainWin->show(); Client::init(mainWin); mainWin->init(); int exitCode = app.exec(); - //delete core; - // the mainWin has to be deleted before the Core // if not Quassel will crash on exit under certain conditions since the gui // still wants to access clientdata delete mainWin; Client::destroy(); Core::destroy(); - //delete guiProxy; - //delete coreProxy; - //delete global; - //delete mainWin; - //delete settings; return exitCode; } @@ -79,29 +93,3 @@ void Client::syncToCore() { // any servers connected at this stage... } -/* -void CoreProxy::sendToGUI(CoreSignal sig, QVariant arg1, QVariant arg2, QVariant arg3) { - guiProxy->recv(sig, arg1, arg2, arg3); -} -*/ - -/* -GUIProxy::GUIProxy() { - if(guiProxy) qFatal("Trying to instantiate more than one GUIProxy object!"); -} -*/ -/* -void GUIProxy::send(GUISignal sig, QVariant arg1, QVariant arg2, QVariant arg3) { - coreProxy->recv(sig, arg1, arg2, arg3); -} -*/ - -// Dummy function definitions -// These are not needed, since we don't have a network connection to the core. -/* -void GUIProxy::serverHasData() {} -void GUIProxy::connectToCore(QString, quint16) {} -void GUIProxy::disconnectFromCore() {} -void GUIProxy::updateCoreData(QString) {} -void GUIProxy::serverError(QAbstractSocket::SocketError) {} -*/ -- 2.20.1