How to define multi-config in KDevelop with CMake? - c++

I'm working with KDevelop and CMake.
When I need to debug my program, I have to switch the value of "CMAKE_BUILD_TYPE" from "Release" to "Debug" in the Project Configure dialog, and rebuild all programs in order to add debugging symbol info into programs.
When I need to release my program, I have to switch back the value to "Release", and rebuild all things again.
It's tedious and long-waiting to re-build all programs.
My question:
Is there a way, by it I can define multiple configurations for my project, and let one conf for "Debug" and another for "Release"?
Thanks!!!

I'm using KDevelop-5.2.1, but I think this method should be applicable with later versions.
Open menu: "Project" -> "Open Configuration..."
In the "Configure Project" dialog, create a new Configuration for our project.
Now we have two Configurations for our project, therefore we can set one for debugging, and another for releasing.

Related

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

Specifying external Makefile options in Eclipse CDT

I'd like to (temporarily) migrate a C++ project from Netbeans to Eclipse (in order to use Eclipse's parallel debugger). So far I've created a "Makefile project with Existing Code" project in Eclipse that references the Netbeans project Makefile/directory. However the Netbeans project accepts config options for example
make -f Makefile CONF=GNU_Debug
How can I pass this option to the Makefile in Eclipse?
Eclipse version
Eclipse for Parallel Application Developers -- Mars.2 Release (4.5.2)
You can change the default make call in the projects properties dialog:
My version:
Version: Mars.1 Release (4.5.1)
Note that the -f Makefile should be superfluous.
In addition to πάντα ῥεῖ's answer, which changes settings "globally" for a project, you can define individual make targets in the Make Target view.
Steps:
Choose Window -> Show View -> Other... -> Make -> Make Target (or simpler, press Ctrl+3 then type Make Target and choose the view from the list.)
Right click on the project in the view and choose New...
Enter the make target you want to use, e.g. CONF=GNU_Debug and press OK
Double-click on target to build
Here is a screenshot:
Shortcuts
You can quickly rebuild last selected Make target by pressing F9
Bring up a pop-up to select Make target by pressing Shift+F9
Access the same UI as above by right-clicking on project in Project Explorer and choosing Make Targets -> Build or selecting the same from the Project menu.

Porting several dependent C++ makefile projects into MSVC

I have several projects which depend on each other. For example, when I install them I do this:
Project1:
/configure & make & make install
Project2:
/configure & make & make install
Such that "Project2" depends on some libraries of "Project1". I want to create an MSVC project for Project2, and start working with it, and changing it (and compiling it inside). How can I do this?
Also, how different is this to be done in linux with Eclips (when you don't have admin permission and can't do 'make install')?
You can create project dependence in Visual Studio.
To assign dependencies to projects
In Solution Explorer, select a project.
On the Project menu, choose Project Dependencies.
The Project Dependencies dialog box opens.
On the Dependencies tab, select a project from the Project drop-down
menu.
In the Depends on field, select the check box of any other project
that must build before this project does.
You can read more about it here
Visual Studio is your usual clickfest, but you can define project dependencies.
Define one project per module, then go to the solution properties tab and, for each project, select the checkboxes that inform the IDE that this project depends on a set of other projects.
The IDE will then sort and build them in the appropriate order.

eclipse CDT:copying library paths from debug to release mode

I have been developing a C++ app and running in debug mode, I have now set active build to release mode and have realized that I have to re-add all of the include paths and libraries (there are a lot of them!) is there any way to automatically do this/a bulk copy paste?
Thanks
You can also select "all configurations" in the menu where you set your paths. The typical workflow for setting up a project is to first set "all configurations", do your stuff, and then selectively put in the Debug/Release specific things (like the NDEBUG symbol, or optimizer flags). No copying is required. Note that most good IDEs have this feature (including Visual Studio).
Just figured it out (kinda). You can highlight all libs and copy them, then can just click on the box in the release dialogue and hit paste.

Makefile-based Eclipse CDT with run/debug launch configuration depend on release/debug build configuration

I have a Makefile that based on given target (all/debug) generates executable in release/debug directories on the project folder.
I have setup the Eclipse-CDT C/C++ build behavior mechanism to generate the right output depending on the active build configuration.
For example the "release" build configuration will call "make" with "all" as the behavior, that makes release/output file, "debug" configuration makes a debug version at debug/output
So far so good, but when I need to setup the "run configurations" I should enter the path for the binary (search project just does not show anything), Variable ${ConfigName} also does not expand there so I cannot use something like ${ConfigName}/output as binary to run/debug.
I also tried adding release and debug to the "Paths and symbols"/"Output location" and that not help either.
I can enter the relative/absolute path (for examle ./release/output) there and if I hit run, it runs the binary or if I hit debug it debugs it. However, because of the reliance on the path I have to have two launch configurations one for debug and one for release.
The problem is that run and debug configurations are basically the same only one has the option to customize gdb, which makes it very confusing. Regardless of whether it is debug or release active, one can run/debug any of the four combinations!
Is there anyway I can run/debug what actually is built? so if the debug build is active one can run/debug the debug build? I am not even constraining the debug build to be non-runnable or the release build to be non-debuggable, I guess that is asking too much. The problem is because of the two launch configurations, and I cannot find anyway to make it just one that depends on the build configuration.