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 # -DSTATICWIN=1 : Enable static building for Windows.
8 # -DSPUTDEV : Do not use.
10 # NOTE: You need to remove CMakeCache.txt if you plan to change any of these values!
14 cmake_minimum_required(VERSION 2.4.5)
16 # This would suppress annoying warnings on cmake-2.6, but we can't use it
17 # with 2.4, so... DUH!
18 # cmake_policy(SET CMP0003 OLD) # suppress linker warnings
21 set(CMAKE_BUILD_TYPE Release)
24 set(QT_MIN_VERSION "4.4.0")
26 # By default, we build all binaries
29 endif(NOT DEFINED BUILD)
31 # User might define which binaries to build by invoking cmake -DBUILD=<string>,
32 # where <string> might contain any combination of "core", "client", "mono" or "all"
35 set(BUILD_QTCLIENT true)
37 message(STATUS "Building Quassel Client, Quassel Core and monolithic Quassel.")
38 else(BUILD MATCHES all)
39 if(BUILD MATCHES core)
41 message(STATUS "Building Quassel Core")
42 endif(BUILD MATCHES core)
43 if(BUILD MATCHES client)
44 set(BUILD_QTCLIENT true)
45 message(STATUS "Building Quassel Client")
46 endif(BUILD MATCHES client)
47 if(BUILD MATCHES mono)
49 message(STATUS "Building monolithic Quassel")
50 endif(BUILD MATCHES mono)
51 endif(BUILD MATCHES all)
53 # Enable mostly b0rked stuff (new ChatView), do not enable this unless you know what you do...
55 add_definitions(-DSPUTDEV)
60 # Select a Qt installation here, if you don't want to use system Qt
62 # FindQt4 will look for the qmake binary in $PATH, so we just prepend the Qt dir
63 set(ENV{PATH} ${QT}/bin:$ENV{PATH})
64 #SET(QT_QMAKE_EXECUTABLE ${QT}/bin/qmake CACHE FILEPATH "" FORCE)
67 # Now that we have the correct $PATH, lets find Qt!
68 find_package(Qt4 REQUIRED)
70 set(QT_DONT_USE_QTGUI 1)
71 include(${QT_USE_FILE})
72 include_directories(${QT_INCLUDES})
74 # We need to create a version.gen
75 # For this, we create our genversion binary and make sure it is run every time.
76 add_executable(genversion ${CMAKE_SOURCE_DIR}/src/common/genversion.cpp)
77 target_link_libraries(genversion ${QT_LIBRARIES})
79 add_custom_target(genversion_run ALL ${CMAKE_BINARY_DIR}/genversion
80 ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/src/common/version.gen)
81 add_dependencies(genversion_run genversion)
84 add_subdirectory(src/common)
85 include_directories(src/common)
86 if(BUILD_CORE OR BUILD_MONO)
87 add_subdirectory(src/core)
88 include_directories(src/core)
89 endif(BUILD_CORE OR BUILD_MONO)
90 if(BUILD_QTCLIENT OR BUILD_MONO)
91 add_subdirectory(src/client)
92 add_subdirectory(src/uisupport)
93 add_subdirectory(src/qtui)
94 include_directories(src/client)
95 include_directories(src/uisupport)
96 include_directories(src/qtui)
97 endif(BUILD_QTCLIENT OR BUILD_MONO)
99 # Make sure version.gen exists before building mod_common
100 add_dependencies(mod_common genversion_run)
103 qt4_add_resources(RC_I18N i18n/i18n.qrc)
104 qt4_add_resources(RC_ICONS src/icons/icons.qrc)
105 qt4_add_resources(RC_QUASSEL_ICONS src/icons/quassel-icons.qrc)
106 qt4_add_resources(RC_SQL src/core/sql.qrc)
108 # Set global buildflags
110 set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc ${CMAKE_EXE_LINKER_FLAGS}")
111 link_directories(${CMAKE_BINARY_DIR}/staticlibs)
112 endif(DEFINED STATIC)
114 if(STATICWIN AND WIN32)
115 link_libraries(imm32 winmm) # missing by default :/
117 link_libraries(libeay32MD ssleay32MD)
119 endif(STATICWIN AND WIN32)
122 set(WIN32_RC src/icons/win32.rc) # for app icons on windows
125 # FIXME: Add icons for windows as soon as we have merged with trunk (which has reorganized
127 # Simply add the .rc file to the targets
129 # Here comes the dirty part. Our targets need different Qt4 modules, i.e. different libs
130 # and defines. We can't simply include UseQt4 several times, since definitions add up.
131 # We workaround this by using our own macro to figure out what to add.
133 # This macro sets variables for additional Qt modules.
134 macro(setup_qt4_variables)
135 set(QUASSEL_QT_DEFINITIONS ${QT_DEFINITIONS})
136 set(QUASSEL_QT_LIBRARIES )
137 foreach(qtmod ${ARGV})
138 # This needs to be a string, not a list, otherwise set_target_properties screws up...
139 set(QUASSEL_QT_DEFINITIONS "${QUASSEL_QT_DEFINITIONS} -DQT_${qtmod}_LIB")
140 set(QUASSEL_QT_LIBRARIES ${QUASSEL_QT_LIBRARIES} ${QT_QT${qtmod}_LIBRARY} ${QT_${qtmod}_LIB_DEPENDENCIES})
141 endforeach(qtmod ${ARGV})
142 set(QUASSEL_QT_LIBRARIES ${QUASSEL_QT_LIBRARIES} ${QT_LIBRARIES})
143 endmacro(setup_qt4_variables)
145 # Now we have everything, so just glue the right pieces together :)
147 setup_qt4_variables(NETWORK SCRIPT SQL)
148 add_executable(quasselcore ${CMAKE_SOURCE_DIR}/src/common/main.cpp
149 ${RC_SQL} ${RC_I18N} ${WIN32_RC})
150 set_target_properties(quasselcore PROPERTIES COMPILE_FLAGS "${QUASSEL_QT_DEFINITIONS} -DBUILD_CORE")
151 target_link_libraries(quasselcore mod_core mod_common ${QUASSEL_QT_LIBRARIES})
155 setup_qt4_variables(GUI NETWORK)
156 add_executable(quasselclient ${CMAKE_SOURCE_DIR}/src/common/main.cpp
157 ${RC_ICONS} ${RC_QUASSEL_ICONS} ${RC_I18N} ${WIN32_RC})
158 set_target_properties(quasselclient PROPERTIES COMPILE_FLAGS "${QUASSEL_QT_DEFINITIONS} -DBUILD_QTUI")
159 target_link_libraries(quasselclient mod_qtui mod_uisupport mod_client mod_common ${QUASSEL_QT_LIBRARIES})
160 endif(BUILD_QTCLIENT)
163 setup_qt4_variables(GUI NETWORK SCRIPT SQL)
164 add_executable(quassel ${CMAKE_SOURCE_DIR}/src/common/main.cpp
165 ${RC_ICONS} ${RC_QUASSEL_ICONS} ${RC_SQL} ${RC_I18N} ${WIN32_RC})
166 set_target_properties(quassel PROPERTIES COMPILE_FLAGS "${QUASSEL_QT_DEFINITIONS} -DBUILD_MONO")
167 target_link_libraries(quassel mod_qtui mod_uisupport mod_client mod_core mod_common ${QUASSEL_QT_LIBRARIES})