commit 09689c4f3a2421f50d8f12d5b0e9f76938f8e6c0 Author: Andreas Pakulat Date: Tue May 29 12:30:02 2012 +0200 Fix building Didn't get the compilation through far enough before comitting. HAVE_KOMPARE was used in a totally bogus manner and the change to use #cmakedefine broke that. Avoid the double-conversion from bool to 0/1 back to bool, by simply using explicit ifdef checks for HAVE_KOMPARE now thats its either defined or undefined. (cherry picked from commit dcb300796f1b824b6c65a1750cbf816f6f7f6dfb) commit a6191e8cd7d4ebbb421566c2ae426f5a7900f1e3 Author: Andreas Pakulat Date: Tue May 29 11:50:13 2012 +0200 Fix finding unordered_map header check_include_file_cxx fails here with CMake 2.8.8, since unordered_map has a warning generated when used without the -std=c++0x flag. Hence unordered_map support is disabled even though the header exists. Since part of the code thats run when unordered_map is found is setting this flag, set it also for the include-file check. This fixes detecting unordered_map on my Debian with gcc4.6 and CMake 2.8.8 (cherry picked from commit d756d28f4b000d2b7af12822c935dd13754876b4) commit 7078e3b26b75f1daaa36294285177dad411c31d1 Author: Andreas Pakulat Date: Tue May 29 11:48:36 2012 +0200 Fix generation of the config-file With the #define x @x@ the generated config file would still always have a #define x in it, even if @x@ is 0. This results in both ext-hashmap and unordered-map to be enabled even if only the latter was found and hence results in compile-errors. Instead if one wants to base a define in a configure_file-generated header on the value of a cmake variable #cmakedefine should be used. This fixes building of kdevplatform on systems where unordered_map produces a warning without the -std=c++0x compiler flag which in turn makes check_include_file_cxx fail to find the header. (cherry picked from commit 34dc37ec3b37c4895f5164235812a1a367b779c7) commit 2223fdb28a2af4aa3a6cae74f834c9421a0482e3 Author: Andreas Pakulat Date: Tue May 29 11:44:46 2012 +0200 Provide status info when using ext/hash_map. (cherry picked from commit daa89efb9c76093a9b62623c04e7b486c94db1eb) commit 4eed75814ae984ff80ec0e9fb990422c01f7c091 Author: Raphael Kubo da Costa Date: Mon May 28 15:30:43 2012 -0300 Look for ext/hash_map and unordered_map instead of checking gcc's version. Follow-up to commits 3455de70d45a260607e1a4aa992a507ab979cd48 and 321e7c40bfbe838eb0a8354ff388cd88689166f9. The decision of whether to include or for gcc/clang was based on whether gcc > 4.3 was installed or whether clang was being used. The latter implicitly assumed a recent enough libstdc++ version (ie. >= 4.3) was being used, which might not be the case on systems such as FreeBSD and possibly OS X. Instead of checking for compiler versions, we now look for these headers: CMake first detects whether is present and, in case it is not, it looks for . The checks in language/editor/modificationrevision.cpp have been updated as well. This should cover all the cases being previously detected, as well as fix the checks for FreeBSD and other systems where the build was failing before with clang. Reviewed-by: Millian Wolff REVIEW: 105066 diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c29e9f..f82ffb8 100644 --- ./CMakeLists.txt +++ ./CMakeLists.txt @@ -37,27 +37,30 @@ macro_bool_to_01(KOMPARE_FOUND HAVE_KOMPARE) #macro_log_feature(KOMPARE_FOUND "Kompare" "KPart to view file differences." # "http://www.caffeinated.me.uk/kompare/" FALSE "" # "Required for difference checking. From KDE SDK package, KDE 4.3.61 or higher needed.") -configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/config-kdevplatform.h.cmake - ${CMAKE_CURRENT_BINARY_DIR}/config-kdevplatform.h ) 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) - # TODO: Remove when LTS for g++ < 4.3 has ended. - # See also: languages/cpp/parser/parser.h - macro_ensure_version("4.3.0" "${_gcc_version}" GCC_IS_NEWER_THAN_4_3) - if (GCC_IS_NEWER_THAN_4_3) - message(STATUS "Enabling c++0x support for unordered map") - add_definitions( -std=c++0x ) # For unordered_map - else(GCC_IS_NEWER_THAN_4_3) - add_definitions( -DGXX_LT_4_3 ) - endif (GCC_IS_NEWER_THAN_4_3) -endif(CMAKE_COMPILER_IS_GNUCXX) -if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - # TODO: version check? - add_definitions( -std=c++0x ) -endif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + +# 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") + add_definitions( -std=c++0x ) + else(HAVE_UNORDERED_MAP) + message(STATUS "Using ext/hash_map") + check_include_file_cxx(ext/hash_map HAVE_EXT_HASH_MAP) + endif(HAVE_UNORDERED_MAP) +endif(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + +configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/config-kdevplatform.h.cmake + ${CMAKE_CURRENT_BINARY_DIR}/config-kdevplatform.h ) include_directories(${KDevPlatform_SOURCE_DIR} ${KDevPlatform_BINARY_DIR} ${KDE4_INCLUDES}) diff --git a/config-kdevplatform.h.cmake b/config-kdevplatform.h.cmake index 6737e06..e24bd4f 100644 --- ./config-kdevplatform.h.cmake +++ ./config-kdevplatform.h.cmake @@ -1,2 +1,8 @@ /* Define to 1 if you have Kompare support, 0 otherwise */ -#define HAVE_KOMPARE @HAVE_KOMPARE@ +#cmakedefine HAVE_KOMPARE + +/* Define to 1 if the unordered_map header is present, 0 otherwise */ +#cmakedefine HAVE_UNORDERED_MAP + +/* Define to 1 if the ext/hash_map header is present, 0 otherwise */ +#cmakedefine HAVE_EXT_HASH_MAP diff --git a/language/codegen/komparesupport.cpp b/language/codegen/komparesupport.cpp index 017ef01..428d1e6 100644 --- ./language/codegen/komparesupport.cpp +++ ./language/codegen/komparesupport.cpp @@ -20,7 +20,7 @@ #include "komparesupport.h" #include -#if HAVE_KOMPARE +#ifdef HAVE_KOMPARE #include #include diff --git a/language/codegen/komparesupport.h b/language/codegen/komparesupport.h index 11e9f23..5ea6824 100644 --- ./language/codegen/komparesupport.h +++ ./language/codegen/komparesupport.h @@ -33,7 +33,11 @@ class IndexedString; class KompareWidgets { public: - static const bool enabled = HAVE_KOMPARE; +#ifdef HAVE_KOMPARE + static const bool enabled = true; +#else + static const bool enabled = false; +#endif KompareWidgets(); ~KompareWidgets(); diff --git a/language/editor/modificationrevision.cpp b/language/editor/modificationrevision.cpp index ac8a852..ee0d510 100644 --- ./language/editor/modificationrevision.cpp +++ ./language/editor/modificationrevision.cpp @@ -16,6 +16,7 @@ Boston, MA 02110-1301, USA. */ +#include "config-kdevplatform.h" #include "modificationrevision.h" #include @@ -23,13 +24,7 @@ #include -#if defined(Q_CC_MSVC) -#include -using namespace stdext; -#elif defined GXX_LT_4_3 -#include -using namespace __gnu_cxx; -#else // C++0X +#if defined(HAVE_UNORDERED_MAP) // C++0X // TODO: Replace hash_map with unordered map when support for G++ < 4.3 has // ended. This class was added as a temporary workaround, to get rid of // hash_map related warnings for g++ >= 4.3. @@ -39,6 +34,12 @@ template, class _Alloc = std::allocator > > class hash_map : public std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc> { }; +#elif defined(HAVE_EXT_HASH_MAP) +#include +using namespace __gnu_cxx; +#elif defined(Q_CC_MSVC) +#include +using namespace stdext; #endif diff --git a/plugins/patchreview/patchreview.cpp b/plugins/patchreview/patchreview.cpp index 5d8d0e2..c2355bd 100644 --- ./plugins/patchreview/patchreview.cpp +++ ./plugins/patchreview/patchreview.cpp @@ -1219,7 +1219,7 @@ void PatchReviewPlugin::clearPatch( QObject* _patch ) { } #if 0 -#if HAVE_KOMPARE +#ifdef HAVE_KOMPARE void showDiff( const KDevelop::VcsDiff& d ) { ICore::self()->uiController()->switchToArea( "review", KDevelop::IUiController::ThisWindow ); foreach( const VcsLocation& l, d.leftTexts().keys() ) diff --git a/shell/documentcontroller.cpp b/shell/documentcontroller.cpp index 1fb3c7f..1d8b3f7 100644 --- ./shell/documentcontroller.cpp +++ ./shell/documentcontroller.cpp @@ -60,7 +60,7 @@ Boston, MA 02110-1301, USA. #include -#if HAVE_KOMPARE +#ifdef HAVE_KOMPARE #include "patchdocument.h" #endif @@ -565,7 +565,7 @@ DocumentController::DocumentController( QObject *parent ) if(!(Core::self()->setupFlags() & Core::NoUi)) setupActions(); -#if HAVE_KOMPARE +#ifdef HAVE_KOMPARE registerDocumentForMimetype("text/x-patch", new PatchDocumentFactory); #endif } diff --git a/vcs/vcspluginhelper.cpp b/vcs/vcspluginhelper.cpp index 0c6699f..f5c9667 100644 --- ./vcs/vcspluginhelper.cpp +++ ./vcs/vcspluginhelper.cpp @@ -59,7 +59,7 @@ #include #include -#if HAVE_KOMPARE +#ifdef HAVE_KOMPARE #include #endif #include