diff options
| author | Xiyue Deng | 2013-10-07 00:40:32 -0700 |
|---|---|---|
| committer | Xiyue Deng | 2013-10-26 22:17:04 -0700 |
| commit | f2132c47bd26484e8a9961ad6056bbbb17a2d108 (patch) | |
| tree | 5d0e8d5b9dbe0629a20a31347222dc3cb50cd9d9 /Library/ENV | |
| parent | 0e6df1c3bf1c5f5d23bcfa5c668d26cf48dffd20 (diff) | |
| download | brew-f2132c47bd26484e8a9961ad6056bbbb17a2d108.tar.bz2 | |
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.
Diffstat (limited to 'Library/ENV')
| -rwxr-xr-x | Library/ENV/4.3/cc | 29 |
1 files changed, 23 insertions, 6 deletions
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 |
