diff --git a/CMakeLists.txt b/CMakeLists.txt index 76e1aca47..d3d3b8101 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,7 @@ option(WITH_TESTS "Enable building of unit tests" ON) option(WITH_GUI_TESTS "Enable building of GUI tests" OFF) option(WITH_LTO "Enable Link Time Optimization (LTO)" OFF) option(WITH_PIE "Build as Position-independent executable (PIE)" OFF) +option(WITH_CXX11 "Build with the C++ 11 standard" OFF) set(KEEPASSX_VERSION "2.0 alpha 1") set(KEEPASSX_VERSION_NUM "1.9.80") @@ -113,6 +114,10 @@ if(WITH_PIE) endif() endif() +if (WITH_CXX11) + add_gcc_compiler_cxxflags("-std=c++0x") +endif() + if(APPLE OR MINGW) set(PROGNAME KeePassX) else() diff --git a/src/core/Global.h b/src/core/Global.h new file mode 100644 index 000000000..75701ec2d --- /dev/null +++ b/src/core/Global.h @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2012 Felix Geyer + * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) + * Copyright (C) 2012 Intel Corporation + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 or (at your option) + * version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef KEEPASSX_GLOBAL_H +#define KEEPASSX_GLOBAL_H + +// mostly copied from qcompilerdetection.h which is part of Qt 5 + +#include + +#ifdef Q_CC_CLANG +# if __cplusplus >= 201103L || __GXX_EXPERIMENTAL_CXX0X__ +# if ((__clang_major__ * 100) + __clang_minor__) >= 209 /* since clang 2.9 */ +# define COMPILER_DECLTYPE +# endif +# if ((__clang_major__ * 100) + __clang_minor__) >= 300 /* since clang 3.0 */ +# define COMPILER_CLASS_ENUM +# define COMPILER_EXPLICIT_OVERRIDES +# define COMPILER_NULLPTR +# endif +# endif +#endif // Q_CC_CLANG + +#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && !defined(Q_CC_CLANG) +# if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L +# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 403 + /* C++11 features supported in GCC 4.3: */ +# define COMPILER_DECLTYPE +# endif +# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 +# define COMPILER_CLASS_ENUM +# endif +# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 +# define COMPILER_CONSTEXPR +# define COMPILER_NULLPTR +# endif +# endif +#endif + +/* + * C++11 keywords and expressions + */ +#if !defined(Q_NULLPTR) +# ifdef COMPILER_NULLPTR +# define Q_NULLPTR nullptr +# else +# define Q_NULLPTR 0 +# endif +#endif + +#if !defined(Q_DECL_CONSTEXPR) +# ifdef COMPILER_CONSTEXPR +# define Q_DECL_CONSTEXPR constexpr +# else +# define Q_DECL_CONSTEXPR +# endif +#endif + +#if !defined(Q_DECL_OVERRIDE) && !defined(Q_DECL_FINAL) && !defined(Q_DECL_FINAL_CLASS) +# ifdef COMPILER_EXPLICIT_OVERRIDES +# define Q_DECL_OVERRIDE override +# define Q_DECL_FINAL final +# ifdef COMPILER_DECLTYPE +# define Q_DECL_FINAL_CLASS final +# else +# define Q_DECL_FINAL_CLASS +# endif +# else +# define Q_DECL_OVERRIDE +# define Q_DECL_FINAL +# define Q_DECL_FINAL_CLASS +# endif +#endif + +#endif // KEEPASSX_GLOBAL_H