1 # This is the cmake-based build system for Quassel IRC.
5 cmake_minimum_required(VERSION 2.4.5)
7 set(QT_MIN_VERSION "4.4.0")
8 find_package(Qt4 REQUIRED)
10 # By default, we build all binaries
13 endif(NOT DEFINED BUILD)
15 # User might define which binaries to build by invoking cmake -DBUILD=<string>,
16 # where <string> might contain any combination of "core", "client", "mono" or "all"
19 set(BUILD_QTCLIENT true)
21 message(STATUS "Building Quassel Client, Quassel Core and monolithic Quassel.")
22 else(BUILD MATCHES all)
23 if(BUILD MATCHES core)
25 message(STATUS "Building Quassel Core")
26 endif(BUILD MATCHES core)
27 if(BUILD MATCHES client)
28 set(BUILD_QTCLIENT true)
29 message(STATUS "Building Quassel Client")
30 endif(BUILD MATCHES client)
31 if(BUILD MATCHES mono)
33 message(STATUS "Building monolithic Quassel")
34 endif(BUILD MATCHES mono)
35 endif(BUILD MATCHES all)
37 # Enable mostly b0rked stuff (new ChatView), do not enable this unless you know what you do...
39 add_definitions(-DSPUTDEV)
43 add_subdirectory(src/common)
44 include_directories(src/common)
45 if(BUILD_CORE OR BUILD_MONO)
46 add_subdirectory(src/core)
47 include_directories(src/core)
48 endif(BUILD_CORE OR BUILD_MONO)
49 if(BUILD_QTCLIENT OR BUILD_MONO)
50 add_subdirectory(src/client)
51 add_subdirectory(src/uisupport)
52 add_subdirectory(src/qtui)
53 include_directories(src/client)
54 include_directories(src/uisupport)
55 include_directories(src/qtui)
56 endif(BUILD_QTCLIENT OR BUILD_MONO)
59 qt4_add_resources(RES_I18N ${CMAKE_SOURCE_DIR}/i18n/i18n.qrc)
60 qt4_add_resources(RES_ICONS ${CMAKE_SOURCE_DIR}/src/icons/icons.qrc)
61 qt4_add_resources(RES_SQL ${CMAKE_SOURCE_DIR}/src/core/sql.qrc)
63 # Here comes the dirty part. Our targets need different Qt4 modules, i.e. different libs
64 # and defines. We can't simply include UseQt4 several times, since definitions add up.
65 # We workaround this by only setting up QtCore first, and adding additional stuff later.
66 set(QT_DONT_USE_QTGUI 1)
67 include(${QT_USE_FILE})
68 include_directories(${QT_INCLUDES})
70 # This macro sets variables for additional Qt modules.
71 macro(setup_qt4_variables)
72 set(QUASSEL_QT_DEFINITIONS )
73 set(QUASSEL_QT_LIBRARIES )
74 foreach(qtmod ${ARGV})
75 # This needs to be a string, not a list, otherwise set_target_properties screws up...
76 set(QUASSEL_QT_DEFINITIONS "${QUASSEL_QT_DEFINITIONS} -DQT_${qtmod}_LIB")
77 set(QUASSEL_QT_LIBRARIES ${QUASSEL_QT_LIBRARIES} ${QT_QT${qtmod}_LIBRARY} ${QT_${qtmod}_LIB_DEPENDENCIES})
78 endforeach(qtmod ${ARGV})
79 endmacro(setup_qt4_variables)
81 # Now we have everything, so just glue the right pieces together :)
83 setup_qt4_variables(NETWORK SCRIPT SQL)
84 add_executable(quasselcore ${CMAKE_SOURCE_DIR}/src/common/main.cpp ${RES_SQL} ${RES_I18N})
85 set_target_properties(quasselcore PROPERTIES COMPILE_FLAGS "${QUASSEL_QT_DEFINITIONS} -DBUILD_CORE")
86 target_link_libraries(quasselcore mod_core mod_common ${QUASSEL_QT_LIBRARIES})
90 setup_qt4_variables(GUI NETWORK)
91 add_executable(quasselclient ${CMAKE_SOURCE_DIR}/src/common/main.cpp ${RES_ICONS} ${RES_I18N})
92 set_target_properties(quasselclient PROPERTIES COMPILE_FLAGS "${QUASSEL_QT_DEFINITIONS} -DBUILD_QTUI")
93 target_link_libraries(quasselclient mod_qtui mod_uisupport mod_client mod_common ${QUASSEL_QT_LIBRARIES})
97 setup_qt4_variables(GUI NETWORK SCRIPT SQL)
98 add_executable(quassel ${CMAKE_SOURCE_DIR}/src/common/main.cpp ${RES_ICONS} ${RES_SQL} ${RES_I18N})
99 set_target_properties(quassel PROPERTIES COMPILE_FLAGS "${QUASSEL_QT_DEFINITIONS} -DBUILD_MONO")
100 target_link_libraries(quassel mod_qtui mod_uisupport mod_client mod_core mod_common ${QUASSEL_QT_LIBRARIES})