[asterisk-scf-commits] asterisk-scf/release/cmake.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Mon Dec 6 09:02:40 CST 2010


branch "master" has been updated
       via  27ad6cf29c108f07b8b83eb24f5d37fb8a6efedc (commit)
      from  b19a7d9c985a79bca1580b57190cb8b7bd11e203 (commit)

Summary of changes:
 AsteriskSCF.cmake   |   27 +++++++++++++++++++++++++++
 tests/SharedPtr.cpp |    7 +++++++
 2 files changed, 34 insertions(+), 0 deletions(-)
 create mode 100644 tests/SharedPtr.cpp


- Log -----------------------------------------------------------------
commit 27ad6cf29c108f07b8b83eb24f5d37fb8a6efedc
Author: Joshua Colp <jcolp at digium.com>
Date:   Mon Nov 29 18:52:50 2010 -0400

    Enable C++0x support on GCC versions where it is supported.

diff --git a/AsteriskSCF.cmake b/AsteriskSCF.cmake
index e347b90..a7615c7 100644
--- a/AsteriskSCF.cmake
+++ b/AsteriskSCF.cmake
@@ -55,6 +55,23 @@ if(NOT integrated_build)
     message(FATAL_ERROR "This project can not be built in a non-integrated fashion. Please use the gitall script present in the gitall repository.")
 endif()
 
+# Use a compile test to see if shared_ptr is supported. If present then C++0x support exists.
+if(CMAKE_COMPILER_IS_GNUCXX)
+    try_compile(SHARED_PTR_PRESENT
+            ${CMAKE_BINARY_DIR}
+            ${CMAKE_SOURCE_DIR}/cmake/tests/SharedPtr.cpp
+            COMPILE_DEFINITIONS "-std=c++0x"
+            OUTPUT_VARIABLE OUTPUT
+    )
+    if(SHARED_PTR_PRESENT)
+        message(STATUS "Support for C++0x Enabled")
+	add_definitions("-DCPP_ZEROX_SUPPORT")
+	set(CPP_ZEROX_STD "-std=c++0x")
+    else()
+        message(STATUS "Support for C++0x Disabled")
+    endif()
+endif()
+
 list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
 
 # If a build type has not been explicitly specified then use debug
@@ -80,6 +97,8 @@ if(CMAKE_COMPILER_IS_GNUC)
         CACHE STRING "Flags used by the compiler during debug builds." FORCE)
 endif()
 if(CMAKE_COMPILER_IS_GNUCXX)
+    set(CMAKE_CXX_FLAGS "${CPP_ZEROX_STD}"
+        CACHE STRING "Flags used by the compiler during release builds." FORCE)
     set(CMAKE_CXX_FLAGS_DEBUG "-Werror -Wall -g3"
         CACHE STRING "Flags used by the compiler during debug builds." FORCE)
 endif()
@@ -198,6 +217,14 @@ function(find_ICE_CXX)
     else()
         message(FATAL_ERROR "Failed to find Ice headers for CXX")
     endif()
+    # This block essentially tricks the GNU compiler into treating the Ice header files as system headers. This has
+    # the benefit of having warnings emitted by the headers NOT treated as errors, even if the compiler has been told
+    # to do so. This is currently being utilized by the C++0x support in this file so that Ice itself does not have to
+    # be updated to be C++0x safe.
+    if(CMAKE_COMPILER_IS_GNUCXX)
+        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${ICE_CXX_INCLUDE_DIR}"
+            CACHE STRING "Flags used by the compiler during release builds." FORCE)
+    endif()
 endfunction()
 
 # Find an Ice library for CXX components
diff --git a/tests/SharedPtr.cpp b/tests/SharedPtr.cpp
new file mode 100644
index 0000000..eb7339f
--- /dev/null
+++ b/tests/SharedPtr.cpp
@@ -0,0 +1,7 @@
+#include <memory>
+
+int main()
+{
+    std::shared_ptr<void> bob;
+    return 0;
+}

-----------------------------------------------------------------------


-- 
asterisk-scf/release/cmake.git



More information about the asterisk-scf-commits mailing list