Add documentation for IDE developer setup (#13935)

This commit is contained in:
AFCMS 2024-05-26 14:28:12 +02:00 committed by GitHub
parent 728f643ea7
commit 82790b1556
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 193 additions and 1 deletions

9
.gitignore vendored

@ -1,5 +1,8 @@
## Editors and development environments ## Editors and development environments
*~ *~
.cmake
CMakeUserPresets.json
Testing/*
*.swp *.swp
*.bak* *.bak*
*.orig *.orig
@ -26,7 +29,8 @@ gtags.files
# Codelite # Codelite
*.project *.project
# Visual Studio Code & plugins # Visual Studio Code & plugins
.vscode/ .vscode/*
!.vscode/extensions.json
build/.cmake/ build/.cmake/
# Fleet # Fleet
.fleet .fleet
@ -107,7 +111,10 @@ src/cmake_config_githash.h
*.iml *.iml
test_config.h test_config.h
cmake-build-debug/ cmake-build-debug/
cmake-build-minsizerel/
cmake-build-release/ cmake-build-release/
cmake-build-relwithdebinfo/
cmake-build-default/
cmake_config.h cmake_config.h
cmake_config_githash.h cmake_config_githash.h
CMakeDoxy* CMakeDoxy*

5
.vscode/extensions.json vendored Normal file

@ -0,0 +1,5 @@
{
"recommendations": [
"ms-vscode.cpptools-extension-pack"
]
}

41
CMakePresets.json Normal file

@ -0,0 +1,41 @@
{
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 12
},
"configurePresets": [
{
"name": "Debug",
"displayName": "Debug",
"description": "Debug preset with debug symbols and no optimizations",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "Release",
"displayName": "Release",
"description": "Release preset with optimizations and no debug symbols",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "RelWithDebInfo",
"displayName": "RelWithDebInfo",
"description": "Release with debug symbols",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "MinSizeRel",
"displayName": "MinSizeRel",
"description": "Release with minimal code size",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "MinSizeRel"
}
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

81
doc/ides/jetbrains.md Normal file

@ -0,0 +1,81 @@
# [Jetbrains IntellIJ CLion](https://www.jetbrains.com/clion)
## Linux
When opening the folder for the first time, select `Open as CMake project` if the IDE ask you between Make and CMake.
The IDE will open the folder and display the open project wizard:
![Open Project Wizard](images/jetbrains_open_project_wizard_profiles.png)
CLion try to determine a base configuration, but Minetest define it's own presets for easier setup. So you need to
delete the `Debug` profile with the `-` sign and close the dialog.
You should notice a notification telling you 4 presets have been loaded in the bottom right corner.
![Notification Popup](images/jetbrains_notification_profiles.png)
Clicking on the `View` link or going to `Settings > Build, Execution, Deployment > CMake` you should get a window
similar to the Open Project Wizard, but with the readonly presets listed.
![CMake Profiles](images/jetbrains_cmake_profiles.png)
By default, none of the presets are enabled. You can select them and enable the ones you want. Keep in mind that
triggering the CMake project reload (VCS updates, config changes, etc) will reload all the enabled profiles, so unless
you need the other ones you can enable just `Debug` and `Release`.
If none of the availlable profiles fit your needs, you can create a `CMakeUserPresets.json` file, edit it by hand and
CLion will load the presets in this window. But the easiest solution is to create an editable copy of one of the availlable
presets with the `Copy` button icon.
After these steps you should get an IDE like this.
On the main toolbar at the top right, you have a dropdown for selecting the CMake profile to use for the build. You have another dropdown next to it to select the build target; by default the `minetest` executable will be selected, but you may also have to use `IrrlichtMt` for building just the library .
![Jetbrains IDE](images/jetbrains_ide.png)
You can rightclick the topbar to change the project icon and color, for fancier looking IDE.
## Windows
Under Windows, the recommended compiler is the [Visual Studio](https://visualstudio.microsoft.com) compiler.
From the Visual Studio installer, you need to install the `Desktop development with C++` Workload. CMake is already
bundled in CLion.
By default, CLion have a MinGW compiler bundled, so if you want to use Visual Studio, you need to configure it as the default compiler.
CLion may ask you in the open project wisard for your compilers, with MinGW and Visual Studio if you have installed it predefined. You can use the arrows to make `Visual Studio` the default.
If not you can go to `Settings > Build, Execution, Deployment > Toolchains` to change it.
![Jetbrains Open Project Wizard](images/jetbrains_open_project_wizard_windows_compiler.png)
Then, the process is roughly similar to Linux, you just need to pick `Visual Studio` as toolchain.
![Jetbrains Open Project Wizard](images/jetbrains_open_project_wizard_windows_cmake.png)
[Vcpkg](https://vcpkg.io) is the recommended way of installing Minetest dependencies.
You need to let CLion know about a `vcpkg` installation to let the bundled CMake use the dependencies seamlessly and get
IDE integration. (Require CLion 2023 or later)
Go to `View > Tool Windows > Vcpkg` and click the add button. I will open a popup allowing you to add a Vcpkg
installation. By default it will download a new one that you can use to install your dependencies, but if you already
have one installed or you do not plan on using CLion only then install Vcpkg by hand and select your installation
directory. Don't forget to check `Add vcpkg installation to existing CMake profiles`. If you haven't already installed
Minetest dependencies in your vcpkg installation, you can do it right from CLion's Vcpkg tool window.
![Jetbrains Vcpkg](images/jetbrains_vcpkg.png)
Reloading the CMake project (should happen automatically, or display a notification for outdated CMake project) will now
load the dependencies.
[More infos on Vcpkg integration in CLion](https://blog.jetbrains.com/clion/2023/01/support-for-vcpkg-in-clion)

@ -0,0 +1,7 @@
# [Visual Studio](https://visualstudio.microsoft.com)
From the Visual Studio installer, you need to install the `Desktop development with C++` Workload. You need to make sure the `C++ CMake tools for Windows` component is included in the installation details panel.
You need to install [Vcpkg](https://vcpkg.io) and install Minetest dependencies as stated in the compilation documentation.
For the packages to be discoverable and used by Visual Studio, you need to run `vcpkg integrate install`.

51
doc/ides/vscode.md Normal file

@ -0,0 +1,51 @@
# [Visual Studio Code](https://code.visualstudio.com)
VSCode suppport for C/C++ and CMake is provided by
the [Microsoft C/C++ extension pack](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools-extension-pack).
You can install it from the VSCode extensions tab.
If you use a unofficial VSCode distribution like [VSCodium](https://vscodium.com), you will need to install the
extension pack manually by downloading the VSIX files and going to `Extensions > ... > Install from VSIX`.
CMake support for VSCode uses CMake presets provided by the project by default.
When you open the Minetest folder with VSCode, you should get a quick pick asking you for the default preset.
![VSCode CMake Preset Selection](images/vscode_cmake_preset_selection.png)
You can use the bottom bar to change the CMake profile, change the build target, build, run and debug (running/debugging doesn't build first).
![VSCode Toolbar](images/vscode_toolbar.png)
Like most of the VSCode experience, it may be faster to use commands directly (most of the VSCode UI just trigger commands).
| Command Name | Usecase |
|----------------------------------|----------------------------------|
| `CMake: Select Configure Preset` | Change the current CMake profile |
| `CMake: Set Build Target` | Change the current build target |
| `CMake: Build` | Build current target |
| `CMake: Clean` | Clean build files |
| `CMake: Run Without Debugging` | Run selected run target |
| `CMake: Debug` | Debug selected run target |
## Windows
Under Windows, the recommended compiler is the [Visual Studio](https://visualstudio.microsoft.com) compiler.
From the Visual Studio installer, you need to install the `Desktop development with C++` Workload.
[Vcpkg](https://vcpkg.io) is the recommended way of installing Minetest dependencies.
Follow the official documentation to install it and install Minetest dependencies as explained in [Windows compilation process](../compiling/windows.md).
You need to let CMake know about the `vcpkg` installation in VSCode.
Modify your `.vscode/settings.json`:
```json
{
"cmake.configureSettings": {
"CMAKE_TOOLCHAIN_FILE": "C:/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake"
}
}
```