After quite a while, we have another big SVN update now.
[quassel.git] / CMakeLists.txt
1 PROJECT(Quassel)
2
3 # 2.4.2 had a bug with out-of-source builds and UIC dependencies.
4 CMAKE_MINIMUM_REQUIRED(VERSION 2.4.3 FATAL_ERROR)
5
6 # Select if Quassel should be built in client, server or monolithic mode
7 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.")
8 SET(BUILD_CORE )
9 SET(BUILD_GUI )
10 SET(BUILD_MONO )
11 IF(BUILD MATCHES "core" OR BUILD MATCHES "all")
12   SET(BUILD_CORE true)
13   MESSAGE("Building Quassel core.")
14 ENDIF(BUILD MATCHES "core" OR BUILD MATCHES "all")
15 IF(BUILD MATCHES "gui" OR BUILD MATCHES "all")
16   SET(BUILD_GUI true)
17   MESSAGE("Building Quassel GUI.")
18 ENDIF(BUILD MATCHES "gui" OR BUILD MATCHES "all")
19 IF(BUILD MATCHES "mono" OR BUILD MATCHES "all")
20   SET(BUILD_MONO true)
21   MESSAGE("Building monolithic Quassel.")
22 ENDIF(BUILD MATCHES "mono" OR BUILD MATCHES "all")
23 IF(NOT BUILD_MONO AND NOT BUILD_CORE AND NOT BUILD_GUI)
24   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")
25 ENDIF(NOT BUILD_MONO AND NOT BUILD_CORE AND NOT BUILD_GUI)
26
27 # Define files
28 SET(quassel_mono_SRCS main/main_mono.cpp)
29 SET(quassel_core_SRCS main/main_core.cpp)
30 SET(quassel_gui_SRCS  main/main_gui.cpp ${common_SRCS})
31 SET(quassel_RCCS images/icons.qrc)
32 SET(quassel_DIRS main gui core)
33
34 # Build correct absolute paths for subdirs to include
35 SET(SDIRS "")
36 FOREACH(dir ${quassel_DIRS})
37   SET(SDIRS ${SDIRS} "${CMAKE_CURRENT_SOURCE_DIR}/${dir}")
38 ENDFOREACH(dir)
39 INCLUDE_DIRECTORIES(${SDIRS})
40 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
41
42 # We need Qt4 support.
43 SET(QT_MIN_VERSION "4.2.0")
44 FIND_PACKAGE(Qt4 REQUIRED)
45
46 # Set needed libraries
47 SET(QT_USE_QTXML true)
48 SET(QT_USE_QTNETWORK true)
49 SET(QT_DONT_USE_QTGUI true)   # This is added later if GUI is requested
50 INCLUDE(${QT_USE_FILE})
51
52 # Define subdirs. CMake complains if a directory is added twice, so make sure this
53 # does not happen in any combination of the requested targets.
54
55 ADD_SUBDIRECTORY(main)
56 IF(BUILD_CORE)
57   ADD_SUBDIRECTORY(core)
58 ENDIF(BUILD_CORE)
59 IF(BUILD_MONO AND NOT BUILD_CORE)
60   ADD_SUBDIRECTORY(core)
61 ENDIF(BUILD_MONO AND NOT BUILD_CORE)
62
63 QT4_ADD_RESOURCES(_RCCS ${quassel_RCCS})
64
65 IF(BUILD_CORE)
66   ADD_DEFINITIONS(-DBUILD_CORE)
67   ADD_EXECUTABLE(quasselcore ${quassel_core_SRCS} ${_RCCS})
68   TARGET_LINK_LIBRARIES(quasselcore core main ${QT_LIBRARIES})
69 ENDIF(BUILD_CORE)
70
71 IF(BUILD_GUI OR BUILD_MONO)  # OK, now we need QtGui!
72   REMOVE_DEFINITIONS(-DQT_CORE_LIB -DQT_GUI_LIB ${QT_DEFINITIONS})
73   SET(QT_DONT_USE_QTGUI "")
74   SET(QT_INCLUDE_DIR "")
75   SET(QT_LIBRARIES "")
76   INCLUDE(${QT_USE_FILE})
77   ADD_SUBDIRECTORY(gui)
78
79   IF(BUILD_MONO)
80     ADD_DEFINITIONS(-DBUILD_MONO)
81     ADD_EXECUTABLE(quassel ${quassel_mono_SRCS} ${_RCCS})
82     TARGET_LINK_LIBRARIES(quassel gui core main ${QT_LIBRARIES})
83   ENDIF(BUILD_MONO)
84
85   IF(BUILD_GUI)
86     ADD_DEFINITIONS(-DBUILD_GUI)
87     ADD_EXECUTABLE(quasselgui ${quassel_gui_SRCS} ${_RCCS})
88     TARGET_LINK_LIBRARIES(quasselgui gui main ${QT_LIBRARIES})
89   ENDIF(BUILD_GUI)
90
91 ENDIF(BUILD_GUI OR BUILD_MONO)