Add file from build dir to qrc file - qt5

I'm preparing translations for my application exactly like guy here. The problem I've is that .qm file is generated in build dir (which is fine) but resource compiler cannot find there whle compiling qrc file.
What I want to achieve is to have qrc file with entries refering to qm files from build dir.

I can give you a procedure that works but maybe it is not what you are after.
We have a subdirectory of our resource branch called 'translations'. This subdir contains all our ts files for the languages we support. These ts files are under svn control. Our pro file contains the directives (only one language shown)
TRANSLATIONS+= $$PWD/resources/translations/safepackager_nl.ts
!exists( $$PWD/resources/translations/safepackager_nl.ts ): warning( "not existing safepackager_nl.ts" )
!exists( $$PWD/resources/translations/safepackager_nl.qm ): warning( "run lrelease: not existing safepackager_nl.qm" )
Every time strings in our source change we use Qt Linguist to translate the newly added or edited strings. Next we run lupdate from within Qt Creator and then run lrelease from within Qt Creator. lupdate generates/updates the ts files and lrelease generates/updates the qm files. The qm files - located at the same location as the ts files - are not under svn control. The builder finds the qm files during build.
The lesson being - I guess - is that when ts files and qm files are in the same directory building will succeed without the need of setting additional paths.

Related

Xcode Build path and copying additional files

I'm writing a plugin for Elgato Stream Deck. https://developer.elgato.com/documentation/stream-deck/sdk/overview/
Basically it is a binary command line tool written in C++/OBJ-C/Swift combined with a JSON manifest and optionally some HTML and JS files as well as different assets (.png, ...). All files have to be included in a folder (com.companyname.pluginname.sdPlugin) which lives in Library/Application Support/com.elgato.StreamDeck/Plugins/
At the moment, I'm building the binary to the default build path (derived data, ...) and manually copy it to the above folder. But I need to build and run that binary with an executable (Stream Deck app) defined in the scheme for debugging under Xcode. The JSON manifest and assets also lives in my xcode project folder and have to be copied manually.
So Before:
After:
So my question: how can I automate that under Xcode? I assume I can do some sort of post build scripting, but I have no knowledge about all that stuff.
Thanks
Solution:
go to target -> build settings
Deployment Location = YES
Installation Build Products Location = / (empty this one!)
Installation Directory = path to folder (= $INSTALL_PATH)
this will copy your binary to the defined installation path
go to target -> build phases
new phase -> run script
cp -r "$SRCROOT"/<FILE OR FOLDER NAME> "$INSTALL_PATH"/<FILE OR FOLDER NAME>
repeat this for all files and folders you need to be copied to the installation path. be careful with empty spaces in the folder/file names, they won't be recognized correctly and you have to use quotation marks

Hide non source files from the Qt Creator (4.8) file system view

Qt Creator (4.2.1) used to do this by default. It would show the files organised in the same directory structure as they are in my file system, but it would only show files that are source or header files for the current project. It could work this out with the CMake add_executable, add_library, or add_custom_target function call.
The new version of Qt Creator now shows all the files in my file system, regardless of whether they are source or header files or not. I can change it from "File System" view to "Projects" view, but this structure the files in a different way to my directory structure, i.e it organises them into "Headers", "Targets", and "CMake Modules".
How can I get Qt Creator to behave more like the old version, and only show the files relevant to my project, but in the directory structure that they are actually in?
Thanks.

Can CLion project files be stored in a specified folder by default?

I've been using CLion for a little while now, and I quite like it, except that it stores it's prject files by default in my CMake project. I am wondering if I can set a default place it stores it's project files(like compiled executables) in specific directory, per project.(So not one big folder that might interfere with other projects). The reason I want to do that is because I don't like having it in my git project(yes, I know about .gitignore) Anyone know how to do that?
Thanks!
To use a different folder for CLion building
In the CLion menu:
Build,Execution,Deployment -> Cmake -> Generation Path
Change the value to the folder path you want.
To include source code from a different folder out of current
In your CMakeLists.txt, add subdirectory like following:
add_subdirectory(<PATH_OF_YOUR_ANOTHER_CMAKE_PROJECT>)
Be aware PATH_OF_YOUR_ANOTHER_CMAKE_PROJECT can be anywhere on your computer, which does not have to be in your current project folder or one of the sub-folders.

Something strange with Project Paths in IntelliJ 14.1.4

So, something has started to act weird in my intelliJ project. I even tried removing the iml and .idea data, to no avail.
I go to Project Structure. There, I have a content root. Withing, I have three folders - one for my jar (and jni lib), one for Samples and one for Tools (just tools written to use the jar). The jar, Samples and Tools are marked blue (sources).
In the jar folder, I have my source tree (com\company\projectname\XXX), a lib folder, a folder for my JNI lib and a folder I created call 'junit', which is the focus of this question. It is marked in Project Structure in green (Tests).
Within, I have a folder structure eerily similar to my code: com\company\projectname\junit.
When I open a file in junit\com\company\xxx\junit, I have a big red underline under my package com.company.xxx.junit; line which tells me: "Package name 'com.company.xxx.junit' does not correspond to the file path 'junit.com.company.xxx.junit'.
I was under the impression that marking a folder as 'Tests' would instruct the IDE to use that as a "parent" folder, if you will, eliminating the need to prepend another folder name.
How can I separate the code from unit tests and in fact, create two junit test suites (one is for internal use, the other is a 'skeleton' for distribution), park them under one "umbrella" folder and NOT have to prepend the package names with that folder name?
Update: Project structure:
Based on your screen shot, the issue is that the junit directory is a subdirectory of another source directory, namely MyProvider. A source directory (whether a "production" source or a unit test source directory) cannot be a subdirectory of another source directory.
You need to either:
move the junit directory out of MyProvider so it is a sibling directory, or
unmark MyProvider as a source directory, create a main (or some such directory) in MyProvider, mark it as a source directory, and then move the com directory/package into main.
Option 2 would be the preferred way to deal with this as it follows a very common directory structure standard.
UPDATE (Following comment from OP)
Here's a couple of screenshot showing the configuration you desire:
I removed the .IdeaIC15 folder and started over. Working for now. Something must have gotten confused in the config, either as part of the update, or in the course of operation. I have taken a backup copy as it is now, so if this happens again, I will have something to check.

Determining whether a file is linked to a project or not

I'm writing a project documenter and I write out the full file path of each compiled file. This is for the VB.NET language so .proj files are written in xml.
Any file that is linked to the project exists on the same drive so at least one of the directory levels are the same for all files. I currently have it set up to put the project directory path on files which exist inside the project since it only shows the name of the file and the residing directory it lives in if its in a directory inside the project. For files outside (linked in) to the project I initially saw their files paths were "..\..\..\dir\filename". So I set it up to take off all the "..\" and put the necessary directories in front of it and all that worked fine. Now for this one .proj file some of the linked in files have their full file path with no "..\".
How can I properly distinguish these three possible inputs?
System.IO.Path.IsRooted will tell you whether a path is rooted, i.e. is a full path, or not. If the path is not rooted it is a relative path. You can use Path.Combine to resolve the full path from a relative path.