1 # This is the cmake-based build system for Quassel IRC.
2 # You may pass various options to cmake:
3 # -DWANT_(CORE|QTCLIENT|MONO)=(ON|OFF)
4 # : select binaries to build
5 # -DQT=/path/to/qt : Choose a Qt4 installation to use instead of the system Qt4
6 # -DSTATIC=ON : Enable static building of Quassel. Use with care.
7 # -DSPUTDEV=ON : Do not use.
8 # -DDEPLOY=ON : Mac OS X only. Use only fore redistribution Quassel Packages!!
10 # NOTE: You need to remove CMakeCache.txt if you plan to change any of these values!
14 # Target scopes don't work in older versions
15 cmake_minimum_required(VERSION 2.4.7 FATAL_ERROR)
17 if(COMMAND cmake_policy)
18 cmake_policy(SET CMP0003 OLD) # suppress linker warnings
19 endif(COMMAND cmake_policy)
21 # Use our own (well, KDE's) version of some modules
22 # In particular cmake's FindQt4 and FindOpenSSL are quite buggy
23 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
25 # Various options and variables that can be set on the command line
26 option(WANT_CORE "Build the core (server) binary" ON)
27 option(WANT_QTCLIENT "Build the Qt4 GUI client binary" ON)
28 option(WANT_MONO "Build the monolithic (all-in-one) binary" OFF)
30 option(STATIC "Enable static building (might not be portable)" OFF)
31 option(DEPLOY "Mac OS X only! Adds required libs to bundle resources and create a dmg. Note: requires Qt to be built with 10.4u SDK" OFF)
32 option(SPUTDEV "Do not use!" OFF)
34 set(QT "" CACHE STRING "Path to a Qt installation to use instead of the system Qt")
35 set(LINGUAS "" CACHE STRING "Space-separated List of locales specifying languages that should be compiled")
38 set(CMAKE_BUILD_TYPE Release)
41 # RPATH needs to be set correctly
42 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH 1)
43 set(CMAKE_BUILD_WITH_INSTALL_RPATH 1)
45 # Enable various flags on gcc
46 if(CMAKE_COMPILER_IS_GNUCXX)
47 include(CheckCXXCompilerFlag)
48 check_cxx_compiler_flag(-Wall HAVE_WALL)
50 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
52 check_cxx_compiler_flag(-Wextra HAVE_WEXTRA)
54 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra")
56 check_cxx_compiler_flag(-ansi HAVE_ANSI)
58 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ansi")
60 endif(CMAKE_COMPILER_IS_GNUCXX)
62 set(QT_MIN_VERSION "4.4.0")
65 set(CMAKE_OSX_ARCHITECTURES "i386;ppc")
66 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.4")
67 set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.4u.sdk/")
68 add_definitions(-DMAC_10_4_SDK)
69 endif(APPLE AND DEPLOY)
71 # Enable mostly b0rked stuff (new ChatView), do not enable this unless you know what you do...
73 add_definitions(-DSPUTDEV)
79 add_definitions(-DQT_NO_OPENSSL)
80 endif(NOT OPENSSL_FOUND)
82 # Select a Qt installation here, if you don't want to use system Qt
84 # FindQt4 will look for the qmake binary in $PATH, so we just prepend the Qt dir
85 set(ENV{PATH} ${QT}/bin:$ENV{PATH})
88 # Now that we have the correct $PATH, lets find Qt!
89 find_package(Qt4 REQUIRED)
92 add_definitions(-DHAVE_DBUS)
95 endif(QT_QTDBUS_FOUND)
97 set(QT_DONT_USE_QTGUI 1)
98 include(${QT_USE_FILE})
99 include_directories(${QT_INCLUDES})
101 # We need to create a version.gen
102 # For this, we create our genversion binary and make sure it is run every time.
103 add_executable(genversion ${CMAKE_SOURCE_DIR}/src/common/genversion.cpp)
104 target_link_libraries(genversion ${QT_LIBRARIES} ${QT_CORE_LIB_DEPENDENCIES})
106 add_custom_target(genversion_run ALL ${CMAKE_BINARY_DIR}/genversion
107 ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/src/common/version.gen)
108 add_dependencies(genversion_run genversion)
111 add_subdirectory(src/common)
112 include_directories(src/common)
113 if(WANT_CORE OR WANT_MONO)
114 add_subdirectory(src/core)
115 include_directories(src/core)
116 endif(WANT_CORE OR WANT_MONO)
117 if(WANT_QTCLIENT OR WANT_MONO)
118 add_subdirectory(src/client)
119 add_subdirectory(src/uisupport)
120 add_subdirectory(src/qtui)
121 include_directories(src/client)
122 include_directories(src/uisupport)
123 include_directories(src/qtui)
124 endif(WANT_QTCLIENT OR WANT_MONO)
126 # Make sure version.gen exists before building mod_common
127 add_dependencies(mod_common genversion_run)
129 # Generate binary translation files
130 include(QuasselGenerateTranslations)
131 quassel_generate_i18n_resource(RC_I18N ${LINGUAS})
134 qt4_add_resources(RC_ICONS src/icons/icons.qrc)
135 qt4_add_resources(RC_QUASSEL_ICONS src/icons/quassel-icons.qrc)
136 qt4_add_resources(RC_SQL src/core/sql.qrc)
138 # Set global buildflags
139 # This is very much non-portable, so don't use -DSTATICGCC until you know what
141 if(STATIC AND CMAKE_COMPILER_IS_GNUCXX)
142 set(CMAKE_CXX_FLAGS "-static-libgcc ${CMAKE_CXX_FLAGS}")
143 link_directories(${CMAKE_BINARY_DIR}/staticlibs) # override dynamic libs
145 set(QUASSEL_SSL_LIBRARIES ssl crypto) # these miss in static builds
147 endif(STATIC AND CMAKE_COMPILER_IS_GNUCXX)
150 link_libraries(imm32 winmm) # missing by default :/
152 link_libraries(${OPENSSL_LIBRARIES} libeay32MD)
154 endif(STATIC AND WIN32)
157 set(WIN32_RC src/icons/win32.rc) # for app icons on windows
160 # Here comes the dirty part. Our targets need different Qt4 modules, i.e. different libs
161 # and defines. We can't simply include UseQt4 several times, since definitions add up.
162 # We workaround this by using our own macro to figure out what to add.
164 # This macro sets variables for additional Qt modules.
165 macro(setup_qt4_variables)
166 set(QUASSEL_QT_LIBRARIES )
170 foreach(qtmod CORE ${ARGV} ${MAIN})
171 set(QUASSEL_QT_LIBRARIES ${QUASSEL_QT_LIBRARIES} ${QT_QT${qtmod}_LIBRARY} ${QT_${qtmod}_LIB_DEPENDENCIES})
172 endforeach(qtmod ${ARGV})
173 set(QUASSEL_QT_LIBRARIES ${QUASSEL_QT_LIBRARIES} ${QT_LIBRARIES})
174 endmacro(setup_qt4_variables)
176 # Now we have everything, so just glue the right pieces together :)
178 setup_qt4_variables(NETWORK SCRIPT SQL)
179 add_executable(quasselcore ${CMAKE_SOURCE_DIR}/src/common/main.cpp
180 ${RC_SQL} ${RC_I18N} ${WIN32_RC})
181 set_target_properties(quasselcore PROPERTIES
182 COMPILE_FLAGS "-DQT_NETWORK_LIB -DQT_SCRIPT_LIB -DQT_SQL_LIB -DBUILD_CORE")
183 target_link_libraries(quasselcore mod_core mod_common
184 ${QUASSEL_QT_LIBRARIES} ${QUASSEL_SSL_LIBRARIES})
188 setup_qt4_variables(${LINK_DBUS} GUI NETWORK)
189 add_executable(quasselclient WIN32 ${CMAKE_SOURCE_DIR}/src/common/main.cpp
190 ${RC_ICONS} ${RC_QUASSEL_ICONS} ${RC_I18N} ${WIN32_RC})
191 set_target_properties(quasselclient PROPERTIES
192 COMPILE_FLAGS "-DQT_GUI_LIB -DQT_NETWORK_LIB -DBUILD_QTUI")
193 target_link_libraries(quasselclient mod_qtui mod_uisupport mod_client mod_common
194 ${QUASSEL_QT_LIBRARIES} ${QUASSEL_SSL_LIBRARIES})
198 setup_qt4_variables(${LINK_DBUS} GUI NETWORK SCRIPT SQL)
199 add_executable(quassel WIN32 ${CMAKE_SOURCE_DIR}/src/common/main.cpp
200 ${RC_ICONS} ${RC_QUASSEL_ICONS} ${RC_SQL} ${RC_I18N} ${WIN32_RC})
201 set_target_properties(quassel PROPERTIES
202 COMPILE_FLAGS "-DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_SCRIPT_LIB -DQT_SQL_LIB -DBUILD_MONO")
203 target_link_libraries(quassel mod_qtui mod_uisupport mod_client mod_core mod_common
204 ${QUASSEL_QT_LIBRARIES} ${QUASSEL_SSL_LIBRARIES})
207 # Build bundles for MacOSX
209 add_custom_command(TARGET quasselclient POST_BUILD
210 COMMAND ${CMAKE_SOURCE_DIR}/scripts/build/macosx_makebundle.py
211 ${CMAKE_SOURCE_DIR} "Quassel Client" quasselclient)
212 add_custom_command(TARGET quassel POST_BUILD
213 COMMAND ${CMAKE_SOURCE_DIR}/scripts/build/macosx_makebundle.py
214 ${CMAKE_SOURCE_DIR} "Quassel" quassel)
216 add_custom_command(TARGET quasselclient POST_BUILD
217 COMMAND ${CMAKE_SOURCE_DIR}/scripts/build/macosx_makePackage.sh Client)
218 add_custom_command(TARGET quasselcore POST_BUILD
219 COMMAND ${CMAKE_SOURCE_DIR}/scripts/build/macosx_makePackage.sh Core)
225 install(TARGETS quasselcore
226 RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
230 install(TARGETS quasselclient
231 RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
233 install(FILES quasselclient.desktop
234 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications)
238 install(TARGETS quassel
239 RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
241 install(FILES quassel.desktop
242 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications)