1 # This is the cmake-based build system for Quassel IRC.
2 # You may pass various options to cmake:
3 # -DBUILD=<string> : Select binaries to build. <string> may contain any combination
4 # of "core", "client", "mono" or "all".
5 # -DQT=/path/to/qt : Choose a Qt4 installation to use instead of the system Qt4
6 # -DSTATIC=1 : Enable static building of Quassel, most useful with a static Qt.
7 # -DSPUTDEV : Do not use.
9 # NOTE: You need to remove CMakeCache.txt if you plan to change any of these values!
13 cmake_minimum_required(VERSION 2.4.5)
15 set(QT_MIN_VERSION "4.4.0")
17 # By default, we build all binaries
20 endif(NOT DEFINED BUILD)
22 # User might define which binaries to build by invoking cmake -DBUILD=<string>,
23 # where <string> might contain any combination of "core", "client", "mono" or "all"
26 set(BUILD_QTCLIENT true)
28 message(STATUS "Building Quassel Client, Quassel Core and monolithic Quassel.")
29 else(BUILD MATCHES all)
30 if(BUILD MATCHES core)
32 message(STATUS "Building Quassel Core")
33 endif(BUILD MATCHES core)
34 if(BUILD MATCHES client)
35 set(BUILD_QTCLIENT true)
36 message(STATUS "Building Quassel Client")
37 endif(BUILD MATCHES client)
38 if(BUILD MATCHES mono)
40 message(STATUS "Building monolithic Quassel")
41 endif(BUILD MATCHES mono)
42 endif(BUILD MATCHES all)
44 # Select a Qt installation here, if you don't want to use system Qt
46 # FindQt4 will look for the qmake binary in $PATH, so we just prepend the Qt dir
47 set(ENV{PATH} ${QT}/bin:$ENV{PATH})
48 #SET(QT_QMAKE_EXECUTABLE ${QT}/bin/qmake CACHE FILEPATH "" FORCE)
51 # Enable mostly b0rked stuff (new ChatView), do not enable this unless you know what you do...
53 add_definitions(-DSPUTDEV)
56 # Now that we have the correct $PATH, lets find Qt!
57 find_package(Qt4 REQUIRED)
60 add_subdirectory(src/common)
61 include_directories(src/common)
62 if(BUILD_CORE OR BUILD_MONO)
63 add_subdirectory(src/core)
64 include_directories(src/core)
65 endif(BUILD_CORE OR BUILD_MONO)
66 if(BUILD_QTCLIENT OR BUILD_MONO)
67 add_subdirectory(src/client)
68 add_subdirectory(src/uisupport)
69 add_subdirectory(src/qtui)
70 include_directories(src/client)
71 include_directories(src/uisupport)
72 include_directories(src/qtui)
73 endif(BUILD_QTCLIENT OR BUILD_MONO)
76 qt4_add_resources(RES_I18N ${CMAKE_SOURCE_DIR}/i18n/i18n.qrc)
77 qt4_add_resources(RES_ICONS ${CMAKE_SOURCE_DIR}/src/icons/icons.qrc)
78 qt4_add_resources(RES_SQL ${CMAKE_SOURCE_DIR}/src/core/sql.qrc)
80 # Set global buildflags
82 set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc ${CMAKE_EXE_LINKER_FLAGS}")
83 link_directories(${CMAKE_BINARY_DIR}/staticlibs)
86 # Here comes the dirty part. Our targets need different Qt4 modules, i.e. different libs
87 # and defines. We can't simply include UseQt4 several times, since definitions add up.
88 # We workaround this by only setting up QtCore first, and adding additional stuff later.
89 set(QT_DONT_USE_QTGUI 1)
90 include(${QT_USE_FILE})
91 include_directories(${QT_INCLUDES})
93 # This macro sets variables for additional Qt modules.
94 macro(setup_qt4_variables)
95 set(QUASSEL_QT_DEFINITIONS ${QT_DEFINITIONS})
96 set(QUASSEL_QT_LIBRARIES )
97 foreach(qtmod ${ARGV})
98 # This needs to be a string, not a list, otherwise set_target_properties screws up...
99 set(QUASSEL_QT_DEFINITIONS "${QUASSEL_QT_DEFINITIONS} -DQT_${qtmod}_LIB")
100 set(QUASSEL_QT_LIBRARIES ${QUASSEL_QT_LIBRARIES} ${QT_QT${qtmod}_LIBRARY} ${QT_${qtmod}_LIB_DEPENDENCIES})
101 endforeach(qtmod ${ARGV})
102 set(QUASSEL_QT_LIBRARIES ${QUASSEL_QT_LIBRARIES} ${QT_LIBRARIES})
103 endmacro(setup_qt4_variables)
105 # Now we have everything, so just glue the right pieces together :)
107 setup_qt4_variables(NETWORK SCRIPT SQL)
108 add_executable(quasselcore ${CMAKE_SOURCE_DIR}/src/common/main.cpp ${RES_SQL} ${RES_I18N})
109 set_target_properties(quasselcore PROPERTIES COMPILE_FLAGS "${QUASSEL_QT_DEFINITIONS} -DBUILD_CORE")
110 target_link_libraries(quasselcore mod_core mod_common ${QUASSEL_QT_LIBRARIES})
114 setup_qt4_variables(GUI NETWORK)
115 add_executable(quasselclient ${CMAKE_SOURCE_DIR}/src/common/main.cpp ${RES_ICONS} ${RES_I18N})
116 set_target_properties(quasselclient PROPERTIES COMPILE_FLAGS "${QUASSEL_QT_DEFINITIONS} -DBUILD_QTUI")
117 target_link_libraries(quasselclient mod_qtui mod_uisupport mod_client mod_common ${QUASSEL_QT_LIBRARIES})
118 endif(BUILD_QTCLIENT)
121 setup_qt4_variables(GUI NETWORK SCRIPT SQL)
122 add_executable(quassel ${CMAKE_SOURCE_DIR}/src/common/main.cpp ${RES_ICONS} ${RES_SQL} ${RES_I18N})
123 set_target_properties(quassel PROPERTIES COMPILE_FLAGS "${QUASSEL_QT_DEFINITIONS} -DBUILD_MONO")
124 target_link_libraries(quassel mod_qtui mod_uisupport mod_client mod_core mod_common ${QUASSEL_QT_LIBRARIES})