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=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 # Target scopes don't work in older versions
15 cmake_minimum_required(VERSION 2.4.7 FATAL_ERROR)
17 # This would suppress annoying warnings on cmake-2.6, but we can't use it
18 # with 2.4, so... DUH!
19 # cmake_policy(SET CMP0003 OLD) # suppress linker warnings
22 set(CMAKE_BUILD_TYPE Release)
25 # Enable various flags on gcc
26 include(CheckCXXCompilerFlag)
27 check_cxx_compiler_flag(-Wall Wall)
29 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
31 check_cxx_compiler_flag(-Wextra Wextra)
33 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra")
35 check_cxx_compiler_flag(-ansi ansi)
37 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ansi")
40 set(QT_MIN_VERSION "4.3.0")
42 option(WANT_CORE "Build the core (server) binary" ON)
43 option(WANT_QTCLIENT "Build the Qt4 GUI client binary" ON)
44 option(WANT_MONO "Build the monolithic (all-in-one) binary" ON)
46 # Enable mostly b0rked stuff (new ChatView), do not enable this unless you know what you do...
48 add_definitions(-DSPUTDEV)
54 # Select a Qt installation here, if you don't want to use system Qt
56 # FindQt4 will look for the qmake binary in $PATH, so we just prepend the Qt dir
57 set(ENV{PATH} ${QT}/bin:$ENV{PATH})
58 #SET(QT_QMAKE_EXECUTABLE ${QT}/bin/qmake CACHE FILEPATH "" FORCE)
61 # Now that we have the correct $PATH, lets find Qt!
62 find_package(Qt4 REQUIRED)
64 set(QT_DONT_USE_QTGUI 1)
65 include(${QT_USE_FILE})
66 include_directories(${QT_INCLUDES})
68 # We need to create a version.gen
69 # For this, we create our genversion binary and make sure it is run every time.
70 add_executable(genversion ${CMAKE_SOURCE_DIR}/src/common/genversion.cpp)
71 target_link_libraries(genversion ${QT_LIBRARIES})
73 add_custom_target(genversion_run ALL ${CMAKE_BINARY_DIR}/genversion
74 ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/src/common/version.gen)
75 add_dependencies(genversion_run genversion)
78 add_subdirectory(src/common)
79 include_directories(src/common)
80 if(WANT_CORE OR WANT_MONO)
81 add_subdirectory(src/core)
82 include_directories(src/core)
83 endif(WANT_CORE OR WANT_MONO)
84 if(WANT_QTCLIENT OR WANT_MONO)
85 add_subdirectory(src/client)
86 add_subdirectory(src/uisupport)
87 add_subdirectory(src/qtui)
88 include_directories(src/client)
89 include_directories(src/uisupport)
90 include_directories(src/qtui)
91 endif(WANT_QTCLIENT OR WANT_MONO)
93 # Make sure version.gen exists before building mod_common
94 add_dependencies(mod_common genversion_run)
97 qt4_add_resources(RC_I18N i18n/i18n.qrc)
98 qt4_add_resources(RC_ICONS src/icons/icons.qrc)
99 qt4_add_resources(RC_QUASSEL_ICONS src/icons/quassel-icons.qrc)
100 qt4_add_resources(RC_SQL src/core/sql.qrc)
102 # Set global buildflags
104 set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc ${CMAKE_EXE_LINKER_FLAGS}")
105 link_directories(${CMAKE_BINARY_DIR}/staticlibs)
106 endif(DEFINED STATIC)
108 if(STATICWIN AND WIN32)
109 link_libraries(imm32 winmm) # missing by default :/
111 link_libraries(${OPENSSL_LIBRARIES} libeay32MD)
113 endif(STATICWIN AND WIN32)
116 set(WIN32_RC src/icons/win32.rc) # for app icons on windows
119 # Here comes the dirty part. Our targets need different Qt4 modules, i.e. different libs
120 # and defines. We can't simply include UseQt4 several times, since definitions add up.
121 # We workaround this by using our own macro to figure out what to add.
123 # This macro sets variables for additional Qt modules.
124 macro(setup_qt4_variables)
125 set(QUASSEL_QT_LIBRARIES )
126 foreach(qtmod CORE ${ARGV})
127 set(QUASSEL_QT_LIBRARIES ${QUASSEL_QT_LIBRARIES} ${QT_QT${qtmod}_LIBRARY} ${QT_${qtmod}_LIB_DEPENDENCIES})
128 endforeach(qtmod ${ARGV})
129 set(QUASSEL_QT_LIBRARIES ${QUASSEL_QT_LIBRARIES} ${QT_LIBRARIES})
130 endmacro(setup_qt4_variables)
132 # Now we have everything, so just glue the right pieces together :)
134 setup_qt4_variables(NETWORK SCRIPT SQL)
135 add_executable(quasselcore ${CMAKE_SOURCE_DIR}/src/common/main.cpp
136 ${RC_SQL} ${RC_I18N} ${WIN32_RC})
137 set_target_properties(quasselcore PROPERTIES
138 COMPILE_FLAGS "-DQT_NETWORK_LIB -DQT_SCRIPT_LIB -DQT_SQL_LIB -DBUILD_CORE")
139 target_link_libraries(quasselcore mod_core mod_common ${QUASSEL_QT_LIBRARIES})
143 setup_qt4_variables(GUI NETWORK)
144 add_executable(quasselclient ${CMAKE_SOURCE_DIR}/src/common/main.cpp
145 ${RC_ICONS} ${RC_QUASSEL_ICONS} ${RC_I18N} ${WIN32_RC})
146 set_target_properties(quasselclient PROPERTIES
147 COMPILE_FLAGS "-DQT_GUI_LIB -DQT_NETWORK_LIB -DBUILD_QTUI")
148 target_link_libraries(quasselclient mod_qtui mod_uisupport mod_client mod_common ${QUASSEL_QT_LIBRARIES})
152 setup_qt4_variables(GUI NETWORK SCRIPT SQL)
153 add_executable(quassel ${CMAKE_SOURCE_DIR}/src/common/main.cpp
154 ${RC_ICONS} ${RC_QUASSEL_ICONS} ${RC_SQL} ${RC_I18N} ${WIN32_RC})
155 set_target_properties(quassel PROPERTIES
156 COMPILE_FLAGS "-DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_SCRIPT_LIB -DQT_SQL_LIB -DBUILD_MONO")
157 target_link_libraries(quassel mod_qtui mod_uisupport mod_client mod_core mod_common ${QUASSEL_QT_LIBRARIES})
160 # Build bundles for MacOSX
162 add_custom_command(TARGET quasselclient POST_BUILD
163 COMMAND ${CMAKE_SOURCE_DIR}/scripts/build/macosx_makebundle.py
164 ${CMAKE_SOURCE_DIR} "Quassel Client" quasselclient)
165 add_custom_command(TARGET quassel POST_BUILD
166 COMMAND ${CMAKE_SOURCE_DIR}/scripts/build/macosx_makebundle.py
167 ${CMAKE_SOURCE_DIR} "Quassel" quassel)
172 install(TARGETS quasselcore
173 RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
177 install(TARGETS quasselclient
178 RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
180 install(FILES quasselclient.desktop
181 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications)
185 install(TARGETS quassel
186 RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
188 install(FILES quassel.desktop
189 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications)