From af9bfa0581dd3620f6fe300084262c55c7084046 Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Tue, 31 Jul 2018 23:14:16 +0200 Subject: [PATCH] cmake: Remove support for building static binaries Building and running static binaries has become increasingly difficult on modern systems, in particular when involving complex libraries like Qt due to their reliance on plugins and other dynamically loaded resources. It is also a security risk, as upgrades to system libraries won't apply to the static binary. Having a static quasselcore binary was quite useful when it was hard to get Qt on an X11-less box, but these days all major distros support modular Qt, and can provide Quasselcore packages that don't require graphical dependencies. Consequently, we no longer intend to offer static binaries. Thus, remove the corresponding hacks from the build system. --- CMakeLists.txt | 35 +++----------------------------- doc/build-static-quassel | 43 ---------------------------------------- po/CMakeLists.txt | 4 ++-- src/CMakeLists.txt | 5 ----- src/common/main.cpp | 6 ------ 5 files changed, 5 insertions(+), 88 deletions(-) delete mode 100644 doc/build-static-quassel diff --git a/CMakeLists.txt b/CMakeLists.txt index c43ba1ae..afb620cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -111,13 +111,13 @@ if (APPLE) link_libraries(${CARBON_LIBRARY}) endif() -# Always embed on Windows, OSX or for a static build; never embed when enabling KDE integration +# Always embed on Windows or OSX; never embed when enabling KDE integration set(EMBED_DEFAULT OFF) -if (STATIC OR WIN32 OR APPLE) +if (WIN32 OR APPLE) set(EMBED_DEFAULT ON) endif() cmake_dependent_option(EMBED_DATA "Embed icons and translations into the binaries instead of installing them" ${EMBED_DEFAULT} - "NOT STATIC;NOT WIN32;NOT WITH_KDE" ${EMBED_DEFAULT}) + "NOT WIN32;NOT WITH_KDE" ${EMBED_DEFAULT}) if (NOT EMBED_DEFAULT) add_feature_info(EMBED_DATA EMBED_DATA "Embed icons and translations in the binaries instead of installing them") endif() @@ -125,18 +125,6 @@ endif() # The following options are not for end-user consumption, so don't list them in the feature summary cmake_dependent_option(DEPLOY "Add required libs to bundle resources and create a dmg. Note: requires Qt to be built with 10.4u SDK" OFF "APPLE" OFF) -# Static builds are not supported and require some manual setup! Don't enable unless you know what you're doing (we don't know either) -cmake_dependent_option(STATIC "Enable static building (not supported)" OFF "NOT WITH_KDE" OFF) - -# For static builds, arbitrary extra libs might need to be linked -# Define a comma-separated list here -# e.g. for pgsql, we need -DLINK_EXTRA=pq;crypt -set(LINK_EXTRA "" CACHE STRING "Semicolon-separated list of libraries to be linked") -if (LINK_EXTRA) - string(REPLACE "," ";" LINK_EXTRA ${LINK_EXTRA}) - link_libraries(${LINK_EXTRA}) -endif() - # List of authenticators and the cmake flags to build them # (currently that's just LDAP, but more can be added here). @@ -519,23 +507,6 @@ if (WIN32) link_libraries(Version dwmapi shlwapi) set(QT_QTMAIN_LIBRARY Qt5::WinMain) endif() - if(HAVE_SSL AND STATIC) - find_package(OpenSSL REQUIRED) - link_libraries(${OPENSSL_LIBRARIES} ${OPENSSL_EAY_LIBRARIES}) - endif() -endif() - - -# Static builds (very much non-portable, so don't use -DSTATIC -# unless you know what you do!) -##################################################################### - -if(STATIC AND CMAKE_COMPILER_IS_GNUCXX) - set(CMAKE_CXX_FLAGS "-static-libgcc ${CMAKE_CXX_FLAGS}") - link_directories(${CMAKE_BINARY_DIR}/staticlibs) # override dynamic libs - if (HAVE_SSL) - set(QUASSEL_SSL_LIBRARIES ssl crypto) # these miss in static builds - endif() endif() diff --git a/doc/build-static-quassel b/doc/build-static-quassel deleted file mode 100644 index 1f367648..00000000 --- a/doc/build-static-quassel +++ /dev/null @@ -1,43 +0,0 @@ -These notes should help you to build a quasselcore statically linked to Qt -and OpenSSL. Note that these are just hints that work for me; ymmv. - -1.) Get a statically linked Qt - As of Qt 4.4, this configure line for building should probably work if - you only want to build a static core (since we disable most GUI - components here; you'd need to adjust that line for a full Qt!) - - ./configure -static -no-accessibility -qt-sql-sqlite -qt-zlib -no-qt3support \ - -no-gif -no-libtiff -no-libpng -no-libmng -no-libjpeg -nomake demos -nomake examples \ - -nomake gui -nomake uic -nomake opengl -nomake tools -no-opengl -no-sm -no-xshape \ - -no-xinerama -no-xcursor -no-xfixes -no-xrandr -no-xrender -no-fontconfig -no-tablet \ - -no-xkb -no-glib -no-svg -openssl-linked -no-phonon -no-webkit -no-dbus -no-xmlpatterns \ - -prefix /usr/local/Trolltech/qt-4.4-static - - To only build non-X dependent parts of Qt: - - $> export QT4_TARGET_DIRECTORIES="src/tools/moc src/tools/rcc src/tools/uic src/corelib src/xml \ - src/network src/sql src/plugins/codecs src/script" - $> for i in $QT4_TARGET_DIRECTORIES; do make -C $i; done - - NOTE: This has not really been tested and may or may not be working for - you. If in doubt, follow the official route and just do make - and make install. - -2.) Link some system libs into /path/to/builddir/staticlibs - (we need this, because otherwise your quasselcore wouldn't be - portable) - - On my system, I have this in staticlibs: - libcrypto.a -> /usr/lib/libcrypto.a - libssl.a -> /usr/lib/libssl.a - libstdc++.a -> /usr/lib/gcc/i686-pc-linux-gnu/4.2.3/libstdc++.a - - YMMV depending on the exact versions installed on your system, of course. - -3.) Build Quassel Core: - - $> cd /path/to/builddir - $> cmake /path/to/source -DSTATIC=1 -DWANT_QTCLIENT=0 -DWANT_MONO=0 -DQT=/usr/local/Trolltech/qt-4.4-static - $> make - -4.) Enjoy. diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt index 03a6d055..cac949c7 100644 --- a/po/CMakeLists.txt +++ b/po/CMakeLists.txt @@ -33,9 +33,9 @@ else() message(STATUS "WARNING: lconvert not found, you won't have translations!") endif() -# For a static or win32 build, we need to include Qt translations if available +# For a Win32 build, we need to include Qt translations if available if(QT_TRANSLATIONS_DIR) - if(STATIC OR WIN32) + if(WIN32) foreach(LANG ${gen_linguas}) file(GLOB lang_files ${QT_TRANSLATIONS_DIR}/qt_${LANG}*.qm) foreach(absfile ${lang_files}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8beb17c0..24a6aa7a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -13,11 +13,6 @@ if(BUILD_GUI) include_directories(BEFORE client) include_directories(BEFORE uisupport) include_directories(BEFORE qtui) - - if(STATIC) - link_directories(${QT_PLUGINS_DIR}/imageformats) - set(CLIENT_LIBRARIES ${CLIENT_LIBRARIES} qjpeg qgif) - endif() endif() include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}) # for version.gen diff --git a/src/common/main.cpp b/src/common/main.cpp index 20ea4d30..c8185b03 100644 --- a/src/common/main.cpp +++ b/src/common/main.cpp @@ -52,12 +52,6 @@ # include #endif -#if !defined(BUILD_CORE) && defined(STATIC) -#include -Q_IMPORT_PLUGIN(qjpeg) -Q_IMPORT_PLUGIN(qgif) -#endif - #include "quassel.h" #include "types.h" -- 2.20.1