Support C++11 Objective-C++ in objc_.* targets
I want to compile a target that contains some Objective-C files and some Objective-C++ files (conventionally ending in .mm). For the latter, I want to specify -std=c++11. If I add that to objccopts, my Objective-C++ files compile, but clang dies on my Objective-C files with:
error: invalid argument '-std=c++11' not allowed with 'C/ObjC'
Damien, could you help direct this to the right person?
Peter: do you have some comment on that?
We don't have the ability to add C++ opts yet. We are aware of the problem.
Sigh... file a bug please?
Cheers, Dave
On Mon, Aug 10, 2015 at 7:18 AM, Damien Martin-Guillerez < [email protected]> wrote:
Peter: do you have some comment on that?
— Reply to this email directly or view it on GitHub https://github.com/google/bazel/issues/366#issuecomment-129470219.
Until this is fixed, my planned workaround is to have my objc++ in a separate objc_library called mylib_objcc that specifies -std=c++11. This also means I need to take that out of my global copts and rely on the c++ toolchain providing it instead, which is... reasonable, I suppose.
Any update on this issue?
Alternatively, allowing .m / .mm files in cc_library could work. Right now, it is possible to build an ObjC/ObjC++ library providing the files end with .c or .cpp and the -ObjC or -ObjC++ flags are passed when compiling. This way, cross platform programs don't have to specify a special set of rules to use the objc_library from a cc_library or cc_binary dependency.
It seems like this is now fixed in objc_library, when passing copts = ["-ObjC++","-std=c++11"]
Consider separating out objc_library targets into srcs of different types, if their copts need to differ? These can be later recombined as a single objc_library which depends on both...
Per-language per-target copts strikes me as scaling poorly.