mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-03-28 14:56:28 +01:00
Bug579242: allow user to override CMake Settings (#683)
The Launch Bar Launch Configuration, Build Settings tab allows the user to customise the CMake Settings (CMake generator, extra arguments, build command and clean command). But changing these settings did not affect the CMake build. This is now fixed. A "Use these settings" checkbox allows the user to choose settings from the UI or use the operating system defaults.
This commit is contained in:
parent
1589b8b074
commit
b7fa35979a
14 changed files with 492 additions and 20 deletions
|
@ -32,6 +32,18 @@ The original locations of object files within a GNU archive are now calculated u
|
|||
|
||||
Managed build _Static Library_ projects using a _Cross GCC_, _Cygwin GCC_, _Linux GCC_ or _MinGW GCC_ toolchain now use the `-P` archiver flag by default to generate the necessary path information.
|
||||
|
||||
# CMake
|
||||
The Launch Bar Launch Configuration Build Settings tab has been updated so it can now correctly control the CMake Generator setting. The "Additional CMake arguments" field can also be used to inject CMake defines into the CMakeCache.txt file to populate it with customizable settings for the project. Use the new "Use these settings" checkbox to control whether to use either the operating system defaults or settings from the UI.
|
||||
|
||||
When "Use these settings" checkbox is unchecked, the operating system defaults are used during the CMake build.
|
||||
|
||||
<p align="center"><img src="images/CDT-11.5-Build_Settings_Use_these_settings_unchecked.PNG" width="50%"></p>
|
||||
|
||||
When the "Use these settings" checkbox is checked, the UI settings are used during the CMake build.
|
||||
|
||||
<p align="center"><img src="images/CDT-11.5-Build_Settings_Use_these_settings_checked.PNG" width="50%"></p>
|
||||
|
||||
|
||||
# API Changes, current and planned
|
||||
|
||||
## Breaking API changes
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
|
@ -117,3 +117,11 @@ DISPLAY=:99 mvn verify
|
|||
or specify the `DISPLAY` in the Eclipse JUnit launch configuration:
|
||||
|
||||

|
||||
|
||||
## Manual Testing
|
||||
### CMake Build Settings tab
|
||||
A set of manual tests that check it is possible to control the CMake build using the Launch Bar Launch Configuration > Build Settings tab.
|
||||
|
||||
[CMake Build Settings tests](./cmake/org.eclipse.cdt.cmake.ui.tests/manualTests/Bug579242_manual_tests.md)
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
|||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: %pluginName
|
||||
Bundle-SymbolicName: org.eclipse.cdt.cmake.core;singleton:=true
|
||||
Bundle-Version: 1.5.400.qualifier
|
||||
Bundle-Version: 1.5.500.qualifier
|
||||
Bundle-Activator: org.eclipse.cdt.cmake.core.internal.Activator
|
||||
Bundle-Vendor: %providerName
|
||||
Require-Bundle: org.eclipse.core.runtime,
|
||||
|
|
|
@ -18,11 +18,13 @@ import java.nio.file.Path;
|
|||
import java.nio.file.SimpleFileVisitor;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.cdt.cmake.core.CMakeErrorParser;
|
||||
import org.eclipse.cdt.cmake.core.CMakeExecutionMarkerFactory;
|
||||
|
@ -66,14 +68,19 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
|||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.osgi.service.prefs.Preferences;
|
||||
|
||||
public class CMakeBuildConfiguration extends CBuildConfiguration {
|
||||
|
||||
public static final String CMAKE_USE_UI_OVERRIDES = "cmake.use.ui.overrides"; //$NON-NLS-1$
|
||||
public static final boolean CMAKE_USE_UI_OVERRIDES_DEFAULT = false;
|
||||
public static final String CMAKE_GENERATOR = "cmake.generator"; //$NON-NLS-1$
|
||||
public static final String CMAKE_ARGUMENTS = "cmake.arguments"; //$NON-NLS-1$
|
||||
public static final String CMAKE_ENV = "cmake.environment"; //$NON-NLS-1$
|
||||
public static final String BUILD_COMMAND = "cmake.command.build"; //$NON-NLS-1$
|
||||
public static final String BUILD_COMMAND_DEFAULT = "cmake"; //$NON-NLS-1$
|
||||
public static final String CLEAN_COMMAND = "cmake.command.clean"; //$NON-NLS-1$
|
||||
public static final String CLEAN_COMMAND_DEFAULT = "clean"; //$NON-NLS-1$
|
||||
|
||||
private ICMakeToolChainFile toolChainFile;
|
||||
|
||||
|
@ -261,6 +268,23 @@ public class CMakeBuildConfiguration extends CBuildConfiguration {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* When UI overrides are in force, gets the user specified clean target (if not blank), otherwise the default clean target.
|
||||
* @return Always a non-null String indicating the clean target.
|
||||
*/
|
||||
private String getCleanCommand() {
|
||||
String retVal = CLEAN_COMMAND_DEFAULT;
|
||||
Preferences settings = this.getSettings();
|
||||
boolean useUiOverrides = settings.getBoolean(CMAKE_USE_UI_OVERRIDES, CMAKE_USE_UI_OVERRIDES_DEFAULT);
|
||||
if (useUiOverrides) {
|
||||
String cleanCommand = settings.get(CLEAN_COMMAND, CLEAN_COMMAND_DEFAULT);
|
||||
if (!cleanCommand.isBlank()) {
|
||||
retVal = cleanCommand;
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clean(IConsole console, IProgressMonitor monitor) throws CoreException {
|
||||
IProject project = getProject();
|
||||
|
@ -271,7 +295,7 @@ public class CMakeBuildConfiguration extends CBuildConfiguration {
|
|||
ICMakeProperties cmakeProperties = getPropertiesController().load();
|
||||
CommandDescriptorBuilder cmdBuilder = new CommandDescriptorBuilder(cmakeProperties,
|
||||
new SimpleOsOverridesSelector());
|
||||
CommandDescriptor command = cmdBuilder.makeCMakeBuildCommandline("clean"); //$NON-NLS-1$
|
||||
CommandDescriptor command = cmdBuilder.makeCMakeBuildCommandline(getCleanCommand());
|
||||
ConsoleOutputStream outStream = console.getOutputStream();
|
||||
|
||||
Path buildDir = getBuildDirectory();
|
||||
|
@ -547,7 +571,12 @@ public class CMakeBuildConfiguration extends CBuildConfiguration {
|
|||
}
|
||||
} // CMakeIndexerInfoConsumer
|
||||
|
||||
private static class SimpleOsOverridesSelector implements IOsOverridesSelector {
|
||||
/**
|
||||
* Supports OS overrides and also User Interface (UI) overrides, provided in the CMakeBuildTab. The UI
|
||||
* overrides are stored in the intermediary CBuildConfiguration Preferences (CBuildConfiguration.getSettings())
|
||||
* and used only when CMAKE_USE_UI_OVERRIDES is true.
|
||||
*/
|
||||
private class SimpleOsOverridesSelector implements IOsOverridesSelector {
|
||||
|
||||
@Override
|
||||
public IOsOverrides getOsOverrides(ICMakeProperties cmakeProperties) {
|
||||
|
@ -561,7 +590,31 @@ public class CMakeBuildConfiguration extends CBuildConfiguration {
|
|||
// fall back to linux, if OS is unknown
|
||||
overrides = cmakeProperties.getLinuxOverrides();
|
||||
}
|
||||
return overrides;
|
||||
return getUiOrOsOverrides(overrides);
|
||||
}
|
||||
|
||||
private IOsOverrides getUiOrOsOverrides(IOsOverrides osOverrides) {
|
||||
IOsOverrides retVal = Objects.requireNonNull(osOverrides, "osOverrides must not be null"); //$NON-NLS-1$
|
||||
Preferences settings = getSettings();
|
||||
boolean useUiOverrides = settings.getBoolean(CMAKE_USE_UI_OVERRIDES, CMAKE_USE_UI_OVERRIDES_DEFAULT);
|
||||
if (useUiOverrides) {
|
||||
// Set UI override for generator
|
||||
String gen = settings.get(CMAKE_GENERATOR, ""); //$NON-NLS-1$
|
||||
retVal.setGenerator(CMakeGenerator.getGenerator(gen));
|
||||
// Set UI override for Extra Arguments
|
||||
String extraArgsStr = settings.get(CMAKE_ARGUMENTS, ""); //$NON-NLS-1$
|
||||
// Convert String of args, separated by 1 or more spaces, into list of Strings
|
||||
List<String> extraArgs = Arrays.stream(extraArgsStr.split("\\s+")).map(entry -> entry.trim()) //$NON-NLS-1$
|
||||
.collect(Collectors.toList());
|
||||
retVal.setExtraArguments(extraArgs);
|
||||
// Set UI override for cmake build command, unless it's the default
|
||||
String buildCommand = settings.get(BUILD_COMMAND, BUILD_COMMAND_DEFAULT);
|
||||
if (!buildCommand.isBlank() && !BUILD_COMMAND_DEFAULT.equals(buildCommand)) {
|
||||
retVal.setUseDefaultCommand(false);
|
||||
retVal.setCommand(buildCommand);
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
} // SimpleOsOverridesSelector
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ class CommandDescriptorBuilder {
|
|||
List<String> env = new ArrayList<>();
|
||||
|
||||
// defaults for all OSes...
|
||||
args.add("cmake"); //$NON-NLS-1$
|
||||
args.add(CMakeBuildConfiguration.BUILD_COMMAND_DEFAULT);
|
||||
/* add general settings */
|
||||
if (cmakeProperties.isWarnNoDev())
|
||||
args.add("-Wno-dev"); //$NON-NLS-1$
|
||||
|
@ -111,7 +111,7 @@ class CommandDescriptorBuilder {
|
|||
|
||||
IOsOverrides osOverrides = overridesSelector.getOsOverrides(cmakeProperties);
|
||||
if (osOverrides.getUseDefaultCommand()) {
|
||||
args.add("cmake"); //$NON-NLS-1$
|
||||
args.add(CMakeBuildConfiguration.BUILD_COMMAND_DEFAULT);
|
||||
} else {
|
||||
IStringVariableManager varManager = VariablesPlugin.getDefault().getStringVariableManager();
|
||||
String cmd = varManager.performStringSubstitution(osOverrides.getCommand());
|
||||
|
|
|
@ -15,6 +15,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.eclipse.cdt.cmake.core.internal.CMakeBuildConfiguration;
|
||||
import org.eclipse.cdt.cmake.core.properties.CMakeGenerator;
|
||||
import org.eclipse.cdt.cmake.core.properties.IOsOverrides;
|
||||
|
||||
|
@ -42,7 +43,7 @@ public abstract class AbstractOsOverrides implements IOsOverrides {
|
|||
* Sets each value to its default.
|
||||
*/
|
||||
public void reset() {
|
||||
setCommand("cmake"); //$NON-NLS-1$
|
||||
setCommand(CMakeBuildConfiguration.BUILD_COMMAND_DEFAULT);
|
||||
useDefaultCommand = true;
|
||||
setGenerator(CMakeGenerator.UnixMakefiles);
|
||||
extraArguments.clear();
|
||||
|
|
|
@ -81,4 +81,16 @@ public enum CMakeGenerator {
|
|||
public String getIgnoreErrOption() {
|
||||
return ignoreErrOption;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.5
|
||||
*/
|
||||
public static CMakeGenerator getGenerator(String generatorName) {
|
||||
for (CMakeGenerator gen : values()) {
|
||||
if (gen.getCMakeName().equals(generatorName)) {
|
||||
return gen;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,331 @@
|
|||
Bug 579242 - Ninja generator not connected
|
||||
|
||||
## Overview
|
||||
Tests that it is possible to control the CMake build using the Launch Bar Launch Configuration > Build Settings tab.
|
||||
The Build Settings page allows the user to control:
|
||||
|
||||
* "Use these settings" checkbox allows user to use these settings instead of operating system defaults.
|
||||
* Generator "Unix Makefiles" or "Ninja" radio group allows choice of CMake generator.
|
||||
* "Additional CMake arguments" allows variable=value arguments to be passed to CMake CACHE entry to customise settings for the project.
|
||||
|
||||
## Test cases
|
||||
The following test cases use a Launch Target set to Local.
|
||||
|
||||
### 1) Operating system defaults used
|
||||
#### 1.1) Launch Bar Launch Mode=Run, CMake Settings > "Use these settings"=unchecked
|
||||
Expected: Build uses default generator (win32: -G MinGW Makefiles)
|
||||
#### 1.2) Launch Bar Launch Mode=Debug, CMake Settings > "Use these settings"=unchecked
|
||||
Expected: Build uses default generator (win32: -G MinGW Makefiles)
|
||||
|
||||
### 2) Build Settings specific generator used:
|
||||
Note, the Build Settings tab settings are stored separately for Run mode and Debug mode.
|
||||
#### 2.1) Launch Bar Launch Mode=Run, CMake Settings > Use these settings=checked, Generator=Ninja
|
||||
Expected: Build uses generator Ninja
|
||||
#### 2.2) Launch Bar Launch Mode=Debug, CMake Settings > Use these settings=checked, Generator=Unix Makefiles
|
||||
Expected: Build uses generator Unix Makefiles
|
||||
#### 2.3) Build Settings are remembered
|
||||
#### 2.4) Build Settings for Run mode can be different to settings stored for Debug
|
||||
|
||||
### 3) Build Settings specific Additional CMake arguments:
|
||||
#### 3.1) CMake Settings > Use these settings=checked, Additional CMake arguments are used during build
|
||||
#### 3.2) CMake Settings > Use these settings=unchecked, Additional CMake arguments are NOT used during build
|
||||
|
||||
### 4) Build Settings specific Build and Clean command:
|
||||
Note, not tested. These may be removed in future.
|
||||
|
||||
## Setup & prerequisites
|
||||
### Setup Host
|
||||
Note, these instructions do not require the following tools to be added to the system path environment variable in the OS before starting Eclipse. This allows a clean environment to be maintained.
|
||||
|
||||
- Install Eclipse/CDT on host.
|
||||
- Install gcc toolchain and make tools on host.
|
||||
- On Windows I used msys64 (https://www.msys2.org/), which contains mingw64.
|
||||
- Install CMake and Ninja on host.
|
||||
|
||||
### In Eclipse, setup tool paths.
|
||||
#### Toolchain
|
||||
When using a recognised gcc toolchain (mingw64 is one of these), CDT automatically registers the toolchain for use within the workbench.
|
||||
* To check if the toolchain is registered, open Preferences > C/C++ > Core Build Toolchains. In the Available Toolchains list, check if it contains the toolchain you installed on the host.
|
||||
|
||||
For example, when using mingw64 the following toolchain is available:
|
||||
|
||||
Type Name OS Arch
|
||||
GCC win32 x86_64 C:\msys64\mingw64\bin\gcc.exe win32 x86_64
|
||||
Otherwise, register your toolchain by clicking Add... in the User Defined Toolchains list.
|
||||
|
||||
#### CMake & Ninja
|
||||
* Open Preferences > C/C++ > Build > Environment and click Add...
|
||||
|
||||
In Name enter "PATH" and in Value enter the path to CMake and Ninja, for example
|
||||
|
||||
`C:\Program Files\CMake\bin;C:\Ninja\bin`
|
||||
|
||||
|
||||
You probably want to make sure "Append variables to native environment" (default) is selected.
|
||||
|
||||
#### Create a CMake project
|
||||
* In Eclipse, choose File > C/C++ Project.
|
||||
* In the New C/C++ Project wizard, choose CMake in the left hand side sash and then CMake Project and click Next.
|
||||
* Enter a project name, for example helloworld and click Finish.
|
||||
* In the Project Explorer, expand the generated project. It contains 3 files :
|
||||
|
||||
helloworld.cpp
|
||||
|
||||
CMakeLists.txt
|
||||
|
||||
config.h.in
|
||||
|
||||
|
||||
## Test Execution
|
||||
### 20240129 Windows 10. All tests pass.
|
||||
|
||||
### Setup
|
||||
Create CMake Project called helloworld.
|
||||
### 1) Operating system defaults used
|
||||
#### 1.1) Launch Bar Launch Mode=Run, CMake Settings > "Use these settings"=unchecked
|
||||
* Set Launch Bar Launch Mode to Run.
|
||||
* Set CMake Settings > "Use these settings" to unchecked.
|
||||
* On the Launch Bar, click Build button.
|
||||
|
||||
Expected: Build uses default generator (win32: -G MinGW Makefiles)
|
||||
|
||||
Actual:
|
||||
|
||||
Configuring in: C:\Users\betamax\cdt-only2\runtime-New_configuration(1)\helloworld\build\default
|
||||
cmake -G MinGW Makefiles -DCMAKE_EXPORT_COMPILE_COMMANDS=ON C:\Users\betamax\cdt-only2\runtime-New_configuration(1)\helloworld
|
||||
-- The C compiler identification is GNU 11.2.0
|
||||
-- The CXX compiler identification is GNU 11.2.0
|
||||
-- Detecting C compiler ABI info
|
||||
-- Detecting C compiler ABI info - done
|
||||
-- Check for working C compiler: C:/msys64/mingw64/bin/cc.exe - skipped
|
||||
-- Detecting C compile features
|
||||
-- Detecting C compile features - done
|
||||
-- Detecting CXX compiler ABI info
|
||||
-- Detecting CXX compiler ABI info - done
|
||||
-- Check for working CXX compiler: C:/msys64/mingw64/bin/c++.exe - skipped
|
||||
-- Detecting CXX compile features
|
||||
-- Detecting CXX compile features - done
|
||||
-- Configuring done (3.1s)
|
||||
-- Generating done (0.0s)
|
||||
-- Build files have been written to: C:/Users/betamax/cdt-only2/runtime-New_configuration(1)/helloworld/build/default
|
||||
Building in: C:\Users\betamax\cdt-only2\runtime-New_configuration(1)\helloworld\build\default
|
||||
cmake --build . --target all
|
||||
[ 50%] Building CXX object CMakeFiles/helloworld.dir/helloworld.cpp.obj
|
||||
[100%] Linking CXX executable helloworld.exe
|
||||
[100%] Built target helloworld
|
||||
Build complete (0 errors, 0 warnings): C:\Users\betamax\cdt-only2\runtime-New_configuration(1)\helloworld\build\default
|
||||
|
||||
#### 1.2) Launch Bar Launch Mode=Debug, CMake Settings > "Use these settings"=unchecked
|
||||
* Set Launch Bar Launch Mode to Debug.
|
||||
* Make sure CMake Settings > "Use these settings" to unchecked.
|
||||
* On the Launch Bar, click Build button.
|
||||
|
||||
Expected: Build uses default generator (win32: -G MinGW Makefiles)
|
||||
|
||||
Actual:
|
||||
|
||||
Configuring in: C:\Users\betamax\cdt-only2\runtime-New_configuration(1)\helloworld\build\cmake.debug.win32.x86_64
|
||||
cmake -G MinGW Makefiles -DCMAKE_EXPORT_COMPILE_COMMANDS=ON C:\Users\betamax\cdt-only2\runtime-New_configuration(1)\helloworld
|
||||
-- The C compiler identification is GNU 11.2.0
|
||||
-- The CXX compiler identification is GNU 11.2.0
|
||||
-- Detecting C compiler ABI info
|
||||
-- Detecting C compiler ABI info - done
|
||||
-- Check for working C compiler: C:/msys64/mingw64/bin/cc.exe - skipped
|
||||
-- Detecting C compile features
|
||||
-- Detecting C compile features - done
|
||||
-- Detecting CXX compiler ABI info
|
||||
-- Detecting CXX compiler ABI info - done
|
||||
-- Check for working CXX compiler: C:/msys64/mingw64/bin/c++.exe - skipped
|
||||
-- Detecting CXX compile features
|
||||
-- Detecting CXX compile features - done
|
||||
-- Configuring done (2.8s)
|
||||
-- Generating done (0.0s)
|
||||
-- Build files have been written to: C:/Users/betamax/cdt-only2/runtime-New_configuration(1)/helloworld/build/cmake.debug.win32.x86_64
|
||||
Building in: C:\Users\betamax\cdt-only2\runtime-New_configuration(1)\helloworld\build\cmake.debug.win32.x86_64
|
||||
cmake --build . --target all
|
||||
[ 50%] Building CXX object CMakeFiles/helloworld.dir/helloworld.cpp.obj
|
||||
[100%] Linking CXX executable helloworld.exe
|
||||
[100%] Built target helloworld
|
||||
Build complete (0 errors, 0 warnings): C:\Users\betamax\cdt-only2\runtime-New_configuration(1)\helloworld\build\cmake.debug.win32.x86_64
|
||||
|
||||
|
||||
### 2) Build Settings specific generator used:
|
||||
#### 2.1) Launch Bar Launch Mode=Run, CMake Settings > Use these settings=checked, Generator=Ninja
|
||||
* Set Launch Bar Launch Mode to Run.
|
||||
* Set CMake Settings > "Use these settings" to checked.
|
||||
* Make sure CMake Settings > Generator is set to Ninja.
|
||||
* In Project Explorer, delete the build directory.
|
||||
* On the Launch Bar, click Build button.
|
||||
|
||||
Expected: Build uses generator Ninja
|
||||
|
||||
Actual:
|
||||
|
||||
Configuring in: C:\Users\betamax\cdt-only2\runtime-New_configuration(1)\helloworld\build\default
|
||||
cmake -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON C:\Users\betamax\cdt-only2\runtime-New_configuration(1)\helloworld
|
||||
-- The C compiler identification is GNU 11.2.0
|
||||
-- The CXX compiler identification is GNU 11.2.0
|
||||
-- Detecting C compiler ABI info
|
||||
-- Detecting C compiler ABI info - done
|
||||
-- Check for working C compiler: C:/msys64/mingw64/bin/cc.exe - skipped
|
||||
-- Detecting C compile features
|
||||
-- Detecting C compile features - done
|
||||
-- Detecting CXX compiler ABI info
|
||||
-- Detecting CXX compiler ABI info - done
|
||||
-- Check for working CXX compiler: C:/msys64/mingw64/bin/c++.exe - skipped
|
||||
-- Detecting CXX compile features
|
||||
-- Detecting CXX compile features - done
|
||||
-- Configuring done (2.3s)
|
||||
-- Generating done (0.0s)
|
||||
-- Build files have been written to: C:/Users/betamax/cdt-only2/runtime-New_configuration(1)/helloworld/build/default
|
||||
Building in: C:\Users\betamax\cdt-only2\runtime-New_configuration(1)\helloworld\build\default
|
||||
cmake --build . --target all
|
||||
[1/2] Building CXX object CMakeFiles/helloworld.dir/helloworld.cpp.obj
|
||||
[2/2] Linking CXX executable helloworld.exe
|
||||
Build complete (0 errors, 0 warnings): C:\Users\betamax\cdt-only2\runtime-New_configuration(1)\helloworld\build\default
|
||||
|
||||
#### 2.2) Launch Bar Launch Mode=Debug, CMake Settings > Use these settings=checked, Generator=Unix Makefiles
|
||||
* Set Launch Bar Launch Mode to Debug.
|
||||
* Set CMake Settings > "Use these settings" to checked.
|
||||
* Make sure CMake Settings > Generator is set to Unix Makefiles.
|
||||
* On the Launch Bar, click Build button.
|
||||
|
||||
Expected: Build uses generator Unix Makefiles
|
||||
|
||||
Actual:
|
||||
|
||||
Configuring in: C:\Users\betamax\cdt-only2\runtime-New_configuration(1)\helloworld\build\cmake.debug.win32.x86_64
|
||||
cmake -G Unix Makefiles -DCMAKE_EXPORT_COMPILE_COMMANDS=ON C:\Users\betamax\cdt-only2\runtime-New_configuration(1)\helloworld
|
||||
-- The C compiler identification is GNU 11.2.0
|
||||
-- The CXX compiler identification is GNU 11.2.0
|
||||
-- Detecting C compiler ABI info
|
||||
-- Detecting C compiler ABI info - done
|
||||
-- Check for working C compiler: C:/msys64/mingw64/bin/cc.exe - skipped
|
||||
-- Detecting C compile features
|
||||
-- Detecting C compile features - done
|
||||
-- Detecting CXX compiler ABI info
|
||||
-- Detecting CXX compiler ABI info - done
|
||||
-- Check for working CXX compiler: C:/msys64/mingw64/bin/c++.exe - skipped
|
||||
-- Detecting CXX compile features
|
||||
-- Detecting CXX compile features - done
|
||||
-- Configuring done (3.3s)
|
||||
-- Generating done (0.0s)
|
||||
-- Build files have been written to: C:/Users/betamax/cdt-only2/runtime-New_configuration(1)/helloworld/build/cmake.debug.win32.x86_64
|
||||
Building in: C:\Users\betamax\cdt-only2\runtime-New_configuration(1)\helloworld\build\cmake.debug.win32.x86_64
|
||||
cmake --build . --target all
|
||||
[ 50%] [32mBuilding CXX object CMakeFiles/helloworld.dir/helloworld.cpp.obj[0m
|
||||
[100%] [32m[1mLinking CXX executable helloworld.exe[0m
|
||||
[100%] Built target helloworld
|
||||
Build complete (0 errors, 0 warnings): C:\Users\betamax\cdt-only2\runtime-New_configuration(1)\helloworld\build\cmake.debug.win32.x86_64
|
||||
|
||||
|
||||
#### 2.3) Build Settings are remembered
|
||||
* With Launch Bar Launch Mode still set to Debug.
|
||||
* Open CMake Settings > "Use these settings".
|
||||
|
||||
Expected:
|
||||
|
||||
checked.
|
||||
|
||||
Actual:
|
||||
|
||||
checked.
|
||||
|
||||
#### 2.4) Build Settings for Run mode can be different to settings stored for Debug
|
||||
* Make sure Launch Bar Launch Mode still set to Debug.
|
||||
* Set CMake Settings > "Use these settings" to unchecked.
|
||||
* Set Launch Bar Launch Mode to Run.
|
||||
* Open CMake Settings > "Use these settings".
|
||||
|
||||
Expected:
|
||||
|
||||
checked.
|
||||
|
||||
Actual:
|
||||
|
||||
checked.
|
||||
* Set Launch Bar Launch Mode to Debug.
|
||||
* Open CMake Settings > "Use these settings".
|
||||
|
||||
Expected:
|
||||
|
||||
unchecked.
|
||||
|
||||
Actual:
|
||||
|
||||
unchecked.
|
||||
|
||||
|
||||
### 3) Build Settings specific Additional CMake arguments:
|
||||
#### 3.1) CMake Settings > Use these settings=checked, Additional CMake arguments are used during build
|
||||
* Make sure Launch Bar Launch Mode still set to Debug.
|
||||
* Set CMake Settings > "Use these settings" to checked.
|
||||
* Set CMake Settings > Generator to Ninja.
|
||||
* Set CMake Settings > "Additional CMake arguments" to "-DVAR=TEST"
|
||||
* On the Launch Bar, click Build button.
|
||||
|
||||
Expected: args in "Additional CMake arguments" are used during build.
|
||||
|
||||
Actual:
|
||||
|
||||
Configuring in: C:\Users\betamax\cdt-only2\runtime-New_configuration(1)\helloworld\build\cmake.debug.win32.x86_64
|
||||
cmake -G Ninja -DVAR=TEST -DCMAKE_EXPORT_COMPILE_COMMANDS=ON C:\Users\betamax\cdt-only2\runtime-New_configuration(1)\helloworld
|
||||
-- The C compiler identification is GNU 11.2.0
|
||||
-- The CXX compiler identification is GNU 11.2.0
|
||||
-- Detecting C compiler ABI info
|
||||
-- Detecting C compiler ABI info - done
|
||||
-- Check for working C compiler: C:/msys64/mingw64/bin/cc.exe - skipped
|
||||
-- Detecting C compile features
|
||||
-- Detecting C compile features - done
|
||||
-- Detecting CXX compiler ABI info
|
||||
-- Detecting CXX compiler ABI info - done
|
||||
-- Check for working CXX compiler: C:/msys64/mingw64/bin/c++.exe - skipped
|
||||
-- Detecting CXX compile features
|
||||
-- Detecting CXX compile features - done
|
||||
-- Configuring done (2.4s)
|
||||
-- Generating done (0.0s)
|
||||
CMake Warning:
|
||||
Manually-specified variables were not used by the project:
|
||||
|
||||
VAR
|
||||
|
||||
|
||||
-- Build files have been written to: C:/Users/betamax/cdt-only2/runtime-New_configuration(1)/helloworld/build/cmake.debug.win32.x86_64
|
||||
Building in: C:\Users\betamax\cdt-only2\runtime-New_configuration(1)\helloworld\build\cmake.debug.win32.x86_64
|
||||
cmake --build . --target all
|
||||
[1/2] Building CXX object CMakeFiles/helloworld.dir/helloworld.cpp.obj
|
||||
[2/2] Linking CXX executable helloworld.exe
|
||||
Build complete (0 errors, 0 warnings): C:\Users\betamax\cdt-only2\runtime-New_configuration(1)\helloworld\build\cmake.debug.win32.x86_64
|
||||
|
||||
#### 3.2) CMake Settings > Use these settings=unchecked, Additional CMake arguments are NOT used during build
|
||||
* Make sure Launch Bar Launch Mode still set to Debug.
|
||||
* Set CMake Settings > "Use these settings" to unchecked.
|
||||
* On the Launch Bar, click Build button.
|
||||
|
||||
Expected: args in "Additional CMake arguments" are NOT used during build.
|
||||
|
||||
Actual:
|
||||
|
||||
Configuring in: C:\Users\betamax\cdt-only2\runtime-New_configuration(1)\helloworld\build\cmake.debug.win32.x86_64
|
||||
cmake -G MinGW Makefiles -DCMAKE_EXPORT_COMPILE_COMMANDS=ON C:\Users\betamax\cdt-only2\runtime-New_configuration(1)\helloworld
|
||||
-- The C compiler identification is GNU 11.2.0
|
||||
-- The CXX compiler identification is GNU 11.2.0
|
||||
-- Detecting C compiler ABI info
|
||||
-- Detecting C compiler ABI info - done
|
||||
-- Check for working C compiler: C:/msys64/mingw64/bin/cc.exe - skipped
|
||||
-- Detecting C compile features
|
||||
-- Detecting C compile features - done
|
||||
-- Detecting CXX compiler ABI info
|
||||
-- Detecting CXX compiler ABI info - done
|
||||
-- Check for working CXX compiler: C:/msys64/mingw64/bin/c++.exe - skipped
|
||||
-- Detecting CXX compile features
|
||||
-- Detecting CXX compile features - done
|
||||
-- Configuring done (2.5s)
|
||||
-- Generating done (0.0s)
|
||||
-- Build files have been written to: C:/Users/betamax/cdt-only2/runtime-New_configuration(1)/helloworld/build/cmake.debug.win32.x86_64
|
||||
Building in: C:\Users\betamax\cdt-only2\runtime-New_configuration(1)\helloworld\build\cmake.debug.win32.x86_64
|
||||
cmake --build . --target all
|
||||
[ 50%] Building CXX object CMakeFiles/helloworld.dir/helloworld.cpp.obj
|
||||
[100%] Linking CXX executable helloworld.exe
|
||||
[100%] Built target helloworld
|
||||
Build complete (0 errors, 0 warnings): C:\Users\betamax\cdt-only2\runtime-New_configuration(1)\helloworld\build\cmake.debug.win32.x86_64
|
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
|||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: %pluginName
|
||||
Bundle-SymbolicName: org.eclipse.cdt.cmake.ui;singleton:=true
|
||||
Bundle-Version: 1.4.300.qualifier
|
||||
Bundle-Version: 1.4.400.qualifier
|
||||
Bundle-Activator: org.eclipse.cdt.cmake.ui.internal.Activator
|
||||
Bundle-Vendor: %providerName
|
||||
Require-Bundle: org.eclipse.core.runtime,
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.cmake.ui.internal;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.cmake.core.internal.CMakeBuildConfiguration;
|
||||
|
@ -32,11 +33,20 @@ import org.eclipse.swt.widgets.Text;
|
|||
|
||||
public class CMakeBuildTab extends CommonBuildTab {
|
||||
|
||||
/**
|
||||
* Checkbox allowing user to choose these settings over the default operating system defaults.
|
||||
* This is connected to the CMakeBuildConfiguration.CMAKE_USE_UI_OVERRIDES preference.
|
||||
*/
|
||||
private Button useUiCmakeSettings;
|
||||
private Button unixGenButton;
|
||||
private Button ninjaGenButton;
|
||||
private Text cmakeArgsText;
|
||||
private Text buildCommandText;
|
||||
private Text cleanCommandText;
|
||||
private Label generatorLabel;
|
||||
private Label cmakeArgsLabel;
|
||||
private Label buildCommandLabel;
|
||||
private Label cleanCommandLabel;
|
||||
|
||||
@Override
|
||||
protected String getBuildConfigProviderId() {
|
||||
|
@ -57,8 +67,19 @@ public class CMakeBuildTab extends CommonBuildTab {
|
|||
cmakeGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
||||
cmakeGroup.setLayout(new GridLayout());
|
||||
|
||||
Label label = new Label(cmakeGroup, SWT.NONE);
|
||||
label.setText(Messages.CMakeBuildTab_Generator);
|
||||
useUiCmakeSettings = new Button(cmakeGroup, SWT.CHECK);
|
||||
useUiCmakeSettings.setText(Messages.CMakeBuildTab_useUICmakeSettings);
|
||||
useUiCmakeSettings.setToolTipText(Messages.CMakeBuildTab_useUICmakeSettingsTip);
|
||||
useUiCmakeSettings.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
updateEnablement();
|
||||
updateLaunchConfigurationDialog();
|
||||
}
|
||||
});
|
||||
|
||||
generatorLabel = new Label(cmakeGroup, SWT.NONE);
|
||||
generatorLabel.setText(Messages.CMakeBuildTab_Generator);
|
||||
|
||||
Composite genComp = new Composite(cmakeGroup, SWT.BORDER);
|
||||
genComp.setLayout(new GridLayout(2, true));
|
||||
|
@ -81,31 +102,50 @@ public class CMakeBuildTab extends CommonBuildTab {
|
|||
}
|
||||
});
|
||||
|
||||
label = new Label(cmakeGroup, SWT.NONE);
|
||||
label.setText(Messages.CMakeBuildTab_CMakeArgs);
|
||||
cmakeArgsLabel = new Label(cmakeGroup, SWT.NONE);
|
||||
cmakeArgsLabel.setText(Messages.CMakeBuildTab_CMakeArgs);
|
||||
|
||||
cmakeArgsText = new Text(cmakeGroup, SWT.BORDER);
|
||||
cmakeArgsText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
|
||||
cmakeArgsText.addModifyListener(e -> updateLaunchConfigurationDialog());
|
||||
|
||||
label = new Label(cmakeGroup, SWT.NONE);
|
||||
label.setText(Messages.CMakeBuildTab_BuildCommand);
|
||||
buildCommandLabel = new Label(cmakeGroup, SWT.NONE);
|
||||
buildCommandLabel.setText(Messages.CMakeBuildTab_BuildCommand);
|
||||
|
||||
buildCommandText = new Text(cmakeGroup, SWT.BORDER);
|
||||
buildCommandText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
|
||||
buildCommandText.addModifyListener(e -> updateLaunchConfigurationDialog());
|
||||
|
||||
label = new Label(cmakeGroup, SWT.NONE);
|
||||
label.setText(Messages.CMakeBuildTab_CleanCommand);
|
||||
cleanCommandLabel = new Label(cmakeGroup, SWT.NONE);
|
||||
cleanCommandLabel.setText(Messages.CMakeBuildTab_CleanCommand);
|
||||
|
||||
cleanCommandText = new Text(cmakeGroup, SWT.BORDER);
|
||||
cleanCommandText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
|
||||
cleanCommandText.addModifyListener(e -> updateLaunchConfigurationDialog());
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the enabled state of the CMake settings controls based on useUiCmakeSettings checkbox
|
||||
*/
|
||||
private void updateEnablement() {
|
||||
boolean isSelected = useUiCmakeSettings.getSelection();
|
||||
generatorLabel.setEnabled(isSelected);
|
||||
unixGenButton.setEnabled(isSelected);
|
||||
ninjaGenButton.setEnabled(isSelected);
|
||||
cmakeArgsLabel.setEnabled(isSelected);
|
||||
cmakeArgsText.setEnabled(isSelected);
|
||||
buildCommandLabel.setEnabled(isSelected);
|
||||
buildCommandText.setEnabled(isSelected);
|
||||
cleanCommandLabel.setEnabled(isSelected);
|
||||
cleanCommandText.setEnabled(isSelected);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
|
||||
// TODO
|
||||
// Set defaults for Build Settings
|
||||
ICBuildConfiguration buildConfig = getBuildConfiguration();
|
||||
buildConfig.setProperty(CMakeBuildConfiguration.CMAKE_USE_UI_OVERRIDES,
|
||||
Boolean.toString(CMakeBuildConfiguration.CMAKE_USE_UI_OVERRIDES_DEFAULT));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -133,10 +173,14 @@ public class CMakeBuildTab extends CommonBuildTab {
|
|||
|
||||
String cleanCommand = buildConfig.getProperty(CMakeBuildConfiguration.CLEAN_COMMAND);
|
||||
if (cleanCommand != null) {
|
||||
cleanCommandText.setText(buildCommand);
|
||||
cleanCommandText.setText(cleanCommand);
|
||||
} else {
|
||||
cleanCommandText.setText(""); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
boolean isSelected = Boolean.valueOf(buildConfig.getProperty(CMakeBuildConfiguration.CMAKE_USE_UI_OVERRIDES));
|
||||
useUiCmakeSettings.setSelection(isSelected);
|
||||
updateEnablement();
|
||||
}
|
||||
|
||||
private void updateGeneratorButtons(String generator) {
|
||||
|
@ -153,8 +197,8 @@ public class CMakeBuildTab extends CommonBuildTab {
|
|||
|
||||
ICBuildConfiguration buildConfig = getBuildConfiguration();
|
||||
|
||||
buildConfig.setProperty(CMakeBuildConfiguration.CMAKE_GENERATOR,
|
||||
ninjaGenButton.getSelection() ? "Ninja" : "Unix Makefiles"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
String gen = ninjaGenButton.getSelection() ? "Ninja" : "Unix Makefiles"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
buildConfig.setProperty(CMakeBuildConfiguration.CMAKE_GENERATOR, gen);
|
||||
|
||||
String cmakeArgs = cmakeArgsText.getText().trim();
|
||||
if (!cmakeArgs.isEmpty()) {
|
||||
|
@ -176,6 +220,13 @@ public class CMakeBuildTab extends CommonBuildTab {
|
|||
} else {
|
||||
buildConfig.removeProperty(CMakeBuildConfiguration.CLEAN_COMMAND);
|
||||
}
|
||||
|
||||
boolean isSelected = useUiCmakeSettings.getSelection();
|
||||
buildConfig.setProperty(CMakeBuildConfiguration.CMAKE_USE_UI_OVERRIDES, Boolean.toString(isSelected));
|
||||
|
||||
Map<String, String> saved = new HashMap<>();
|
||||
saved.put(CMakeBuildConfiguration.CMAKE_USE_UI_OVERRIDES, Boolean.toString(isSelected));
|
||||
getBuildConfiguration().setProperties(saved);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -24,6 +24,8 @@ public class Messages extends NLS {
|
|||
public static String CMakeBuildTab_Settings;
|
||||
public static String CMakeBuildTab_Toolchain;
|
||||
public static String CMakeBuildTab_UnixMakefiles;
|
||||
public static String CMakeBuildTab_useUICmakeSettings;
|
||||
public static String CMakeBuildTab_useUICmakeSettingsTip;
|
||||
public static String CMakePreferencePage_Add;
|
||||
public static String CMakePreferencePage_ConfirmRemoveDesc;
|
||||
public static String CMakePreferencePage_ConfirmRemoveTitle;
|
||||
|
|
|
@ -8,6 +8,8 @@ CMakeBuildTab_NoneAvailable=No Toolchains Available for this Target
|
|||
CMakeBuildTab_Settings=CMake Settings
|
||||
CMakeBuildTab_Toolchain=Toolchain
|
||||
CMakeBuildTab_UnixMakefiles=Unix Makefiles
|
||||
CMakeBuildTab_useUICmakeSettings=Use these settings
|
||||
CMakeBuildTab_useUICmakeSettingsTip=Use these settings instead of the operating system defaults
|
||||
CMakePreferencePage_Add=Add...
|
||||
CMakePreferencePage_ConfirmRemoveDesc=Do you wish to deregister the selected files?
|
||||
CMakePreferencePage_ConfirmRemoveTitle=Deregister CMake ToolChain File
|
||||
|
|
Loading…
Add table
Reference in a new issue