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

CMakeLists.txt Use CMakePresets instead of CMakeSettings #3730

Merged
merged 19 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"version": 6,
"cmakeMinimumRequired": {
"major": 3,
"minor": 26,
"patch": 0
},
"configurePresets": [
{
"name": "base",
"hidden": true,
"generator": "Ninja",
"binaryDir": "${sourceDir}/out/${presetName}",
"architecture": {
"strategy": "external",
"value": "${presetName}"
}
},
{
"name": "x86",
"inherits": "base",
"description": "x86 Ninja Config"
},
{
"name": "x64",
"inherits": "base",
"description": "x64 Ninja Config"
},
{
"name": "ARM",
"inherits": "base",
"description": "ARM Ninja Config",
"cacheVariables": {
"TESTS_BUILD_ONLY": true
}
},
{
"name": "ARM64",
"inherits": "base",
"description": "ARM64 Ninja Config",
"cacheVariables": {
"TESTS_BUILD_ONLY": true
}
}
],
"buildPresets": [
{
"name": "x86",
"configurePreset": "x86",
"description": "Build x86 STL"
},
{
"name": "x64",
"configurePreset": "x64",
"description": "Build x64 STL"
},
{
"name": "ARM",
"configurePreset": "ARM",
"description": "Build ARM STL"
},
{
"name": "ARM64",
"configurePreset": "ARM64",
"description": "Build ARM64 STL"
}
]
}
52 changes: 0 additions & 52 deletions CMakeSettings.json

This file was deleted.

42 changes: 21 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ Just try to follow these rules, so we can spend more time fixing bugs and implem
3. Open a terminal in the IDE with `` Ctrl + ` `` (by default) or press on "View" in the top bar, and then "Terminal".
4. In the terminal, invoke `git submodule update --init --progress`
5. Choose the architecture you wish to build in the IDE, and build as you would any other project. All necessary CMake
settings are set by `CMakeSettings.json`.
settings are set by `CMakePresets.json`.

# How To Build With A Native Tools Command Prompt

Expand All @@ -172,21 +172,21 @@ To build the x86 target:

1. Open an "x86 Native Tools Command Prompt for VS 2022 Preview".
2. Change directories to the previously cloned `STL` directory.
3. `cmake -G Ninja -S . -B out\build\x86`
4. `ninja -C out\build\x86`
3. `cmake --preset x86`
4. `cmake --build --preset x86`

To build the x64 target (recommended):

1. Open an "x64 Native Tools Command Prompt for VS 2022 Preview".
2. Change directories to the previously cloned `STL` directory.
3. `cmake -G Ninja -S . -B out\build\x64`
4. `ninja -C out\build\x64`
3. `cmake --preset x64`
4. `cmake --build --preset x64`

# How To Consume

Consumption of the built library is largely based on the build system you're using. There are at least 2 directories
you need to hook up. Assuming you built the x64 target with the Visual Studio IDE, with the STL repository cloned to
`C:\Dev\STL`, build outputs will end up at `C:\Dev\STL\out\build\x64\out`. Ensure that the `inc` directory is searched
`C:\Dev\STL`, build outputs will end up at `C:\Dev\STL\out\x64\out`. Ensure that the `inc` directory is searched
for headers, and that `lib\{architecture}` is searched for link libraries, before any defaults supplied by MSVC. The
names of the import and static libraries are the same as those that ship with MSVC. As a result, the compiler `/MD`,
`/MDd`, `/MT`, or `/MTd` switches will work without modification of your build scripts or command-line muscle memory.
Expand All @@ -210,7 +210,7 @@ variables to ensure that the built headers and libraries are used.
From an "x64 Native Tools Command Prompt for VS 2022 Preview":

```
C:\Users\username\Desktop>C:\Dev\STL\out\build\x64\set_environment.bat
C:\Users\username\Desktop>C:\Dev\STL\out\x64\set_environment.bat

C:\Users\username\Desktop>type example.cpp
#include <iostream>
Expand Down Expand Up @@ -253,7 +253,7 @@ under a category in libcxx, or running a single test in `std` and `tr1`.

