Setting compiler flags per file in projct template file TemplateInfo.plist - xcode4

I created a project template file - TemplateInfo.plist which is defined with ARC usage.
There are a few external files which I included in the template that are not ARC supported. In a regular project I would set manually the compiler flags for those files in build phases-> compile sources to -fno-objc-arc but how can I do it inside the template?
I didn't find anything related.. any idea?
Thanks

Related

How does AUTOMOC adds files to mocs_compilation.cpp?

I'm porting a Qt project to CMake and after adding set(CMAKE_AUTOUIC ON) I've started experiencing a bunch of compilation problems, which are triggered when trying to compile mocs_compilation.cpp, such as error C2504: 'Lucene::Reader': base class undefined.
After looking into mocs_compilation.cpp, I've found that the file is nothing more than a long list of #include statements bundling source files into a huge translation unit.
CMake's documention mentions the following about mocs_compilation.cpp;
(...)
Not included moc_.cpp files will be generated in custom folders to avoid name collisions and included in a separate <AUTOGEN_BUILD_DIR>/mocs_compilation.cpp file which is compiled into the target.
(...)
With this in mind, how does AUTOMOC determine which files go into mocs_compilation.cpp? And is there any way to keep source files out of mocs_compilation.cpp and build them separately?

Qt Creator: how to embed custom manifest in .exe

I have a custom Manifest file and would like to embed it inside the executable. I use MS Visual Studio 2010 compiler and Qt 5.2.1.
I use Qt Creator as the IDE and CMake for making release builds.
What options should I set in .pro and CMake files?
I tried to pass '/MANIFEST...' like flags to the linker, but they seem to be unsupported by VS 2010 linker.
Eventually I've found the solution.
First it is necessary to add the following line to the .pro file:
CONFIG -= embed_manifest_exe
this will disable embedding of the default manifest file. After that it is necessary to add a windows resource file:
RC_FILE = app_resources.rc
.rc file is usually included to embed version information into .exe, but as soon as manifest is also a part of the executable resources we could reference a custom manifest file in it, just add the following line into app_resources.rc:
1 24 myapp.exe.manifest
where 1 is the resource ID, 24 is the resource type - RT_MANIFEST, and myapp.exe.manifest is the file with our custom manifest.
If you don't need version info then app_resources.rc may contain just this single line.
That's it.
For CMake the steps are as follows:
1) include app_resources.rc in the list of sources of the target
2) add the following line to disable embedding of a default manifest file:
set(CMAKE_EXE_LINKER_FLAGS "/MANIFEST:NO")
For some unknown for me reasons /MANIFEST:NO didn't work in .pro file. The linker failed with an unknown option error. However it works in CMake. The linker is the same from VS 2010...
Using below qmake script based manifest injection you do not need to include the manifest in any *.rc file (works for MakeFile based compile where qmake does generate the MakeFile)
QMAKE_MANIFEST = $$PWD/x86_user.manifest.xml
Note:
this works even if we have set the RC_FILE = Res.rc (i.e. since this takes action and injects the manifest to .exe after the compile is done)
you need to recompile to see effect...
I can't help you with the qmake side, but for CMake, you should be able to just list the manifest file as one of the sources of the target. This requires CMake 3.4 or later (see release notes).

Add QML files to Qt Creator project tree with CMake

I have a library called qml_components containing basic QML graphical elements. I'd like to add these files to the project tree, without building them. I've been able to regroup them in a variable, by doing the following:
CMAKE_MINIMUM_REQUIRED(VERSION 3.4)
CMAKE_POLICY(SET CMP0003 NEW)
PROJECT(myApp)
FILE(GLOB QML_SRC "*.qml")
I then tried to add them to my library target:
# Add QML files to project tree without building/compiling them
ADD_CUSTOM_TARGET(myApp ${QML_SRC})
While researching I read that ADD_CUSTOM_TARGET could add the files to the sources without building them:
The SOURCES option specifies additional source files to be included in the custom target. Specified source files will be added to IDE project files for convenience in editing even if they have not build rules.
It doesn't seem to work. I think the probable cause is that I do not generate any binaries from this library, hence the failure when trying to link the sources to the TARGET.
I had forgotten to add the SOURCES keyword in the command...
ADD_CUSTOM_TARGET(myApp SOURCES ${QML_SRC})
I'm leaving this thread open as it could be of useful information to others.

