From f2132c47bd26484e8a9961ad6056bbbb17a2d108 Mon Sep 17 00:00:00 2001 From: Xiyue Deng Date: Mon, 7 Oct 2013 00:40:32 -0700 Subject: C++11 support. * Add options and ENV method to specify building in C++11 mode. - Set C++ compiler flags to enable C++11 mode. - To add options to support C++11 mode, a formula can now use option :cxx11 to provide "--c++11" option, and detect and enable C++11 support in install method using ENV.cxx11 if build.cxx11? Closes Homebrew/homebrew#22453. --- Library/ENV/4.3/cc | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'Library/ENV') diff --git a/Library/ENV/4.3/cc b/Library/ENV/4.3/cc index d4df6d90f..102f6c64e 100755 --- a/Library/ENV/4.3/cc +++ b/Library/ENV/4.3/cc @@ -45,11 +45,19 @@ class Cmd if @arg0 == 'cpp' or @arg0 == 'ld' @arg0.to_sym elsif @args.include? '-c' - :cc + if @arg0 =~ /(?:c|g|clang)\+\+/ + :cxx + else + :cc + end elsif @args.include? '-E' :ccE else - :ccld + if @arg0 =~ /(?:c|g|clang)\+\+/ + :cxxld + else + :ccld + end end end def tool @@ -83,9 +91,9 @@ class Cmd args << "-syslibroot" << $sdkroot end if nclt? allflags = case mode - when :ccld + when :ccld, :cxxld cflags + args + cppflags + ldflags - when :cc + when :cc, :cxx cflags + args + cppflags when :ccE args + cppflags @@ -149,9 +157,15 @@ class Cmd args end def cflags - return [] unless cccfg? 'O' + args = [] + if mode == :cxx + args << '-std=c++11' if cccfg? 'x' + args << '-stdlib=libc++' if cccfg? 'g' + end + + return args unless cccfg? 'O' - args = %w{-pipe -w -Os} + args << '-pipe' << '-w' << '-Os' # When bottling use the oldest supported CPU type. if cccfg? 'bc' @@ -199,6 +213,9 @@ class Cmd case mode when :ld then args << '-headerpad_max_install_names' when :ccld then args << '-Wl,-headerpad_max_install_names' + when :cxxld + args << '-Wl,-headerpad_max_install_names' + args << '-stdlib=libc++' if cccfg? 'g' end args end -- cgit v1.2.3