## Examples

These examples assume that your current directory is `C:\Dev\STL\out\build\x64`.
These examples assume that your current directory is `C:\Dev\STL\out\x64`.

* This command will run all of the test suites with verbose output.
+ `ctest -V`
Expand Down Expand Up @@ -368,8 +368,8 @@ steps. Let's assume we want to debug a new feature with tests located in `tests\

As always, build the STL from your branch and run the tests:
```
C:\STL\out\build\x64> ninja
C:\STL\out\build\x64> python tests\utils\stl-lit\stl-lit.py -v C:\STL\tests\std\tests\GH_XXXX_meow
C:\STL\out\x64> ninja
C:\STL\out\x64> python tests\utils\stl-lit\stl-lit.py -v C:\STL\tests\std\tests\GH_XXXX_meow
```

Let's assume one of the tests fails an assert and we want to debug that configuration. `stl-lit` will conveniently print
Expand All @@ -379,14 +379,14 @@ provide debug symbols: `/Zi /Fdbark.pdb`.
You can replace `bark` with any descriptive name you like. Add these before the `"-link"` option in the command line
and recompile. Example:
```
C:\STL\out\build\x64>cl "C:\STL\tests\std\tests\GH_XXXX_meow\test.cpp" [... more arguments ...]
"-FeC:\STL\out\build\x64\tests\std\tests\GH_XXXX_meow\Output\02\GH_XXXX_meow.exe" /Zi /Fdbark.pdb "-link"
C:\STL\out\x64>cl "C:\STL\tests\std\tests\GH_XXXX_meow\test.cpp" [... more arguments ...]
"-FeC:\STL\out\x64\tests\std\tests\GH_XXXX_meow\Output\02\GH_XXXX_meow.exe" /Zi /Fdbark.pdb "-link"
[... more arguments ...]
```

You can now start debugging the test via:
```
devenv "C:\STL\out\build\x64\tests\std\tests\GH_XXXX_meow\Output\02\GH_XXXX_meow.exe"
devenv "C:\STL\out\x64\tests\std\tests\GH_XXXX_meow\Output\02\GH_XXXX_meow.exe"
"C:\STL\tests\std\tests\GH_XXXX_meow\test.cpp"
```

Expand All @@ -395,7 +395,7 @@ is that the STL builds those and other DLLs itself and we should under no circum
If you are testing one of the configurations with dynamic linkage (`/MD` or `/MDd`) the easiest solution is to add the
build folder to your path:
```
set PATH=C:\STL\out\build\x64\out\bin\amd64;%PATH%
set PATH=C:\STL\out\x64\out\bin\amd64;%PATH%
```

# Benchmarking
Expand All @@ -416,28 +416,28 @@ for how _we_ use it.
To run benchmarks, you'll need to first build the STL, then build the benchmarks:

```cmd
cmake -B out\x64 -S . -G Ninja
cmake --build out\x64
cmake -B out\benchmark -S benchmarks -G Ninja -DSTL_BINARY_DIR=out\x64
cmake --build out\benchmark
cmake --preset x64
cmake --build --preset x64
cmake -B out\bench -S benchmarks -G Ninja -DSTL_BINARY_DIR=out\x64
cmake --build out\bench
```

You can then run your benchmark with:

```cmd
out\benchmark\benchmark-<benchmark-name> --benchmark_out=<file> --benchmark_out_format=csv
out\bench\benchmark-<benchmark-name> --benchmark_out=<file> --benchmark_out_format=csv
```

And then you can copy this CSV file into Excel, or another spreadsheet program. For example:

```cmd
out\bench\benchmarks\benchmark-std_copy --benchmark_out=benchmark-std_copy-results.csv --benchmark_out_format=csv
out\bench\benchmark-std_copy --benchmark_out=benchmark-std_copy-results.csv --benchmark_out_format=csv
```

If you want to see all the other flags you can pass, run:

```cmd
out\bench\benchmarks\benchmark-<benchmark-name> --help
out\bench\benchmark-<benchmark-name> --help
```

# Editing And Testing The Debugger Visualizer
Expand Down