Questions tagged [cmake-presets]

CMake presets are a configuration mechanism for composing and using common presets for CMake configurations. Presets can be written for common configuration, build, test, and packaging configurations. Preset configurations of each type can be composed via inheritence and used from the commandline.

The official documentation for CMake Presets can be found here.

20 questions
5
votes
2 answers

CMakePresets.json vs CMakeSettings.json vs CMakeLists.txt

I've googled around a bit but I've not found anything really satisfactory. There are a lot of tutorials on how to use them, but I'm struggling to understand which one best fits a particular project. It's not very clear to me, for each of them, what…
Buzz
  • 1,102
  • 1
  • 9
  • 24
4
votes
0 answers

How to specify default values for environment variables in CMakePresets

When using CMakePresets.json the documentation states that I can use either $env{} or $penv{} to query environment variables. Is it possible to specify a default value in case the environment variable is not…
cbandera
  • 105
  • 9
2
votes
1 answer

Merge and/or Override flags of different configure presets in CMakePresets.json

I have two configure presets in my CMakePresets.json were I would like to merge the flags of the inherit configurePresets (gcc) with the other preset (gcc-arm-embedded) Here is a simplified version: "configurePresets": [ { "name":…
Viatorus
  • 1,804
  • 1
  • 18
  • 41
2
votes
1 answer

Visual Studio 2022 CMake Presets

I'm using CMake in my project and I'm beginning to explore the possibilities of CMakePresets I managed to create a default windows preset. Currently my Windows default preset sets the CMAKE_BUILD_TYPE to debug. now I'd like to select the config in…
JHeni
  • 455
  • 3
  • 12
1
vote
1 answer

How to specify CMake Preset for subdirectories?

I have a big library with a lot of options that I recently converted to CMake from make, with a lot of options. I use configuration presets to have multiple profiles. The library is developed by my team, while the applications building over it are…
Shady Atef
  • 2,121
  • 1
  • 22
  • 40
1
vote
0 answers

When using CMakePresets.json, what is the equivalent of remotePreGenerateCommand?

I am trying to switch from CMakeSettings.json to CMakePresets.json in a Visual Studio CMake project targetting Linux. In my current CMakeSettings.json, I used to activate a Conda environment before generating the CMake cache on remote systems…
Samuel
  • 131
  • 1
  • 5
1
vote
1 answer

Using CMake compile flags in preset for non-external projects only

I am adding a few external projects to my application. For instance, gtest. In my CMake preset I set the following... { "version": 4, "cmakeMinimumRequired": { "major": 3, "minor": 23, "patch": 0 }, …
Heng Beng
  • 23
  • 4
0
votes
0 answers

Is any way to split long string in CMakePresets.json?

I have so long LIB and PATH variables in configurations, is any way to split them for readability ?
Anton
  • 79
  • 4
0
votes
1 answer

CMake skips fetching directory with FetchContent when output directory is changed

Trying to configure a multi repository project with CMake. Project A is an graphical application which uses Project B for all hardware related details and code. Project B is a device controller / HAL layer. When CMake is configuring it should fetch…
0
votes
0 answers

CMakePresets: How can I add command line arguments to the cmake build?

I have a CMakeLists.txt in combination with CMakePresets.json, Visual Studio 2022 and the generator ninja. Running the build command in Visual Studio 2022 executes cmake --build --preset Release My goal is that running the build command in Visual…
0
votes
0 answers

problem of visibility with cmake-presets inheritance

cmake-presets supports inheritance. That is nice, providing that the parent preset is visible, but not work otherwise. Taking for example with preset1.json: { "version": 5, "configurePresets": [ { "name": "base_preset" …
kstn
  • 537
  • 4
  • 14
0
votes
0 answers

Is it possible to choose default cmake preset configuration from the vscode devcontainer

I have two devcontainers defined for my c++ project, one for gcc and one for clang, each based on a different container source. The clang container is defined so // For format details, see https://aka.ms/devcontainer.json. For config options, see…
bradgonesurfing
  • 30,949
  • 17
  • 114
  • 217
0
votes
0 answers

CMakePresets.json: Using (env-)variable in Visual Studio Remote Settings vendor map

A few weeks ago, we introduced the introduce the cmakepresets.json to our cpp cross platform project, which we code with Visual Studio. The setup was really straight forward and we are able to build and debug our project without any problems. There…
0
votes
1 answer

How to determine architecture in CMake using Ninja in CLion

I have a simple CMake project which uses CMakePresets.json to set up common settings and Ninja as its underlying build system to compile a C++ program. The problem that I'm facing right now is in CLion where it always picks x86 architecture by…
Nima Ghorab
  • 309
  • 1
  • 3
  • 13
0
votes
1 answer

How to get path to the compiler libs from the CmakeLists.txt using presets?

I use cmake 3.22 and presets to configure and build my project. I have a few presets for different compilers defined like below. How can I get the compiler libraries dir in the CMakeLists.txt file? I can get ${CMAKE_CXX_COMPILER} - full path to the…
Hardwired
  • 804
  • 1
  • 8
  • 19
1
2