From: Manuel Nickschas Date: Fri, 23 Jan 2009 23:35:27 +0000 (+0100) Subject: Revamping the build system (again...) X-Git-Tag: 0.4.0~175 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=36b30b6b8775f5322fad3d1ee99545a07baf9e20 Revamping the build system (again...) * LINGUAS can now be a comma-separated list, and it now supports quassel_xx_YY.ts style properly * Get rid of the options for having builtin icons * Instead, -DEMBED_DATA=ON will embed all external files into the binary, whereas all files will be installed externally if the option is not set * Data files and icons are now installed into sane locations (needs to be checked on Mac) * Various improvements and simplifications (yes, I've discovered PARENT_SCOPE now :D) Note: - Code changes to find files again follow in the next commit - -DEMBED_DATA=OFF not supported on Win32 yet, and untested on Mac and for static builds - -DWITH_KDE=ON implies -DEMBED_DATA=OFF --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e372247..0b2a96cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,5 @@ # This is the cmake-based build system for Quassel IRC. +# # You may pass various options to cmake: # -DWANT_(CORE|QTCLIENT|MONO)=(ON|OFF) # : select binaries to build @@ -7,15 +8,14 @@ # -DWITH_WEBKIT=OFF : Disable WebKit support (link previews) # -DWITH_PHONON=OFF : Disable Phonon support (audio notifications) # -DWITH_KDE=ON : Enable KDE4 support -# -DOXYGEN_ICONS=(Builtin|External) : If "Builtin" (the default), compile our Oxygen Icon Theme subset into the binary -# : If "External", we assume Oxygen is already installed on the system -# -DQUASSEL_ICONS=(Builtin|External) : If "Builtin" (the default), put our own icons into the binary -# : If "External", we install our icons into $PREFIX/share/apps/quassel (UNIX only) +# +# -DEMBED_DATA=ON : Embed all data files in icons the binary, rather than installing them separately +# # -DQT=/path/to/qt : Choose a Qt4 installation to use instead of the system Qt4 # -DSTATIC=ON : Enable static building of Quassel. Use with care. # -DDEPLOY=ON : Mac OS X only. Use only for creating Quassel Packages! # -# NOTE: You need to remove CMakeCache.txt if you plan to change any of these values! +# NOTE: You should remove CMakeCache.txt if you plan to change any of these values! project(QuasselIRC) @@ -26,8 +26,9 @@ if(COMMAND cmake_policy) endif(COMMAND cmake_policy) # Use our own (well, and KDE's) version of some modules -# In particular cmake's FindQt4 and FindOpenSSL are quite buggy +# In particular cmake's own FindQt4 and FindOpenSSL are quite buggy set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules) +include(QuasselMacros) # Various options and variables that can be set on the command line option(WANT_CORE "Build the core (server) binary" ON) @@ -40,28 +41,38 @@ option(WITH_WEBKIT "Enable WebKit support (for link previews)" ON) option(WITH_PHONON "Enable Phonon support (for audio notifications)" ON) option(WITH_KDE "Enable KDE4 integration" OFF) +# We use icon paths from KDE 4.3 trunk, which are partially invalid on older and possibly +# even on newer KDE versions. Do not disable this unless you are sure that your Quassel will +# run on a matching KDE version only. +option(WITH_OXYGEN "Install Oxygen icons. Heavily recommended unless you use KDE 4.3" ON) + option(STATIC "Enable static building (might not be portable)" OFF) -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) -option(SPUTDEV "Do not use!" OFF) -set(OXYGEN_ICONS "Builtin" CACHE STRING "Builtin: Compile Oxygen icons into the binary; External: Use system-installed Oxygen") -set(QUASSEL_ICONS "Builtin" CACHE STRING "Builtin: Compile Quassel icons into the binary; External: Install them separately") +if(APPLE) + 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) +endif(APPLE) -set(QT "" CACHE STRING "Path to a Qt installation to use instead of the system Qt") -set(LINGUAS "" CACHE STRING "Space-separated List of locales specifying languages that should be compiled") +# Default to embedding data in the static case +if(STATIC OR WIN32) + set(EMBED_DEFAULT ON) +else(STATIC OR WIN32) + set(EMBED_DEFAULT ON) # should be OFF as soon as everything works +endif(STATIC OR WIN32) +option(EMBED_DATA "Embed all data files in the binary (rather than installing them separately)" ${EMBED_DEFAULT}) + +set(QT "" CACHE STRING "Path to a Qt installation to use instead of the system Qt (e.g. for static builds)") +set(LINGUAS "" CACHE STRING "Comma-separated list of locales specifying languages that should be compiled") + +# Some settings imply others if(STATIC) - set(CMAKE_BUILD_TYPE Release) - set(OXYGEN_ICONS "Builtin") - set(QUASSEL_ICONS "Builtin") - set(WITH_KDE OFF) + set(WITH_KDE OFF CACHE BOOL "Static building with KDE is not supported") endif(STATIC) -# Define install locations. Using variables will allow overriding this by the KDE macros later. -set(BIN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/bin) -set(DATA_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/apps) -set(ICON_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/icons) -set(XDG_APPS_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/applications) +if(WIN32) + # We don't support separately installed resources yet on Win32 + set(EMBED_DATA ON) +endif(WIN32) # Enable various flags on gcc if(CMAKE_COMPILER_IS_GNUCXX) @@ -78,8 +89,6 @@ if(APPLE AND DEPLOY) add_definitions(-DMAC_10_4_SDK) endif(APPLE AND DEPLOY) -include(QuasselMacros) - # Execinfo is needed for generating backtraces find_package(ExecInfo) if(EXECINFO_FOUND) @@ -162,8 +171,7 @@ if(WITH_KDE) set(MOC_DEFINES ${MOC_DEFINES} -DHAVE_KDE) set(QUASSEL_KDE_LIBRARIES ${KDE4_KDECORE_LIBS} ${KDE4_KDEUI_LIBRARY} knotifyconfig) # We always use external icons for KDE4 support, since we use its iconloader rather than our own - set(OXYGEN_ICONS "External") - set(QUASSEL_ICONS "External") + set(EMBED_DATA OFF) else(KDE4_FOUND) message(STATUS "KDE4 not found, disabling KDE integration") endif(KDE4_FOUND) @@ -188,6 +196,21 @@ if(NOT HAVE_KDE) endif(WITH_PHONON) endif(NOT HAVE_KDE) +# Now set up install locations; those are set by KDE if integration is enabled +if(NOT HAVE_KDE) + if(WIN32) + set(BIN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX} CACHE FILEPATH "Install path for binaries") + set(DATA_INSTALL_DIR $ENV{APPDATA}/quassel-irc.org/share/apps CACHE FILEPATH "Install path for data files") + set(ICON_INSTALL_DIR $ENV{APPDATA}/quassel-irc.org/share/icons CACHE FILEPATH "Global icon install path") + set(XDG_APPS_INSTALL_DIR $ENV{APPDATA}/quassel-irc.org/share/applications CACHE FILEPATH "Install path for .desktop files") + else(WIN32) + set(BIN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/bin CACHE FILEPATH "Install path for binaries") + set(DATA_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/apps CACHE FILEPATH "Install path for data files") + set(ICON_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/icons CACHE FILEPATH "Global icon install path") + set(XDG_APPS_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/applications CACHE FILEPATH "Install path for .desktop files") + endif(WIN32) +endif(NOT HAVE_KDE) + # RPATH needs to be set correctly # Do this down here, since otherwise KDE wants to handle it itself, and fails set(CMAKE_INSTALL_RPATH_USE_LINK_PATH 1) @@ -217,11 +240,6 @@ if(WIN32) set(RC_WIN32 ../pics/win32.rc) # for app icons on windows endif(WIN32) -# This is dirty, but I haven't found a cleaner way to ensure that the generated .qrc files -# (which will be removed with make clean) are regenerated :/ -set_directory_properties(PROPERTIES - ADDITIONAL_MAKE_CLEAN_FILES CMakeCache.txt) - # We need to create a version.gen # For this, we create our genversion binary and make sure it is run every time. add_executable(genversion ${CMAKE_SOURCE_DIR}/src/common/genversion.cpp) @@ -232,33 +250,14 @@ add_custom_target(genversion_run ALL ${GENVERSION_EXECUTABLE} ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/src/version.gen) add_dependencies(genversion_run genversion) -# Decide what to do with icons -if(WANT_QTCLIENT OR WANT_MONO) - if(QUASSEL_ICONS MATCHES "External") - message(STATUS "Install Quassel icons to ${CMAKE_INSTALL_PREFIX}/share/apps/quassel") - else(QUASSEL_ICONS MATCHES "External") - set(QUASSEL_ICONS "Builtin") - message(STATUS "Compile Quassel icons into the binary") - endif(QUASSEL_ICONS MATCHES "External") - - if(OXYGEN_ICONS MATCHES "External") - message(STATUS "Use system-installed icon theme") - else(OXYGEN_ICONS MATCHES "External") - set(OXYGEN_ICONS "Builtin") - message(STATUS "Compile Oxygen icon theme subset into the binary") - endif(OXYGEN_ICONS MATCHES "External") -endif(WANT_QTCLIENT OR WANT_MONO) - # These variables will be added to the main targets (CORE, QTCLIENT, MONO) - set(COMMON_DEPS ${RC_WIN32}) set(CORE_DEPS ) set(CLIENT_DEPS ) -set(KDE_DEPS ) # Add needed subdirs - the order is important, since src needs some vars set by other dirs add_subdirectory(data) add_subdirectory(icons) -#add_subdirectory(pics) +add_subdirectory(pics) add_subdirectory(i18n) add_subdirectory(src) diff --git a/cmake/modules/QuasselMacros.cmake b/cmake/modules/QuasselMacros.cmake index 707afc9d..9d8c1cdd 100644 --- a/cmake/modules/QuasselMacros.cmake +++ b/cmake/modules/QuasselMacros.cmake @@ -20,7 +20,7 @@ endmacro(setup_qt4_variables) # This generates a .qm from a .ts file macro(generate_qm outvar basename) set(input ${CMAKE_SOURCE_DIR}/i18n/${basename}.ts) - set(output ${CMAKE_CURRENT_BINARY_DIR}/${basename}.qm) + set(output ${CMAKE_BINARY_DIR}/i18n/${basename}.qm) add_custom_command(OUTPUT ${output} COMMAND ${QT_LRELEASE_EXECUTABLE} ARGS ${input} diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt index 8d835423..239e306f 100644 --- a/data/CMakeLists.txt +++ b/data/CMakeLists.txt @@ -1,12 +1,23 @@ -if(WANT_QTCLIENT) - install(FILES quasselclient.desktop DESTINATION ${XDG_APPS_INSTALL_DIR}) -endif(WANT_QTCLIENT) +if(NOT WIN32 AND NOT APPLE) + if(WANT_QTCLIENT) + install(FILES quasselclient.desktop DESTINATION ${XDG_APPS_INSTALL_DIR}) + endif(WANT_QTCLIENT) -if(WANT_MONO) - install(FILES quassel.desktop DESTINATION ${XDG_APPS_INSTALL_DIR}) -endif(WANT_MONO) + if(WANT_MONO) + install(FILES quassel.desktop DESTINATION ${XDG_APPS_INSTALL_DIR}) + endif(WANT_MONO) + + if(WANT_MONO OR WANT_QTCLIENT) + if(HAVE_KDE) + install(FILES quassel.notifyrc DESTINATION ${DATA_INSTALL_DIR}/quassel) + endif(HAVE_KDE) + endif(WANT_MONO OR WANT_QTCLIENT) +endif(NOT WIN32 AND NOT APPLE) if(WANT_MONO OR WANT_QTCLIENT) - install(FILES quassel.notifyrc networks.ini - DESTINATION ${DATA_INSTALL_DIR}/quassel) + if(EMBED_DATA) + set(CLIENT_RCS ${CLIENT_RCS} ../data/data.qrc PARENT_SCOPE) + else(EMBED_DATA) + install(FILES networks.ini DESTINATION ${DATA_INSTALL_DIR}/quassel) + endif(EMBED_DATA) endif(WANT_MONO OR WANT_QTCLIENT) diff --git a/data/data.qrc b/data/data.qrc new file mode 100644 index 00000000..d6de7646 --- /dev/null +++ b/data/data.qrc @@ -0,0 +1,5 @@ + + + networks.ini + + diff --git a/i18n/CMakeLists.txt b/i18n/CMakeLists.txt index feb774ec..b174bed7 100644 --- a/i18n/CMakeLists.txt +++ b/i18n/CMakeLists.txt @@ -10,7 +10,7 @@ if(QT_LRELEASE_EXECUTABLE) file(GLOB avail_tsfiles quassel_*.ts) foreach(TS_FILE ${avail_tsfiles}) get_filename_component(basename ${TS_FILE} NAME_WE) - string(REGEX REPLACE "quassel_(.+)$" "\\1" lang ${basename}) + string(REGEX REPLACE "quassel_([a-zA-Z]+)(_.+)?$" "\\1" lang ${basename}) # test if we want this set(flg 1) if(LINGUAS) @@ -39,5 +39,11 @@ file(APPEND ${resfile} "\n\n") #add_custom_command(OUTPUT ${resfile} DEPENDS ${qm_files}) set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${qm_files} i18n.qrc") -qt4_add_resources(RC_I18N ${resfile}) -add_custom_target(i18n DEPENDS ${RC_I18N}) + +if(EMBED_DATA) + set(COMMON_RCS ${COMMON_RCS} ${resfile} PARENT_SCOPE) +else(EMBED_DATA) + install(FILES ${qm_files} DESTINATION ${DATA_INSTALL_DIR}/quassel/i18n) +endif(EMBED_DATA) + +add_custom_target(i18n DEPENDS ${qm_files}) diff --git a/icons/CMakeLists.txt b/icons/CMakeLists.txt index c917a068..d2ec9cb4 100644 --- a/icons/CMakeLists.txt +++ b/icons/CMakeLists.txt @@ -1,14 +1,13 @@ -# Build and/or install icons according to global settings +# Install icons +# We put them in DATA_INSTALL_DIR rather than ICON_INSTALL_DIR, to avoid +# polluting the global namespace and to allow overriding -if(QUASSEL_ICONS MATCHES "External") - install(DIRECTORY hicolor DESTINATION ${ICON_INSTALL_DIR}) -else(QUASSEL_ICONS MATCHES "External") - qt4_add_resources(RC_ICONS hicolor.qrc) -endif(QUASSEL_ICONS MATCHES "External") - -if(OXYGEN_ICONS MATCHES "Builtin") - qt4_add_resources(RC_ICONS oxygen.qrc) -endif(OXYGEN_ICONS MATCHES "Builtin") +if(EMBED_DATA) + set(CLIENT_RCS ${CLIENT_RCS} ../icons/hicolor.qrc ../icons/oxygen.qrc PARENT_SCOPE) +else(EMBED_DATA) + install(DIRECTORY hicolor DESTINATION ${DATA_INSTALL_DIR}/quassel/icons) + install(DIRECTORY oxygen DESTINATION ${DATA_INSTALL_DIR}/quassel/icons) +endif(EMBED_DATA) # Application icon if(NOT APPLE AND NOT WIN32) @@ -17,5 +16,3 @@ if(NOT APPLE AND NOT WIN32) install(FILES hicolor/48x48/apps/quassel.png DESTINATION /usr/share/pixmaps) endif(CMAKE_INSTALL_PREFIX STREQUAL "/usr") endif(NOT APPLE AND NOT WIN32) - -add_custom_target(icons DEPENDS ${RC_ICONS}) diff --git a/pics/CMakeLists.txt b/pics/CMakeLists.txt new file mode 100644 index 00000000..89402a56 --- /dev/null +++ b/pics/CMakeLists.txt @@ -0,0 +1,15 @@ +# pics/ contains non-themed icons and other graphical resources + +if(WIN32) + set(COMMON_DEPS ${COMMON_DEPS} ../pics/win32.rc PARENT_SCOPE) +endif(WIN32) + +if(WANT_MONO OR WANT_QTCLIENT) + if(EMBED_DATA) + set(CLIENT_RCS ${CLIENT_RCS} ../pics/pics.qrc PARENT_SCOPE) + else(EMBED_DATA) + install(FILES qt-logo.png + quassel-large.png + DESTINATION ${DATA_INSTALL_DIR}/quassel/pics) + endif(EMBED_DATA) +endif(WANT_MONO OR WANT_QTCLIENT) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9af8c50a..05c0c2a4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -22,23 +22,16 @@ endif(WANT_QTCLIENT OR WANT_MONO) include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}) # for version.gen -# We always add stuff in :/pics -qt4_add_resources(CLIENT_DEPS ../pics/pics.qrc) - -if(QUASSEL_ICONS MATCHES "Builtin") - set(CLIENT_DEPS ${CLIENT_DEPS} ../icons/qrc_hicolor.cxx) - set_source_files_properties(../icons/qrc_hicolor.cxx PROPERTIES GENERATED true) -endif(QUASSEL_ICONS MATCHES "Builtin") - -if(OXYGEN_ICONS MATCHES "Builtin") - set(CLIENT_DEPS ${CLIENT_DEPS} ../icons/qrc_oxygen.cxx) - set_source_files_properties(../icons/qrc_oxygen.cxx PROPERTIES GENERATED true) -endif(OXYGEN_ICONS MATCHES "Builtin") +# Add resources. Can't be done in other subdirs apparently. +# Note that these variables need to contain paths relative to src/ (this dir) +qt4_add_resources(CLIENT_DEPS ${CLIENT_RCS}) +qt4_add_resources(CORE_DEPS ${CORE_RCS}) +qt4_add_resources(COMMON_DEPS ${COMMON_RCS}) if(WANT_CORE) setup_qt4_variables(NETWORK SCRIPT SQL) add_executable(quasselcore common/main.cpp ${COMMON_DEPS} ${CORE_DEPS}) - add_dependencies(quasselcore genversion_run) + add_dependencies(quasselcore i18n genversion_run) set_target_properties(quasselcore PROPERTIES COMPILE_FLAGS "-DQT_NETWORK_LIB -DQT_SCRIPT_LIB -DQT_SQL_LIB -DBUILD_CORE" OUTPUT_NAME ../quasselcore) @@ -50,7 +43,7 @@ endif(WANT_CORE) if(WANT_QTCLIENT) setup_qt4_variables(${LINK_DBUS} GUI NETWORK ${LINK_WEBKIT}) add_executable(quasselclient WIN32 common/main.cpp ${COMMON_DEPS} ${CLIENT_DEPS}) - add_dependencies(quasselclient icons genversion_run) + add_dependencies(quasselclient i18n genversion_run) set_target_properties(quasselclient PROPERTIES COMPILE_FLAGS "-DQT_GUI_LIB -DQT_NETWORK_LIB -DBUILD_QTUI" OUTPUT_NAME ../quasselclient) @@ -63,7 +56,7 @@ if(WANT_MONO) setup_qt4_variables(${LINK_DBUS} GUI NETWORK SCRIPT SQL ${LINK_WEBKIT}) qt4_wrap_cpp(MOC qtui/monoapplication.h) add_executable(quassel WIN32 common/main.cpp qtui/monoapplication.cpp ${MOC} ${COMMON_DEPS} ${CLIENT_DEPS} ${CORE_DEPS}) - add_dependencies(quassel icons genversion_run) + add_dependencies(quassel i18n genversion_run) set_target_properties(quassel PROPERTIES COMPILE_FLAGS "-DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_SCRIPT_LIB -DQT_SQL_LIB -DBUILD_MONO" OUTPUT_NAME ../quassel) diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index acded6de..dc790b6a 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -61,6 +61,4 @@ qt4_wrap_cpp(MOC ${MOC_HDRS}) include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}) # for version.inc and version.gen set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES version.gen) -add_library(mod_common STATIC ${SOURCES} ${MOC} ${CMAKE_BINARY_DIR}/i18n/qrc_i18n.cxx) -set_source_files_properties(${CMAKE_BINARY_DIR}/i18n/qrc_i18n.cxx PROPERTIES GENERATED true) -add_dependencies(mod_common i18n) +add_library(mod_common STATIC ${SOURCES} ${MOC}) diff --git a/src/common/main.cpp b/src/common/main.cpp index 362f8216..b567af4f 100644 --- a/src/common/main.cpp +++ b/src/common/main.cpp @@ -45,7 +45,6 @@ #include "quassel.h" int main(int argc, char **argv) { - Q_INIT_RESOURCE(i18n); // Setup build information and version string # include "version.gen" diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 9f799493..e0e2044d 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -65,9 +65,9 @@ if(HAVE_SSL) endif(HAVE_SSL) qt4_wrap_cpp(MOC ${MOC_HDRS}) -qt4_add_resources(RC_SQL sql.qrc) +set(CORE_RCS ${CORE_RCS} core/sql.qrc PARENT_SCOPE) include_directories(${CMAKE_SOURCE_DIR}/src/common) -add_library(mod_core STATIC ${SOURCES} ${MOC} ${HEADERS} ${RC_SQL}) +add_library(mod_core STATIC ${SOURCES} ${MOC} ${HEADERS}) add_dependencies(mod_core mod_common) diff --git a/src/core/coreapplication.cpp b/src/core/coreapplication.cpp index 9b9a0b20..06de578e 100644 --- a/src/core/coreapplication.cpp +++ b/src/core/coreapplication.cpp @@ -26,7 +26,7 @@ CoreApplicationInternal::CoreApplicationInternal() : _coreCreated(false) { - Q_INIT_RESOURCE(sql); + } CoreApplicationInternal::~CoreApplicationInternal() {