Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake-presets support #205

Open
ksrp1984 opened this issue Aug 7, 2024 · 4 comments
Open

cmake-presets support #205

ksrp1984 opened this issue Aug 7, 2024 · 4 comments

Comments

@ksrp1984
Copy link

ksrp1984 commented Aug 7, 2024

I created a CMakePresets.json file containing project configurations.
I can see the list of available configurations by adding --list-presets to Other CMake arguments
I can run a configuration by adding --preset MY_CONFIG_NAME
But I can't run --build --presets and --workflow --presets.

Cmake4Eclipse adds first: -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_RULE_MESSAGES:BOOL=OFF -G "Unix Makefiles".
Cmake throws an error. Cmake expects --workflow --presets to be the first argument.

The first step would be to add the ability to run cmake with its own parameters, without adding additional arguments. I think it's not difficult to implement.

The second step would be to load configurations from CMakePresets.json. This is more complicated. I'm not sure it's possible.
But the first step would be enough. Configurations with --preset can be created manually.

CMakePresets.json is very useful when the project is distributed, and a user who does not use Eclipse can build it from the command line, or in another IDE supporting Cmake (VS, QTCreator...)

@15knots
Copy link
Owner

15knots commented Aug 20, 2024

Which version of cmake are you running?
My version is 3.20.4 which does not support the --workflow option.

Anyway: Adding an option like --build or any other option that makes cmake to behave like a native build tool (e.g. make) is a bad idea since it will build the project twice: Once by cmake and once by CDT's builder.
cmake4eclipse uses cmake to generate the build scripts, building is done by CDT's builder.

@ksrp1984
Copy link
Author

Which version of cmake are you running? My version is 3.20.4 which does not support the --workflow option.

I am using cmake 3.28.
I use cmake 3.28. I was able to set up a configuration by сmake --preset and build by CDT. But on Linux for some reason there is no access to the Eclipse environment variables (${ConfigName}). On Windows it works, and you can pass the CDT configuration name in cmake --preset. On Linux you need to specify the configuration name twice - in Configurations Manager and in Other Cmake Arguments
image
Maybe this is a CDT problem and not a plugin problem

@ksrp1984
Copy link
Author

ksrp1984 commented Aug 21, 2024

Another problem: the plugin does not add include directories if there are no source files inside the project (Even if link directories are created).
We use the project only for building, all source files in separate directories. A workaround is to add fake.c to the root of the project, but this is a bad way

@kuch3n
Copy link

kuch3n commented Sep 10, 2024

It loooks like VSCode is parsing the preset file to gather settings from the presets and call CMake directly with those settings. Maybe it's the sanest way of using presets.

Some Ideas:

  • Build presets could be used as build configurations within Eclipse
  • Targets which can be used to auto fill build targets
  • Cache variables for CMake cache entries dialog
  • Per build preset/configuration CMake to, e.g., cross compile with a native CMake and run UnitTests with Cygwin
  • etc.

IMHO supporting presets may lead to a refactoring of the whole plugin, as everything can change depending on choosen preset, which also changes how GUI dialogs expose settings (readonly?).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants