[kdevplatform] /: Enable C++11 for KDevelop.
Milian Wolff
mail at milianw.de
Sat Dec 14 14:25:53 UTC 2013
Git commit fedb51885a812f2dad631441018c66a60bef0dc3 by Milian Wolff.
Committed on 14/12/2013 at 14:00.
Pushed by mwolff into branch 'master'.
Enable C++11 for KDevelop.
Please stick to the (nearly complete) subset supported by GCC 4.8 [1]
and Clang 3.1 [2]. Happy hacking!
[1]: http://gcc.gnu.org/gcc-4.8/cxx0x_status.html
[2]: http://clang.llvm.org/cxx_status.html
CCMAIL: kdevelop-devel at kde.org
M +4 -0 CMakeLists.txt
M +0 -17 language/duchain/tests/CMakeLists.txt
M +1 -18 language/duchain/tests/benchhashes.cpp
D +0 -1 language/duchain/tests/hashconfig.h.cmake
http://commits.kde.org/kdevplatform/fedb51885a812f2dad631441018c66a60bef0dc3
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5fbe96c..125d41a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -44,6 +44,10 @@ set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS -DQURL_NO_CAST_FROM_QSTRING)
+if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+endif()
+
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/config-kdevplatform.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/config-kdevplatform.h )
diff --git a/language/duchain/tests/CMakeLists.txt b/language/duchain/tests/CMakeLists.txt
index d071260..0fcc9cb 100644
--- a/language/duchain/tests/CMakeLists.txt
+++ b/language/duchain/tests/CMakeLists.txt
@@ -42,23 +42,6 @@ target_link_libraries(itemrepositoryregistry_deferred_test ${QT_QTTEST_LIBRARY}
########### next target ###############
-# TODO: Remove when LTS for g++ < 4.3 has ended.
-# See also: languages/cpp/parser/parser.h in KDevelop
-if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
- include(CheckIncludeFileCXX)
- set(CMAKE_REQUIRED_FLAGS "-std=c++0x")
- check_include_file_cxx(unordered_map HAVE_UNORDERED_MAP)
- set(CMAKE_REQUIRED_FLAGS "")
-
- if(HAVE_UNORDERED_MAP)
- message(STATUS "Enabling c++0x support for unordered map")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
- endif(HAVE_UNORDERED_MAP)
-endif(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
-
-configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/hashconfig.h.cmake
- ${CMAKE_CURRENT_BINARY_DIR}/hashconfig.h )
-
set(benchhashes_SRCS benchhashes.cpp)
kde4_add_unit_test(benchhashes ${benchhashes_SRCS})
diff --git a/language/duchain/tests/benchhashes.cpp b/language/duchain/tests/benchhashes.cpp
index f6e04b3..fae9de9 100644
--- a/language/duchain/tests/benchhashes.cpp
+++ b/language/duchain/tests/benchhashes.cpp
@@ -27,7 +27,7 @@
#include <tests/testcore.h>
#include <tests/autotestshell.h>
-#include "hashconfig.h"
+#include <unordered_map>
// similar to e.g. modificationrevision.cpp
struct DataT {
@@ -38,8 +38,6 @@ struct DataT {
typedef QPair<KDevelop::IndexedString, DataT> DataPair;
typedef QVector<DataPair> InputData;
-#ifdef HAVE_UNORDERED_MAP
-#include <unordered_map>
struct IndexedStringHash
{
@@ -58,9 +56,6 @@ inline void insertData(StlHash& hash, const InputData& data)
}
}
-#define HAVE_STL_HASH
-#endif
-
typedef QHash<KDevelop::IndexedString, DataT> QStringHash;
inline void insertData(QStringHash& hash, const InputData& data)
{
@@ -100,10 +95,8 @@ void BenchHashes::feedData()
data << qMakePair(IndexedString(QString::number(i)), DataT());
}
QCOMPARE(data.size(), size);
-#ifdef HAVE_STL_HASH
QTest::newRow(qPrintable(QString("unordered_map-%1").arg(size)))
<< true << data;
-#endif
QTest::newRow(qPrintable(QString("qhash-%1").arg(size)))
<< false << data;
}
@@ -115,12 +108,10 @@ void BenchHashes::insert()
QFETCH(InputData, data);
if (useStl) {
-#ifdef HAVE_STL_HASH
QBENCHMARK {
StlHash hash;
insertData(hash, data);
}
-#endif
} else {
QBENCHMARK {
QStringHash hash;
@@ -140,7 +131,6 @@ void BenchHashes::find()
QFETCH(InputData, data);
if(useStl) {
-#ifdef HAVE_STL_HASH
StlHash hash;
insertData(hash, data);
QBENCHMARK {
@@ -148,7 +138,6 @@ void BenchHashes::find()
(void) hash.find(pair.first);
}
}
-#endif
} else {
QStringHash hash;
insertData(hash, data);
@@ -171,7 +160,6 @@ void BenchHashes::constFind()
QFETCH(InputData, data);
if(useStl) {
-#ifdef HAVE_STL_HASH
StlHash hash;
insertData(hash, data);
const StlHash& constHash = hash;
@@ -180,7 +168,6 @@ void BenchHashes::constFind()
(void) constHash.find(pair.first);
}
}
-#endif
} else {
QStringHash hash;
insertData(hash, data);
@@ -203,7 +190,6 @@ void BenchHashes::remove()
QFETCH(InputData, data);
if(useStl) {
-#ifdef HAVE_STL_HASH
StlHash hash;
insertData(hash, data);
QBENCHMARK {
@@ -211,7 +197,6 @@ void BenchHashes::remove()
hash.erase(pair.first);
}
}
-#endif
} else {
QStringHash hash;
insertData(hash, data);
@@ -281,7 +266,6 @@ void BenchHashes::typeRepo()
}
}
} else if (type == 5) {
-#ifdef HAVE_UNORDERED_MAP
std::unordered_map<int, TypeRepoTestData*> v;
for(int i = 0; i < 100; ++i) {
v[i] = new TypeRepoTestData;
@@ -291,7 +275,6 @@ void BenchHashes::typeRepo()
v.at(i)->size++;
}
}
-#endif
} else if (type == 6) {
// for the idea, look at c++'s lexer.cpp
const int vectors = 5;
diff --git a/language/duchain/tests/hashconfig.h.cmake b/language/duchain/tests/hashconfig.h.cmake
deleted file mode 100644
index f14792f..0000000
--- a/language/duchain/tests/hashconfig.h.cmake
+++ /dev/null
@@ -1 +0,0 @@
-#cmakedefine HAVE_UNORDERED_MAP 1
More information about the KDevelop-devel
mailing list