Skip to content
Snippets Groups Projects
Unverified Commit a80907c3 authored by Tim Kaune's avatar Tim Kaune
Browse files

Remove choice of generator from project presets

Move it to the user presets instead.
parent 58a09b64
Branches
Tags
No related merge requests found
......@@ -15,4 +15,6 @@ jobs:
ninja --version
- uses: actions/checkout@v4
- name: build-and-test
run: cmake --workflow --preset ci-ninja
run: |
cp "./CMakeUserPresets.template.json" "./CMakeUserPresets.json"
cmake --workflow --preset user-test
......@@ -5,165 +5,85 @@
"minor": 25,
"patch": 0
},
"include": [
"./CMakePresetsCommon.json"
],
"configurePresets": [
{
"name": "default",
"name": "config",
"hidden": true,
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_INSTALL_PREFIX": "${sourceDir}/install"
},
"warnings": {
"dev": false
}
},
{
"name": "ninja",
"inherits": [
"default"
],
"generator": "Ninja",
"displayName": "Default Build Configuration using Ninja"
},
{
"name": "make",
"name": "default",
"inherits": [
"default"
"install",
"config"
],
"generator": "Unix Makefiles",
"displayName": "Default Build Configuration using Makefiles"
"displayName": "Default Build Configuration"
}
],
"buildPresets": [
{
"name": "verbose",
"hidden": true,
"verbose": true
},
{
"name": "ninja",
"name": "default",
"inherits": [
"verbose"
],
"displayName": "Default Build using Ninja",
"configurePreset": "ninja"
"displayName": "Default Build",
"configurePreset": "default"
},
{
"name": "ninja-install",
"name": "default-install",
"inherits": [
"ninja"
],
"displayName": "Default Build and Installation using Ninja",
"targets": [
"default",
"install"
]
},
{
"name": "make",
"inherits": [
"verbose"
],
"displayName": "Default Build using Make",
"configurePreset": "make"
},
{
"name": "make-install",
"inherits": [
"make"
],
"displayName": "Default Build and Installation using Make",
"targets": [
"install"
]
"displayName": "Default Build and Installation"
}
],
"testPresets": [
{
"name": "verbose",
"hidden": true,
"output": {
"verbosity": "verbose"
}
},
{
"name": "ninja",
"inherits": [
"verbose"
],
"displayName": "Default Test using Ninja",
"configurePreset": "ninja"
},
{
"name": "make",
"name": "default",
"inherits": [
"verbose"
],
"displayName": "Default Test using Make",
"configurePreset": "make"
"displayName": "Default Test",
"configurePreset": "default"
}
],
"workflowPresets": [
{
"name": "dev-ninja",
"displayName": "Developer Workflow using Ninja",
"steps": [
{
"type": "configure",
"name": "ninja"
},
{
"type": "build",
"name": "ninja-install"
}
]
},
{
"name": "ci-ninja",
"displayName": "CI Workflow using Ninja",
"name": "default",
"displayName": "Default Workflow",
"steps": [
{
"type": "configure",
"name": "ninja"
"name": "default"
},
{
"type": "build",
"name": "ninja"
"name": "default"
},
{
"type": "test",
"name": "ninja"
}
]
},
{
"name": "dev-make",
"displayName": "Developer Workflow using Make",
"steps": [
{
"type": "configure",
"name": "make"
},
{
"type": "build",
"name": "make-install"
"name": "default"
}
]
},
{
"name": "ci-make",
"displayName": "CI Workflow using Make",
"name": "default-install",
"displayName": "Install Workflow",
"steps": [
{
"type": "configure",
"name": "make"
"name": "default"
},
{
"type": "build",
"name": "make"
},
{
"type": "test",
"name": "make"
"name": "default-install"
}
]
}
......
{
"version": 6,
"cmakeMinimumRequired": {
"major": 3,
"minor": 25,
"patch": 0
},
"configurePresets": [
{
"name": "install",
"hidden": true,
"cacheVariables": {
"CMAKE_INSTALL_PREFIX": "${sourceDir}/install"
}
},
{
"name": "ninja",
"hidden": true,
"generator": "Ninja"
},
{
"name": "make",
"hidden": true,
"generator": "Unix Makefiles"
}
],
"buildPresets": [
{
"name": "verbose",
"hidden": true,
"verbose": true
},
{
"name": "install",
"hidden": true,
"targets": [
"install"
]
}
],
"testPresets": [
{
"name": "verbose",
"hidden": true,
"output": {
"verbosity": "verbose"
}
}
]
}
{
"version": 6,
"include": [
"./CMakePresets.json"
],
"configurePresets": [
{
"name": "user-config",
"hidden": true,
"cacheVariables": {
}
},
{
"name": "user-default",
"inherits": [
"user-config",
"ninja",
"default"
],
"displayName": "User Build Configuration"
}
],
"buildPresets": [
{
"name": "user-default",
"inherits": [
"default"
],
"displayName": "User Build",
"configurePreset": "user-default"
},
{
"name": "user-default-install",
"inherits": [
"user-default",
"default-install"
],
"displayName": "User Build and Installation"
}
],
"testPresets": [
{
"name": "user-default",
"inherits": [
"default"
],
"displayName": "User Test",
"configurePreset": "user-default"
}
],
"workflowPresets": [
{
"name": "user-default",
"displayName": "User Default Workflow",
"steps": [
{
"type": "configure",
"name": "user-default"
},
{
"type": "build",
"name": "user-default"
}
]
},
{
"name": "user-install",
"displayName": "User Install Workflow",
"steps": [
{
"type": "configure",
"name": "user-default"
},
{
"type": "build",
"name": "user-default-install"
}
]
},
{
"name": "user-test",
"displayName": "User Test Workflow",
"steps": [
{
"type": "configure",
"name": "user-default"
},
{
"type": "build",
"name": "user-default"
},
{
"type": "test",
"name": "user-default"
}
]
}
]
}
......@@ -87,34 +87,28 @@ process.
1. Clone the git repository or download the source code archive and unpack it to
an arbitrary directory (e.g. `load-static-shared-targets`).
2. Go to this directory and type `cmake --workflow --list-presets`. A list of
available build workflows will be shown to you.
3. For configuring, building and installing the project, type `cmake --workflow
--preset dev-ninja`. This will populate the `./build` directory with a CMake
2. Go to this directory and type `cp ./CMakeUserPresets.template.json
./CMakeUserPresets.json`.
3. Next, type `cmake --workflow --list-presets`. A list of available build
workflows will be shown to you.
4. For configuring, building and installing the project, type `cmake --workflow
--preset user-install`. This will populate the `./build` directory with a CMake
configuration tree, execute the build and install the project. By default,
the configured installation directory is `./install`.
4. For running the tests, type `cmake --workflow --preset ci-ninja`.
### How to customize the build from the command line ###
You can specify a different install location by setting the
`CMAKE_INSTALL_PREFIX` variable in the `"user-config"` preset in your
`./CMakeUserPresets.json`:
1. You can specify a different install location by using the configure preset
directly while setting the `CMAKE_INSTALL_PREFIX` variable:
```shell
$ cmake --preset ninja -D "CMAKE_INSTALL_PREFIX=/path/to/install/prefix"
```json
"cacheVariables": {
"CMAKE_INSTALL_PREFIX": "$env{HOME}/.local"
}
```
If the configured install prefix is a system-wide location (like
`/usr/local`), installing might require `sudo`.
2. Now, you can build manually with `cmake --build --preset ninja-install`. You
should see some informative terminal output.
### How to customize the build using user presets ###
Please refer to the [CMake Documentation about presets][1] for further details.
Create the file `./CMakeUserPresets.json` and build your own configure, build,
test or workflow presets by inheriting from the project's default presets.
Please refer to the [CMake Documentation about presets][1] for details.
5. For running the tests, type `cmake --workflow --preset user-test`.
[1]: https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment