What are QtCreator build step variable names (such as %{buildDir})? - qt-creator

I am specifying a build step which shall run in the project directory. So if this is supposed to work in general, I need a symbol representing project directory, similar to %{buildDir}, which represents the build directory.
Qt manual only mentions nonexistent
Variables button. No such button appears on their screenshots or in the GUI I see.
I would appreciate full list of variables defined by QtCreator - like project path, target executable path, project .pro filename and so on.

Answer can be found here, on Stack Overflow.
It is true that the button you mention is not visible in build settings. Documentation is inconsistent about this. Fortunately as you can see in the answer linked above - the Variables button is available in options.
It is sad that a bug mentioning this is not being fixed as there are many other posts like yours. Beside bug report I see no other way to make missing Variables button appear on the build settings page in Qt Creator.

Related

Xcode: Require workspace instead or project?

I can't count how many times I've opened a Xcode project instead of a workspace and spent a half hour trying to figure out what I've done wrong because none of the dependancies can be found.
Is there a way to detect this and generate a helpful error message in my compiler prefix?
I could try importing one of the headers that isn't always available, but I'd prefer something more direct and obvious if possible. (Mostly because if I rely on a particular header, that only really checks one package. It also imports the header so I don't need to #import it from my other code.)
You might use a pre-action Build phase script in your scheme to check the build path and take some action if it's wrong. In your workspace, you can specify a custom build path for workspace-wide stuff. If the path doesn't match, you know your target is being built from project only. (It's unfortunate that Apple doesn't provide an environment variable for the workspace and that even workspace-level schemes give the target's project as the project path.) But this is fiddly and seems gross. You ought to feel dirty even considering it, and guilty at having caused me to write it. What would your mother think?
Another (better, IMO) approach is to Manage Schemes when opened as Workspace and change the Container for all schemes to your workspace vs. project-level. This ensures there are no schemes available to build if the project itself is opened. You'll see "No Scheme" and any attempt to build, run, whatever, will give you an error beep.

Is there a way to work on multiple projects in CLion?

I'm looking for a way to work on multiple projects in parallel in CLion IDE.
For now I can only work on each project in a window at a time, but I'm looking for a solution similar to Eclipse IDE (see below) - being able to see my different projects' directories on a side bar and choosing the one I want, compiling it by itself, etc.
Is there a way to do it?
Yes: CLion doesn't allow you to open multiple projects from the menu because it uses the CMake system, which is script based.
However, CMake is quite capable of encompassing multiple projects, and CLion will correctly parse your CMake file and show all relevant directories in the project explorer.
Example
To do this, just like in Visual Studio, you need a parent "solution" and one or more child "projects".
Here is a simple CMake example in which "my_solution" references two child projects, "my_application" and "my_library". Here, my three folders are arranged:
xxx/my_solution/CMakeLists.txt
xxx/my_application/CMakeLists.txt
xxx/my_library/CMakeLists.txt
And xxx/my_solution/CMakeLists.txt simply reads:
cmake_minimum_required(VERSION 3.7)
project(my_solution)
add_subdirectory("${PROJECT_SOURCE_DIR}/../my_library" "${PROJECT_SOURCE_DIR}/my_library_output")
add_subdirectory("${PROJECT_SOURCE_DIR}/../my_application" "${PROJECT_SOURCE_DIR}/my_application_output")
Note that it is also permitted to put my_application and my_library within the my_solution directory, as in Visual Studio.
No. CLion either:
opens a new window with the other project you want to work on
closes your current project and opens the new one in the current window
as you can see in the documentation. I think this is wanted in their design; probably to maintain CLion fast and reactive...
Adding some visual clues based on the answer from #c-z
This is how my project structure looking -
This is how my root level CMakeLists.txt is looking -
Finally, this is how my sub-directory level CMakeLists.txt is looking -
NOTE:
You may choose to remove the outer level main.cpp file (I've deleted it)
Also, you can remove the project level executable to remove it from the run configuration.

Creating Xcode Project Templates in Xcode 8.2.1

How does one go about creating a project template in Xcode 8.2.1? I'm asking this because of how I would like to use such a project template as the basis for the many Xcode projects that I will most likely create in the process of learning how to program in C++ from Bjarne Stroustrup's Programming: Principles and Practices Using C++, Second Edition. Mr. Stroustrup provides his readers with several header files, which I have copied into a GitHub repository, on the book's rudimentary web site, and I would like to figure out how to link them into Xcode's build system.
Someone created a makefile for use with the Darwin base of OS X, but I'd rather be able to use Xcode so that I can learn how to do so while I am learning C++ so that I know how to use it for later projects. I don't know whether I should use this makefile or not, but Apple does provide instructions on 'Building Makefile Projects with Xcode', so should I use those? I've also noticed that other people have similarly asked questions about how to create project templates for older versions of Xcode here, here, here, and here. Would any of the material from these Stack Overflow posts help my prospective answerer or answerers by providing them with some source material for their research?
There seems to be an amazing lack of information on this topic. As far as I know templates have not changed materially since Xcode 4. Templates I made for it still work on Xcode 6.
Like one of the commenters above, I used this post to get started.
I am only developing for macOS (OS X), not iOS.
I also made some file templates, which are much easier; maybe try making one or two of them first. Macro names in file templates do need triple underscores at each end.
In XCode 7.3.1 (and maybe above versions too), you just need to go to Application folder, find XCode and right click on it and pick "Show Package Contents". Then, make your way to:
Contents/Developer/Library/XCode/Templates/..
In here you will find more folders which you mess with. Basically they are the items that appear when you goto XCode->File->New File... Becareful though, cause this is part of the XCode application. Not sure what will happen if you edit or add files wrongly.
ps. You also should quit XCode before opening the package contents.
Hope that helps.
http://robnapier.net/project-templates
This link helps me much,since the macros did not change.
I want to custom a project template. But no automatic tools could be found,I make one my self.
first,drag a template to my desktop from Path below.
Xcode ▸ Contents ▸ Developer ▸ Platforms ▸ iPhoneOS.platform ▸ Developer ▸ Library ▸ Xcode ▸ Templates ▸ Project Templates
( I use the empty template from the link:
https://github.com/tobymao/EmptyApplication.xctemplate)
then,add your files to the *.xctemplate directory .
And edit plist file.
two items needs: Definitions which type should be Dictionary;Nodes which type is Array;
In Definitions for each added file define a correspond Dictionary (name should be filename or filename had PROJECTNAMEASINDENTIFIER as prefix) ,which has key "Path" hold your files' path;
In Nodes ,add all the items defined in Definitions.
and,
if you had your filename has projectname as prefix ,you should change content of your class files,change the classnames to macro FILEBASENAMEASIDENTIFIER
at last ,
move your template directory back, and don't forget to change the identifier in plist.

Why compile button is disabled in VisualStudio?

For some reason when I open my project Compile button is disabled. I'm in C++ file and Ctrl+F7 doesn't work, Menu/Build/Compile is disabled and Compile in context menu in SolutionExplorer is disabled too. I can build project with F7, but I can't compile single file. It used to work just fine.
Any ideas why?
Had the same problem just because my project wasn't set as startup Project in my solution. Setting it solve the issue.
It seems that problem is on my side: someone in my team introduced some build scripts, which apparently work only for building whole project.
It might also be that a referenced property sheet could not be found. You can check this by attempting to view the properties of the project (Alt-Enter). A warning will be shown then when the property sheet cannot be found. Fix the property sheet reference, and probably you can compile again.
Note: question was asked/answered a while ago, but maybe it is useful for other persons.
My project was using an intermediate version of a unity build (sometimes called blob build) where groups of ~10 cpp files are put in the same compilation unit by being included in some blob_xxx.cpp. The project only considers the blob_xxx.cpp as source files, so technically the .cpp I was working on was not a source file for the project, so the Compile command was disabled (this is similar to what Paulius experienced).
In this case, you need to either select the blob_xxx.cpp file and Compile this single file, or switch to a non-blob build.
If your objective is to quickly test for compilation errors, you can comment out the includes for all the files you are not working on.
Alternatively, you may setup your project generation script to isolate the files you are working on in a separate blob (it's up to you to define what "working on" means; it may be a manual list or the list of cpp files that are checked out in Perforce if using it).

Set the default description for custom build rules in Visual Studio (2008)

In VS, it is possible to set a custom build rule at the individual file level. However, unless you change the description of the build step (which is what msbuild outputs when running the external tool), all you get is the default, which says "Performing Custom Build Step," followed by the error output of the tool.
I recently got burned by this in an inherited solution, where the build rule for a .asm file buried deep in a project was failing, and NASM didn't provide any useful debug information. Since I didn't know what file was failing, it took me forever to find the problem. One thing I tried was changing the description for all the projects in the solution (by selecting them all at once and opening the properties panel) and adding macros to show the project and file affected. Since the build rule was attached to a file, however, this naturally didn't work.
I also tried searching for the default description string in all the project files, but the project files don't store this information unless you set the value. So clearly, there's got to be a default somewhere. Anyone know how you can set this?
I doubt you can change the default for everything, but what you can do is create a property sheet in which you set a custom description, and than add that property sheet to all projects needing it.

Resources