From 976bf2f6846e93372f1e0b30172beff99db92270 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Mon, 6 Nov 2017 18:59:21 +0200 Subject: [PATCH] add ENABLE_MAKE_UNIQUE flag for older gcc versions -- fix #754 -- make_unique function is not available for gcc<=4.8.x by enabling this flag in through install script or through cmake such systems can build latte correctly --- CMakeLists.txt | 2 +- install.sh | 12 +++++++++--- liblattedock/CMakeLists.txt | 2 ++ liblattedock/config-latte-lib.h.cmake | 6 ++++++ liblattedock/extras.h | 15 +++++++++++++++ 5 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 liblattedock/config-latte-lib.h.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 38cf92323..0000cf867 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,11 +56,11 @@ include(WriteBasicConfigVersionFile) include(Definitions.cmake) +add_subdirectory(liblattedock) add_subdirectory(app) add_subdirectory(applets) add_subdirectory(containment) add_subdirectory(icons) -add_subdirectory(liblattedock) add_subdirectory(plasmoid) add_subdirectory(shell) diff --git a/install.sh b/install.sh index 46c7d21f5..d3085689e 100755 --- a/install.sh +++ b/install.sh @@ -7,6 +7,12 @@ set -e build_type=$1 build_type=${build_type:="Release"} +enable_make_unique=OFF + +if [ "$1" == "--enable-make-unique" ] || [ "$2" == "--enable-make-unique" ] ; then + enable_make_unique=ON +fi + if ! [ -a build ] ; then mkdir build fi @@ -21,13 +27,13 @@ if [ -a locale ] ; then fi if [ "$1" == "--translations" ] ; then - cmake -DCMAKE_INSTALL_PREFIX=/usr -DKDE_L10N_BRANCH=trunk -DKDE_L10N_AUTO_TRANSLATIONS=ON -DCMAKE_BUILD_TYPE=$build_type .. + cmake -DCMAKE_INSTALL_PREFIX=/usr -DKDE_L10N_BRANCH=trunk -DKDE_L10N_AUTO_TRANSLATIONS=ON -DENABLE_MAKE_UNIQUE=$enable_make_unique -DCMAKE_BUILD_TYPE=$build_type .. make fetch-translations elif [ "$1" == "--translations-stable" ] ; then - cmake -DCMAKE_INSTALL_PREFIX=/usr -DKDE_L10N_BRANCH=stable -DKDE_L10N_AUTO_TRANSLATIONS=ON -DCMAKE_BUILD_TYPE=$build_type .. + cmake -DCMAKE_INSTALL_PREFIX=/usr -DKDE_L10N_BRANCH=stable -DKDE_L10N_AUTO_TRANSLATIONS=ON -DENABLE_MAKE_UNIQUE=$enable_make_unique -DCMAKE_BUILD_TYPE=$build_type .. make fetch-translations else - cmake -DCMAKE_INSTALL_PREFIX=/usr -DKDE_L10N_AUTO_TRANSLATIONS=OFF -DCMAKE_BUILD_TYPE=$build_type .. + cmake -DCMAKE_INSTALL_PREFIX=/usr -DKDE_L10N_AUTO_TRANSLATIONS=OFF -DENABLE_MAKE_UNIQUE=$enable_make_unique -DCMAKE_BUILD_TYPE=$build_type .. make fi diff --git a/liblattedock/CMakeLists.txt b/liblattedock/CMakeLists.txt index b700d6738..45e6cafbc 100644 --- a/liblattedock/CMakeLists.txt +++ b/liblattedock/CMakeLists.txt @@ -1,3 +1,5 @@ +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config-latte-lib.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-latte-lib.h) + set(lattedock_SRCS lattedockplugin.cpp quickwindowsystem.cpp diff --git a/liblattedock/config-latte-lib.h.cmake b/liblattedock/config-latte-lib.h.cmake new file mode 100644 index 000000000..e5eab3d45 --- /dev/null +++ b/liblattedock/config-latte-lib.h.cmake @@ -0,0 +1,6 @@ +#ifndef CONFIG_LATTE_LIB_H +#define CONFIG_LATTE_LIB_H + +#cmakedefine01 ENABLE_MAKE_UNIQUE + +#endif // CONFIG_LATTE_LIB_H diff --git a/liblattedock/extras.h b/liblattedock/extras.h index eb9fe1f69..e4547f0b4 100644 --- a/liblattedock/extras.h +++ b/liblattedock/extras.h @@ -1,6 +1,8 @@ #ifndef EXTRAS_H #define EXTRAS_H +#include "../liblattedock/config-latte-lib.h" + #include #include #include @@ -15,6 +17,19 @@ #include #include +//! There are gcc versions that dont support yet that function even though they +//! publish themselves as C++14 compatible. Such a case is gcc 4.8.x that openSUSE +//! LEAP 42.2-3 is using. By enabling this flag such systems can be build correctly. +#if ENABLE_MAKE_UNIQUE +namespace std { +template +unique_ptr make_unique(Args &&... args) +{ + return std::unique_ptr(new T(std::forward(args)...)); +} +} +#endif + /*! * @brief convert a QRect to a QString with format `(, ) x` */