diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000000..31e064cebd --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,80 @@ +{ + "version": 5, + "cmakeMinimumRequired": { + "major": 3, + "minor": 26, + "patch": 0 + }, + "configurePresets": [ + { + "name": "base", + "hidden": true, + "generator": "Ninja", + "binaryDir": "${sourceDir}/out/${presetName}" + }, + { + "name": "x86", + "inherits": "base", + "description": "x86 Ninja Config", + "architecture": { + "strategy": "external", + "value": "x86" + } + }, + { + "name": "x64", + "inherits": "base", + "description": "x64 Ninja Config", + "architecture": { + "strategy": "external", + "value": "x64" + } + }, + { + "name": "ARM", + "inherits": "base", + "description": "ARM Ninja Config", + "architecture": { + "strategy": "external", + "value": "ARM" + }, + "cacheVariables": { + "TESTS_BUILD_ONLY": true + } + }, + { + "name": "ARM64", + "inherits": "base", + "description": "ARM64 Ninja Config", + "architecture": { + "strategy": "external", + "value": "ARM64" + }, + "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" + } + ] +} diff --git a/CMakeSettings.json b/CMakeSettings.json deleted file mode 100644 index f5c1dfff5c..0000000000 --- a/CMakeSettings.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "configurations": [ - { - "name": "x86", - "buildCommandArgs": "-v", - "buildRoot": "${projectDir}\\out\\build\\${name}", - "cmakeCommandArgs": "", - "configurationType": "Debug", - "ctestCommandArgs": "", - "generator": "Ninja", - "inheritEnvironments": [ "msvc_x86" ], - "installRoot": "${projectDir}\\out\\install\\${name}", - "variables": [] - }, - { - "name": "x64", - "buildCommandArgs": "-v", - "buildRoot": "${projectDir}\\out\\build\\${name}", - "cmakeCommandArgs": "", - "configurationType": "Debug", - "ctestCommandArgs": "", - "generator": "Ninja", - "inheritEnvironments": [ "msvc_x64_x64" ], - "installRoot": "${projectDir}\\out\\install\\${name}", - "variables": [] - }, - { - "name": "ARM", - "buildCommandArgs": "-v", - "buildRoot": "${projectDir}\\out\\build\\${name}", - "cmakeCommandArgs": "", - "configurationType": "Debug", - "ctestCommandArgs": "", - "generator": "Ninja", - "inheritEnvironments": [ "msvc_arm" ], - "installRoot": "${projectDir}\\out\\install\\${name}", - "variables": [] - }, - { - "name": "ARM64", - "buildCommandArgs": "-v", - "buildRoot": "${projectDir}\\out\\build\\${name}", - "cmakeCommandArgs": "", - "configurationType": "Debug", - "ctestCommandArgs": "", - "generator": "Ninja", - "inheritEnvironments": [ "msvc_arm64" ], - "installRoot": "${projectDir}\\out\\install\\${name}", - "variables": [] - } - ] -} diff --git a/README.md b/README.md index 4f699bd966..c898ffc531 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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. @@ -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 @@ -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` @@ -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 @@ -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" ``` @@ -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 @@ -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_out= --benchmark_out_format=csv +out\bench\benchmark- --benchmark_out= --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- --help +out\bench\benchmark- --help ``` # Editing And Testing The Debugger Visualizer