Undefined references - I'm including correct header

I'm trying to subclass from ProjectExplorer::ProjectExplorerPlugin but I'm getting error telling me about undefined references. Any ideas how to fix it?
class MyPluginPlugin : public ProjectExplorer::ProjectExplorerPlugin
{
Q_OBJECT
...
};
error: undefined reference to `imp__ZN15ProjectExplorer21ProjectExplorerPluginC2Ev'
The fact that you don't get a compilation error, but an undefined reference usually means that your project knows where the header files are, but it doesn't know where the library is which contains the already compiled source code.
I've never written a plugin for Qt Creator but I've taken a quick look at its source code structure and I see the following options:
Option A)
There is a projectexplorer.pro file in Qt Creator's source under src/plugins/projectexplorer. You could manually build that project in order to get a ProjectExplorer.lib (plus a .dll or a .a) and then reference this library.Example: Assuming the library would be created in the same directory as its .pro file (I have no idea if it is like that) and you created your plugin withing Qt Creator's source under src/plugins/myplugin, you would define your LIBS variable like this:
LIBS += -L../projectexplorer \
-lProjectExplorer
The first line adds "../projectexplorer" as an additional library directory and the second line adds "ProjectExplorer" as a library to search in any of the defined directories (it automatically adds the OS-specific file extensions like .lib on windows etc).
Obviously if your project or the library is located somewhere else, you need to change the first line accordingly.
Option B)
You could include the source and header files of the projectexplorer directory to your own .pro file using the HEADERS and SOURCES variables. I'm not sure if this wouldn't interfere with any other plugins (including projectexplorer itself) though.
Option C)
There probably is a way to include the projectexplorer.pro file so that you have a master project which first builds the project explorer library and then your own plugin. This would be the safest way to go as it ensures the Project Explorer library is built and up-to-date before your own project is linked against it.
However I have limited experience on this.
If anyone reading this can give a detailed explanation on this option, feel free to edit or provide your own answer.
If you are using Qt Creator built from source coded after April 2013 which includes Commit: #66a3553 - make library and plugin dependencies declarative, then you can simply specify dependencies for your plugin in its .pro file:
# myplugin.pro
QTC_PLUGIN_DEPENDS += \
coreplugin \
projectexplorer

mxmlc embedding assets

I'm trying complie my project via mxmlc this way:
[prj_folder]\src>mxmlc mymxml.mxml -library-path+=../libs -sp+=..\assets
and i get such errors:
[prj_folder]\src\view\controls\controlname.mxml(7): Error: Problem finding external st
ylesheet: assets/cssname.css
<fx:Style source="assets/cssname.css"/>
[prj_folder]\src\view\constants\Images.as(24):
col: 3: Error: Unable to transcode
assets/ icons/icon1.png.
how to include assets for the compiler?
Flash Builder preprocesses the files.
For a directory structure like this:
projectdir/src/Main.mxml
projectdir/src/views/SomeView.mxml
projectdir/src/assets/MyImage.png
And if SomeView.mxml references assets/MyImage.png, Flash Builder will allow this:
#Embed('assets/MyImage.png')
because it is preprocessed to /assets/MyImage.png by the IDE, but ant/maven + mxmlc won't do that.
#Embed('/assets/MyImage.png')
works for both Flash Builder and mxmlc.
If you are using a relative path like this:
#Embed('../assets/MyImage.png')
try changing it to this, odd as it may seem:
#Embed('/../assets/MyImage.png')
The leading / gets translated to "my src directory", and mxmlc does the remainder of the path calculation from there.
Hope this helps.
This is a directory setup issue; not a compiler error. And you aren't actually embedding assets; just referencing them.
When using Flash Builder, the file "assets/cssname.css" should be relative to the main application file. I believe the same should occur if you're using the command line compiler.
Does your source directory have an assets subdirectory? Is the cssname.css file inside it?

Resources