QtCreator 4 and CMake parameters - c++

I used to open a CMake-based C++ project with QtCreator and pass my custom CMake command line parameters when configuring the project. In the recent versions of QtCreator (QtCreator 4 to be precise), this does not seem to be possible anymore - QtCreator configures the project with its own set of CMake variables and their default values. This is extremely annoying, because the only way to change the values of certain CMake variables is to click on 'Projects' and modify the variables one by one, which is really tedious. I have the configuration parameters for specific machine and setup on that machine in a text file that I could just paste in the configuration dialog of Qtcreator and then run CMake, but this dialog now disappeared. Do you know if there's a way of passing custom CMake values while opening a new project?
I tried to clean the build directory, remove CMakeLists.txt.user in the source tree, run CMake with my parameters and then open the project with QtCreator. Unfortunately, QtCreator ignores the cached values and generates its own ...

"Tools" > "Options" > "Build & Run" > "Your kit" > "CMake configuration"
Add a line and rebuild. You can go the short way Ctrl+5 (Projects mode) > "Manage Kits...", too.

#Manuel's answer is ideal for me when I have toolkit-specific CMake variables without project-specific variables.
When you have project-specific CMake variables, the options I have seen/used with recent QtCreator versions (~4+) are:
From QtCreator
Open the project
go to Projects (on left) and select Build Settings
Under CMake, use the "Add" button to add new settings
"Apply Configuration Changes"
"Build" menu, "Run CMake"
Notes:
if your project updates CMake variables (as most do), you may need to "Apply Configuration Changes" again.
if you have enabled the feature to automatically run CMake, it may fire off in the background, further confusing things. This can create chicken and egg situations - boo!
Outside QtCreator
Go to the build directory
Run CMake with your commands as usual
Open QtCreator
Open the project
Under Projects - Build Settings:
Confirm that the "Build directory:" is as expected
Confirm that your CMake variables appear in the list of variables
Sadly, I find both of these profoundly unsatisfying...

Since QtCreator 4.13 it is possible to set CMake parameters per project (finally):
Project > Build Settings > CMake > Initial CMake parameters

Related

Deploy a custom built project with QtCreator

