Add "-fobjc-arc" flag on specific files from command line - xcode

I'm working on a non-arc workspace,for specific files I added "-fobjc-arc" flag BuildPhases>CompileSources>. When I try to automate the build I'm unable to add the compiler flags. I have multiple targets, so i should pick the required target and add compiler flags for files in the target. Can it be handled while generating the project with CMAKE?
Any help here would be appreciated.

Related

Does CMake have an option to control the executables that get generated

I'm new to CMake. So this question might be a rookie misunderstanding. A general use of CMake generates the project files ZERO_CHECK, ALL_BUILD and the main project sln. I need to compile source and header files from 3 folders to generate a static library (*.lib). What's the best way to do so without generating other build files?

How to build a C++ make project using specific LDFLAGS (Mac OSX)

I have a project that needs to be built using cmake and make. However, I want the project to use libc++ (since its written in C++11) so I need to set the right linker flags. Is there a way I can pass the following flags via command line?
LDFLAGS="-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib"
Or do I need to edit my CMakeLists.txt file? If so how can I add this to the file?
For the more complex linker flags use
set (CMAKE_SHARED_LINKER_FLAGS -Wl,-rpath,/usr/local/opt/llvm/lib)
To add a library search directory (-L) simply add
link_directories(/usr/local/opt/llvm/lib)
See also this and that answer

Adding an Objective-C++ file to a C++ Xcode 5 project

I am attempting to add an ObjC++ file to a large Xcode 5 C++ project.
For legacy reasons, the "Compile Sources As" setting must remain "C++". If I could change this setting to "According to File Type" the ObjC++ file would build properly, but it won't compile if Xcode thinks its a C++ file.
I have tried explicitly setting the Type of the .mm file under Identity and Type to "Objective-C++ Source" and the compiler still attempts to build it as a C++ file. I have tried adding the "-ObjC" and "-ObjC++" compiler flags to to the individual file under Build Phases > Compile Sources, and I get a warning that the argument is unused during compilation.
I have tried this process in reverse, adding an ObjC++ file to a different project that is compiling sources as "According to File Type," and setting the Type to C++. As expected, the file fails to build. This shows that specifying the type of an individual file takes precedence over the project setting.
Is there no way to force Xcode5.1.1/llvm5.1 to build a single ObjC++ or ObjC file as the correct type? The project setting is overridden by the individual file setting in every case I've tested, except trying to build an ObjC++ file. Is this a bug or missing feature?
You were close with the ObjC++ flag.
Set the file's Compiler Flags in the Compile Sources Build Phase to -x objective-c++ $(inherited).

CPPFLAGS equivalent in Xcode project

So I'm trying to port a make file to Xcode. Not sure where to put stuff from CPPFLAGS.
Currently CPPFLAGS = -I../src/ meaning that the preprocessor will append ../src/ to the include directives while trying to resolve paths. I can not modify the source files.
You don't need any explicit -I switches if you put all your source files and headers into the Xcode project. Xcode will generate all the necessary include directives at build time as it knows where all the headers are.

Xcode 4 + llvm, How to ignore compiler warnings in specific directory?

I'm putting all my third party code in a /Vendor directory in my Xcode project. How can I suppress all compiler warnings in that directory?
I'm using Xcode 4 and LLVM 2.1.
You cannot set warning flags in Xcode by directory; directories have no meaning to Xcode, they don't form any form of "compile entity". You can set warning flags per Target, per Build Configuration, or on single files. This leaves you with two options:
Build all 3rd party code as an own target, e.g. make it a static library target, then build your code in another target and make it link against the static library of the first target. Each target can then have different warning flags.
Select all the 3rd party files in the list of files to build and override some of the warning flags (if a warning is turned on with -Wfoobar, then you can disable it with -Wno-foobar). Setting compile flags on single files is shown in the screenshot below; this can be done with multiple files at once.

Resources