Open ewaterlander opened 1 month ago
@betamaxbandit this issued that @ewaterlander raises sounds familiar - I think you have thoughts on this. (For reference @ewaterlander has done a bunch of fixes on core build for Makefiles and it would be great if the two of you coordinated/reviewed each others fixes in the CMake area)
@betamaxbandit this issued that @ewaterlander raises sounds familiar - I think you have thoughts on this. (For reference @ewaterlander has done a bunch of fixes on core build for Makefiles and it would be great if the two of you coordinated/reviewed each others fixes in the CMake area)
Hi @jonahgraham, Thanks for bringing this to my attention. I'll take a look (probably early next week) and check what code I use to achieve this.
@betamaxbandit this issued that @ewaterlander raises sounds familiar - I think you have thoughts on this. (For reference @ewaterlander has done a bunch of fixes on core build for Makefiles and it would be great if the two of you coordinated/reviewed each others fixes in the CMake area)
Hi @jonahgraham, Thanks for bringing this to my attention. I'll take a look (probably early next week) and check what code I use to achieve this.
Hi @jonahgraham , @ewaterlander,
This is the patch I have used to get around this issue.
Sets the CMake CMAKE_BUILD_TYPE define
The CMAKE_BUILD_TYPE is added to CMake configuration build, based on the active launch mode; DEBUG_MODE sets a buildType of "Debug", everything else sets a buildType of "Release". Note, the CMake CMAKE_BUILD_TYPE definition is not directly equivalent to the Launch Bar Launch Mode; there might be a scenario where the user wants to launch a debug session using the CMake Release build and not run it. However, for most cases this is probably sufficient.
For Issue CMake projects are ignoring the Launch mode Run/Debug #807.
diff --git a/cmake/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java b/cmake/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java
index 02c5b7a..3645c1f 100644
--- a/cmake/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java
+++ b/cmake/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java
@@ -68,6 +68,7 @@
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.debug.core.ILaunchManager;
import org.osgi.service.prefs.Preferences;
public class CMakeBuildConfiguration extends CBuildConfiguration {
@@ -161,6 +162,13 @@
ICMakeProperties cmakeProperties = getPropertiesController().load();
runCMake |= !Files.exists(buildDir.resolve("CMakeCache.txt")); //$NON-NLS-1$
+ // Causes CMAKE_BUILD_TYPE to be set according to the launch mode
+ if (ILaunchManager.DEBUG_MODE.equals(getLaunchMode())) {
+ cmakeProperties.setBuildType("Debug"); //$NON-NLS-1$
+ } else {
+ cmakeProperties.setBuildType("Release"); //$NON-NLS-1$
+ }
+
final SimpleOsOverridesSelector overridesSelector = new SimpleOsOverridesSelector();
if (!runCMake) {
CMakeGenerator generator = overridesSelector.getOsOverrides(cmakeProperties).getGenerator();
I was going to submit this as a PR, but I'm having problems connecting. As you can see from my commit message, it's not entirely ideal, but I think it matches most scenarios.
Hi @ewaterlander , I managed to add my PR (#810)
Regarding the inconsistency between use of the Launch Bar Launch Mode and the CMake Release/Debug, another way to handle this could be inside the Build Settings tab (see #691 for a screenshot of this). We could have a mapping of Launch Mode to CMake to CMAKE_BUILD_TYPE.
Launch Mode CMAKE_BUILD_TYPE
Run Release
Debug Debug
If you think it is important enough I can create a new ticket and add a mockup. WDYT?
Thanks. I have look tomorrow.
Hi @betamaxbandit
I approved your PR #810 Thanks! I think it is a good idea to have a mapping defined of launch mode to CMake build type. I think in CMakeBuildConfiguration is a good location.
CMake projects are not setting cmake -DCMAKE_BUILD_TYPE=... based on the Launch mode in the LaunchBar. If you switch Launch mode to Debug in the LaunchBar and build you get a binary without debug information, because CFLAG -g was missing. Hitting a breakpoint will show you no code.
To Reproduce Steps to reproduce the behavior:
The program will break at main, but you see no code.
Expected behavior You see the code.
Screenshots![image](https://github.com/eclipse-cdt/cdt/assets/102143930/6283dc06-94f7-4042-a59d-4b4b0f08b2d1)
Version Information (please complete the following information):
Additional context I did some debug. In CommandDescriptorBuilder.makeCMakeCommandline() a call is done to cmakeProperties.getBuildType() which always returns null. And this is caused by the fact that the build type was never set. CMakePropertiesBean.setBuildType() is never called.