I am using a custom build system (not CMake or qmake) with QtCreator 4.6.0 IDE on Linux, though I have both of these plugins installed.
My project is cross-compiled for an embedded Linux device, which I have set up the kit for. It builds fine, but the trouble is in the deployment step, where the custom build system does not tell it the executable file, so it does not know which files to deploy to the device. I have been referring to this page:
http://doc.qt.io/qtcreator/creator-deployment-embedded-linux.html
In my Run Settings page, I have the Deployment section to "Upload files via SFTP", but the "Files to deploy" list is empty (see the first screenshot in the above link). When I attempt to deploy/run, it confirms no files were deployed, as it outputs:
No deployment action necessary. Skipping.
Deploy step finished.
The documentation link first says to "Edit the qmake INSTALLS variable in the project .pro file to add the missing files.", however, my project has no .pro file at all. I created one for fun, and QtCreator has no idea it exists to be able to look at the INSTALLS line anyway, so that doesn't work.
In the "Deploying CMake Projects to Embedded Linux Devices" section at the bottom, it then says "You must specify all other files in the QtCreatorDeployment.txt file that you create and place in either the root directory of the CMake project or the build directory of the active build configuration." So I created such a file in the main project directory, as well as the build directory:
/home/root
build/test:.
The file makes no difference to the "Files to deploy" list, even after restarting. It seems to suggest this method is for CMake anyway. However, I have not even explicitly turned off the CMake building in the Build&Run > Kits, so I would not even know how to start making it build with CMake (and there is no insight from the documentation page: https://doc.qt.io/qtcreator/creator-project-cmake.html). The one thing I did change on the Build Settings page was in the "Build Steps" to do "Custom Process Step" instead of the usual Make step.
How do I add files to the "Files to deploy" list?
QtCreator 4.9 now supports specifying the QtCreatorDeployment.txt file for generic (non-CMake) projects to achieve this.
https://doc.qt.io/qtcreator/creator-deployment-embedded-linux.html#deploying-cmake-projects-to-embedded-linux-devices
https://blog.qt.io/blog/2019/02/21/qt-creator-4-9-beta-released/

Clion multiple debug configurations in cmake

I have project with qt-gui and command line only version.
I have release and debug configuration for both gui and non gui version. I want to have different names for debug configuration in gui and non gui version. But when configuration has different name than Debug, debugging does not work and it behaves like release build.
Is there any possibility to have multiple debug configurations, each with different name?
Note, if you click on "Debug" configuration, the following hint is shown up underneath the "CMake options":
-DCMAKE_BUILD_TYPE=Debug will be passed automatically
So, you shouldn try to add -DCMAKE_BUILD_TYPE=Debug into "CMake options" expliticly when you create your own configuration with a different name, which is inherently a Debug configuration

Eclipse Luna With MinGW: "Launch failed. Binary not found."

I have searched all over the web and have tried everything I could to fix this problem, to no avail. So here I am making a new post, hoping to fix this terribly frustrating problem.
I have the Eclipse IDE for C/C++ Developers that on my Windows 7 computer. The version of Eclipse is Luna Service Release 2 (4.4.2) and the build ID is 20150219-0600.
I have MinGW installed onto my computer, and I downloaded all the package choices just to be safe.
I create a C++ project. The "Project type" is Executable > Empty Project and the "Toolchains" is "Cross GCC".
I select both "Debug" and "Release" in the "Configurations".
I leave the "Cross compiler prefix" blank because I don't know what to write. I then put in "F:\MinGW" as the "Cross compiler path".
I create a new source file in the project and write the infamous Hello World program (in C++, of course). When I save the project, it gives me two errors in the "Problems" tab:
Program "g++" not found in PATH
Program "gcc" not found in PATH
When I build the project, it adds on another error:
Program "make" not found in PATH
I go to Project > Properties > C/C++ Build > Tool Chain Editor and change the "Current builder" from "Gnu Make Builder" to "CDT Internal Builder".
The error Program "make" not found in PATH then disappears.
I go to Window > Preferences > C/C++ > New C/C++ Project Wizard > Makefile Project and set the "Binary parser" to "PE Windows Parser". I clear the project, save the project, and build the project, but the 2 errors remain.
If I go to Project > Properties > C/C++ Build > Environment and set the value of the "PATH" variable to "F:\MinGW\bin", still nothing happens and the two errors remain.
Now, when I attempt to run the project (ctrl + F11), it spits out the error Launch Failed. Binary not found.
In the "Project Explorer", I see a HelloWorld file that contains an "Includes" file (containing the compiler libraries?), a "Debug" folder (containing a HelloWorld.exe and a main.o), and a main.cpp file (containing my Hello World program).
Thank you in advance for taking the time to read this and for trying to help.
You need to update environment variable PATH. Check this page.
You must add C:\MinGW\bin; to your user PATH environment variable manually.
I suggest, not a solution, at least you want to make sure the following.
Recheck that the PATH is set up right. Sometime we think we did, but the computer does not. In the command line, type the following command to see the gcc installed right and PATH is set right.
gcc --version
echo $PATH
or
echo %PATH%
All things are right as you did above, but it does not work?, Then remove and reinstall mingw and eclipse CDT cleanly. Don't change and keep the default options in the Eclipse CDT. Without any option changes CDT, it should work NOWADAYS. Eclipse CDT(8.7, 8.8) is pretty much stable.
Blessings,
(a debtor)<><

How to import C makefile project into eclipse or put in under eclipse

I have standard source code package under Linux which requires to run
./configure
make
to compile it (and it works ok).
Mostly these files are C/C++
Is it possible to put this project under Eclipse control? I wish to browse definitions etc...
UPDATE 1
I have Eclipse Indigo running on Ubuntu. It contains CDT of course.
When I choose File-Import, I see no matching option under C/C++. Under General I have Existing Projects into Workspace but I get No project are found to import if I point this wizard to my project root.
UPDATE 2
I have installed Eclipse with Ubuntu package manager. Probably this was wrong.
First run the ./configure to generate the Makefile.
After that, if you have CDT installed,just choose the option
"File->New->Makefile Project With Existing Code" and point to the directory where the Makefile is stored.
Create a new project, make sure to uncheck the "Use default location" option while doing so. Add your source tree path in the location field. Now select "Makefile Project" in the project types window.
In "builder settings" (Project>Properties), uncheck the "use default build command" and add:
make -f /<your project location/Makefile
If your makefile is named otherwise, you can change it here.
To run your application, add the application in Run Configurations. See full instructions here.
Don't say import.
Create a new C/C++ project using the New Project Wizard, and specify the "root folder" as a non-default location of the new project.
See the instructions here.
Read "Creating new projects from existing source roots"

QtCreator and "Run CMake"

When running CMake from the project view in QtCreator ("Run CMake" command), CMake wizard pops up. This is becoming really annoying and since I'm QtCreator newbie, I don't know if there is any remedy for this.
Desired effect would be automatic execution of cmake, without the CMake wizard pestilence.
Yes, this GUI annoying me too.
The only option is to add custom build step in your Project configuration
run app: cmake
params CMakeLists.txt
working folder: %{sourceDir}
this step should be added BEFORE make step.
Once you have created a project in Qt Creator, you do not need to use the "Run CMake" command unless for some reason you think the project files are out of date. Just click build, run, debug etc and it will take care of compiling the files that need to be compiled and invoking CMake as and when necessary.
Underneath it uses Unix Makefiles with Codeblocks in order to generate an XML description of the project. Running CMake from the menu explicitly re-runs CMake and reparses the XML description.