[lldb-dev] CMake build script not work with gcc 4.6

comicfans44 comicfans44 at gmail.com
Wed Mar 20 23:00:07 PDT 2013


I have tried this patch with lldb git version d3a8d6565ff40fd99533f50a085ace806a9300ee,
compiled by both version 4.6.3 and 4.7.2 ,this flag works as expected.

comicfans44,comicfans44 at gmail.com
2013-3-21 
----- Original Message ----- 
From: Kopec, Matt 
To: comicfans44 
Date: 2013-03-20, 07:05:54
Subject: RE: [lldb-dev] CMake build script not work with gcc 4.6


CMake isn't my area but I found starting with CMake 2.8.8 there is support for compiler version. This would mean you have to use CMake 2.8.8 or greater. I believe -std=c++11 is preferred for gcc 4.7+.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index d5a28ea..7187af7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -82,7 +82,14 @@ endmacro(add_lldb_definitions)
 include_directories(/usr/include/python2.7)
 include_directories(../clang/include)
 include_directories("${CMAKE_CURRENT_BINARY_DIR}/../clang/include")
-set(CMAKE_CXX_FLAGS "-std=c++11")
+
+if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+    if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.7")
+      set(CMAKE_CXX_FLAGS "-std=c++0x")
+    else()
+      set(CMAKE_CXX_FLAGS "-std=c++11")
+    endif()
+endif()
 
 # Disable MSVC warnings
 if( MSVC )

Let me know if this works.

Matt 



From: lldb-dev-bounces at cs.uiuc.edu [lldb-dev-bounces at cs.uiuc.edu] on behalf of comicfans44 [comicfans44 at gmail.com]
Sent: Sunday, March 17, 2013 8:51 PM
To: lldb-dev
Subject: [lldb-dev] CMake build script not work with gcc 4.6


LLDB offical build help page said that gcc>=4.6.2 is supported ,and should set CXXFLAGS=-std=c++0x
bug CMake build script set CXX_FLAGS to -std=c++11 ,which gcc 4.6 does not understand.I suggest a 
patch ,just simply set -std=c++0x when compiler is gcc, which makes gcc 4.6 works all right. I did not 
add gcc version check because it requires gcc -version output parse,which is not very stable across
different build-config

diff --git a/CMakeLists.txt b/CMakeLists.txt
index d5a28ea..2837a8d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -82,7 +82,14 @@ endmacro(add_lldb_definitions)
 include_directories(/usr/include/python2.7)
 include_directories(../clang/include)
 include_directories("${CMAKE_CURRENT_BINARY_DIR}/../clang/include")
-set(CMAKE_CXX_FLAGS "-std=c++11")
+
+
+
+if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
+    set(CMAKE_CXX_FLAGS "-std=c++0x")
+else()
+    set(CMAKE_CXX_FLAGS "-std=c++11")
+endif()
 
 # Disable MSVC warnings
 if( MSVC )


本邮件附件清单如下:
  (1) gcc4.6-cmake.patch (0.5 K)


comicfans44,comicfans44 at gmail.com
2013-3-18 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20130321/7905599a/attachment.html>


More information about the lldb-dev mailing list