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 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 # Enable various flags on gcc
25 include(CheckCXXCompilerFlag)
26 check_cxx_compiler_flag(-Wall Wall)
28 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
30 check_cxx_compiler_flag(-Wextra Wextra)
32 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra")
34 check_cxx_compiler_flag(-ansi ansi)
36 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ansi")
39 set(QT_MIN_VERSION "4.3.0")
41 option(WANT_CORE "Build the core (server) binary" ON)
42 option(WANT_QTCLIENT "Build the Qt4 GUI client binary" ON)
43 option(WANT_MONO "Build the monolithic (all-in-one) binary" ON)
45 # Enable mostly b0rked stuff (new ChatView), do not enable this unless you know what you do...
47 add_definitions(-DSPUTDEV)
53 # Select a Qt installation here, if you don't want to use system Qt
55 # FindQt4 will look for the qmake binary in $PATH, so we just prepend the Qt dir
56 set(ENV{PATH} ${QT}/bin:$ENV{PATH})
57 #SET(QT_QMAKE_EXECUTABLE ${QT}/bin/qmake CACHE FILEPATH "" FORCE)
60 # Now that we have the correct $PATH, lets find Qt!
61 find_package(Qt4 REQUIRED)
63 set(QT_DONT_USE_QTGUI 1)
64 include(${QT_USE_FILE})
65 include_directories(${QT_INCLUDES})
67 # We need to create a version.gen
68 # For this, we create our genversion binary and make sure it is run every time.
69 add_executable(genversion ${CMAKE_SOURCE_DIR}/src/common/genversion.cpp)
70 target_link_libraries(genversion ${QT_LIBRARIES})
72 add_custom_target(genversion_run ALL ${CMAKE_BINARY_DIR}/genversion
73 ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/src/common/version.gen)
74 add_dependencies(genversion_run genversion)
77 add_subdirectory(src/common)
78 include_directories(src/common)
79 if(WANT_CORE OR WANT_MONO)
80 add_subdirectory(src/core)
81 include_directories(src/core)
82 endif(WANT_CORE OR WANT_MONO)
83 if(WANT_QTCLIENT OR WANT_MONO)
84 add_subdirectory(src/client)
85 add_subdirectory(src/uisupport)
86 add_subdirectory(src/qtui)
87 include_directories(src/client)
88 include_directories(src/uisupport)
89 include_directories(src/qtui)
90 endif(WANT_QTCLIENT OR WANT_MONO)
92 # Make sure version.gen exists before building mod_common
93 add_dependencies(mod_common genversion_run)
96 qt4_add_resources(RC_I18N i18n/i18n.qrc)
97 qt4_add_resources(RC_ICONS src/icons/icons.qrc)
98 qt4_add_resources(RC_QUASSEL_ICONS src/icons/quassel-icons.qrc)
99 qt4_add_resources(RC_SQL src/core/sql.qrc)
101 # Set global buildflags
103 set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc ${CMAKE_EXE_LINKER_FLAGS}")
104 link_directories(${CMAKE_BINARY_DIR}/staticlibs)
105 endif(DEFINED STATIC)
107 if(STATICWIN AND WIN32)
108 link_libraries(imm32 winmm) # missing by default :/
110 link_libraries(${OPENSSL_LIBRARIES} libeay32MD)
112 endif(STATICWIN AND WIN32)
115 set(WIN32_RC src/icons/win32.rc) # for app icons on windows
118 # Here comes the dirty part. Our targets need different Qt4 modules, i.e. different libs
119 # and defines. We can't simply include UseQt4 several times, since definitions add up.
120 # We workaround this by using our own macro to figure out what to add.
122 # This macro sets variables for additional Qt modules.
123 macro(setup_qt4_variables)
124 set(QUASSEL_QT_LIBRARIES )
125 foreach(qtmod CORE ${ARGV})
126 set(QUASSEL_QT_LIBRARIES ${QUASSEL_QT_LIBRARIES} ${QT_QT${qtmod}_LIBRARY} ${QT_${qtmod}_LIB_DEPENDENCIES})
127 endforeach(qtmod ${ARGV})
128 set(QUASSEL_QT_LIBRARIES ${QUASSEL_QT_LIBRARIES} ${QT_LIBRARIES})
129 endmacro(setup_qt4_variables)
131 # Now we have everything, so just glue the right pieces together :)
133 setup_qt4_variables(NETWORK SCRIPT SQL)
134 add_executable(quasselcore ${CMAKE_SOURCE_DIR}/src/common/main.cpp
135 ${RC_SQL} ${RC_I18N} ${WIN32_RC})
136 set_target_properties(quasselcore PROPERTIES
137 COMPILE_FLAGS "-DQT_NETWORK_LIB -DQT_SCRIPT_LIB -DQT_SQL_LIB -DBUILD_CORE")
138 target_link_libraries(quasselcore mod_core mod_common ${QUASSEL_QT_LIBRARIES})
142 setup_qt4_variables(GUI NETWORK)
143 add_executable(quasselclient ${CMAKE_SOURCE_DIR}/src/common/main.cpp
144 ${RC_ICONS} ${RC_QUASSEL_ICONS} ${RC_I18N} ${WIN32_RC})
145 set_target_properties(quasselclient PROPERTIES
146 COMPILE_FLAGS "-DQT_GUI_LIB -DQT_NETWORK_LIB -DBUILD_QTUI")
147 target_link_libraries(quasselclient mod_qtui mod_uisupport mod_client mod_common ${QUASSEL_QT_LIBRARIES})
151 setup_qt4_variables(GUI NETWORK SCRIPT SQL)
152 add_executable(quassel ${CMAKE_SOURCE_DIR}/src/common/main.cpp
153 ${RC_ICONS} ${RC_QUASSEL_ICONS} ${RC_SQL} ${RC_I18N} ${WIN32_RC})
154 set_target_properties(quassel PROPERTIES
155 COMPILE_FLAGS "-DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_SCRIPT_LIB -DQT_SQL_LIB -DBUILD_MONO")
156 target_link_libraries(quassel mod_qtui mod_uisupport mod_client mod_core mod_common ${QUASSEL_QT_LIBRARIES})
159 # Build bundles for MacOSX
161 add_custom_command(TARGET quasselclient POST_BUILD
162 COMMAND ${CMAKE_SOURCE_DIR}/scripts/build/macosx_makebundle.py
163 ${CMAKE_SOURCE_DIR} "Quassel Client" quasselclient)
164 add_custom_command(TARGET quassel POST_BUILD
165 COMMAND ${CMAKE_SOURCE_DIR}/scripts/build/macosx_makebundle.py
166 ${CMAKE_SOURCE_DIR} "Quassel" quassel)
171 install(TARGETS quasselcore
172 RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
176 install(TARGETS quasselclient
177 RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
179 install(FILES quasselclient.desktop
180 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications)
184 install(TARGETS quassel
185 RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
187 install(FILES quassel.desktop
188 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications)