New nifty super dooper not yet so nice but real and true channel widget. To be continued.
[quassel.git] / CMakeLists.txt
index 59487d1..58a6b95 100644 (file)
@@ -1,68 +1,91 @@
 PROJECT(Quassel)
 
-# CMAKE_MINIMUM_REQUIRED(VERSION 2.4.2)
+# 2.4.2 had a bug with out-of-source builds and UIC dependencies.
+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 'server', 'client' and/or 'monolithic' (which is the default).")
-SET(BUILD_SERVER )
-SET(BUILD_CLIENT )
+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_GUI )
 SET(BUILD_MONO )
-IF(BUILD MATCHES "server")
-  SET(BUILD_SERVER true)
-  MESSAGE(STATUS "Building Quassel server.")
-ENDIF(BUILD MATCHES "server")
-IF(BUILD MATCHES "client")
-  SET(BUILD_CLIENT true)
-  MESSAGE(STATUS "Building Quassel client.")
-ENDIF(BUILD MATCHES "client")
-IF(BUILD MATCHES "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 "gui" OR BUILD MATCHES "all")
+  SET(BUILD_GUI true)
+  MESSAGE("Building Quassel GUI.")
+ENDIF(BUILD MATCHES "gui" OR BUILD MATCHES "all")
+IF(BUILD MATCHES "mono" OR BUILD MATCHES "all")
   SET(BUILD_MONO true)
-  MESSAGE(STATUS "Building monolithic Quassel.")
-ENDIF(BUILD MATCHES "mono")
-IF(NOT BUILD_MONO AND NOT BUILD_SERVER AND NOT BUILD_CLIENT)
-  MESSAGE(FATAL_ERROR "You have not selected which parts of Quassel I should build. Aborting.\nRun 'cmake -DBUILD=<part>', where <part> contains one or more of 'server', 'client' or 'monolithic'.")
-ENDIF(NOT BUILD_MONO AND NOT BUILD_SERVER AND NOT BUILD_CLIENT)
-
-# We need Qt4 support.
-FIND_PACKAGE(Qt4 REQUIRED)
-
-# Set needed libraries
-SET(QT_USE_QTXML true)
-IF(NOT BUILD_CLIENT AND NOT BUILD_MONO)
-  SET(QT_DONT_USE_QTGUI true)
-  MESSAGE(STATUS "Disabling GUI support.")
-ENDIF(NOT BUILD_CLIENT AND NOT BUILD_MONO)
-INCLUDE(${QT_USE_FILE})
-ADD_DEFINITIONS(${QT_DEFINITIONS})
+  MESSAGE("Building monolithic Quassel.")
+ENDIF(BUILD MATCHES "mono" OR BUILD MATCHES "all")
+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 <path> -DBUILD=<part>', where <part> 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)
 
 # Define files
 SET(quassel_mono_SRCS main/main_mono.cpp)
+SET(quassel_core_SRCS main/main_core.cpp)
+SET(quassel_gui_SRCS  main/main_gui.cpp ${common_SRCS})
 SET(quassel_RCCS images/icons.qrc)
-SET(quassel_DIRS gui core)
+SET(quassel_DIRS main gui core network)
 
 # Build correct absolute paths for subdirs to include
 SET(SDIRS "")
 FOREACH(dir ${quassel_DIRS})
   SET(SDIRS ${SDIRS} "${CMAKE_CURRENT_SOURCE_DIR}/${dir}")
 ENDFOREACH(dir)
-INCLUDE_DIRECTORIES(${SDIRS} ${QT_INCLUDES})
+INCLUDE_DIRECTORIES(${SDIRS})
 
-ADD_SUBDIRECTORY(gui)
-ADD_SUBDIRECTORY(core)
+# We need Qt4 support.
+FIND_PACKAGE(Qt4 REQUIRED)
+
+# Set needed libraries
+SET(QT_USE_QTXML true)
+SET(QT_USE_QTNETWORK true)
+SET(QT_DONT_USE_QTGUI true)   # This is added later if GUI is requested
+INCLUDE(${QT_USE_FILE})
+
+# Define subdirs. CMake complains if a directory is added twice, so make sure this
+# does not happen in any combination of the requested targets.
+
+ADD_SUBDIRECTORY(main)
+IF(BUILD_CORE)
+  ADD_SUBDIRECTORY(core)
+  ADD_SUBDIRECTORY(network)
+ENDIF(BUILD_CORE)
+IF(BUILD_MONO AND NOT BUILD_CORE)
+  ADD_SUBDIRECTORY(core)
+  ADD_SUBDIRECTORY(network)
+ENDIF(BUILD_MONO AND NOT BUILD_CORE)
 
 QT4_ADD_RESOURCES(_RCCS ${quassel_RCCS})
 
-IF(BUILD_MONO)
-  ADD_EXECUTABLE(quassel ${quassel_mono_SRCS} ${_RCCS})
-  TARGET_LINK_LIBRARIES(quassel gui core ${QT_LIBRARIES})
-ENDIF(BUILD_MONO)
+IF(BUILD_CORE)
+  ADD_DEFINITIONS(-DBUILD_CORE)
+  ADD_EXECUTABLE(quasselcore ${quassel_core_SRCS} ${_RCCS})
+  TARGET_LINK_LIBRARIES(quasselcore core network main ${QT_LIBRARIES})
+ENDIF(BUILD_CORE)
+
+IF(BUILD_GUI 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 "")
+  SET(QT_LIBRARIES "")
+  INCLUDE(${QT_USE_FILE})
+  ADD_SUBDIRECTORY(gui)
+
+  IF(BUILD_MONO)
+    ADD_DEFINITIONS(-DBUILD_MONO)
+    ADD_EXECUTABLE(quassel ${quassel_mono_SRCS} ${_RCCS})
+    TARGET_LINK_LIBRARIES(quassel gui core network main ${QT_LIBRARIES})
+  ENDIF(BUILD_MONO)
 
-IF(BUILD_SERVER)
-#  MESSAGE(FATAL_ERROR "Server mode not yet supported.")
-  ADD_EXECUTABLE(quasselserver ${quassel_mono_SRCS} ${_RCCS})
-  TARGET_LINK_LIBRARIES(quasselserver gui core ${QT_LIBRARIES})
-ENDIF(BUILD_SERVER)
+  IF(BUILD_GUI)
+    ADD_DEFINITIONS(-DBUILD_GUI)
+    ADD_EXECUTABLE(quasselgui ${quassel_gui_SRCS} ${_RCCS})
+    TARGET_LINK_LIBRARIES(quasselgui gui main ${QT_LIBRARIES})
+  ENDIF(BUILD_GUI)
 
-IF(BUILD_CLIENT)
-  MESSAGE(FATAL_ERROR "Client mode not yet supported.")
-ENDIF(BUILD_CLIENT)
+ENDIF(BUILD_GUI OR BUILD_MONO)