diff --git a/.gitignore b/.gitignore index 37e27bfed..047a24c70 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ ## Editors and development environments *~ +.cmake +CMakeUserPresets.json +Testing/* *.swp *.bak* *.orig @@ -26,7 +29,8 @@ gtags.files # Codelite *.project # Visual Studio Code & plugins -.vscode/ +.vscode/* +!.vscode/extensions.json build/.cmake/ # Fleet .fleet @@ -107,7 +111,10 @@ src/cmake_config_githash.h *.iml test_config.h cmake-build-debug/ +cmake-build-minsizerel/ cmake-build-release/ +cmake-build-relwithdebinfo/ +cmake-build-default/ cmake_config.h cmake_config_githash.h CMakeDoxy* diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 000000000..fd9b2c09b --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "ms-vscode.cpptools-extension-pack" + ] +} \ No newline at end of file diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 000000000..d1e6a4037 --- /dev/null +++ b/CMakePresets.json @@ -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" + } + } + ] +} diff --git a/doc/ides/images/jetbrains_cmake_profiles.png b/doc/ides/images/jetbrains_cmake_profiles.png new file mode 100644 index 000000000..f0e969a6b Binary files /dev/null and b/doc/ides/images/jetbrains_cmake_profiles.png differ diff --git a/doc/ides/images/jetbrains_ide.png b/doc/ides/images/jetbrains_ide.png new file mode 100644 index 000000000..8b9b11c0f Binary files /dev/null and b/doc/ides/images/jetbrains_ide.png differ diff --git a/doc/ides/images/jetbrains_notification_profiles.png b/doc/ides/images/jetbrains_notification_profiles.png new file mode 100644 index 000000000..8aeb13073 Binary files /dev/null and b/doc/ides/images/jetbrains_notification_profiles.png differ diff --git a/doc/ides/images/jetbrains_open_project_wizard_profiles.png b/doc/ides/images/jetbrains_open_project_wizard_profiles.png new file mode 100644 index 000000000..dafc2c0c4 Binary files /dev/null and b/doc/ides/images/jetbrains_open_project_wizard_profiles.png differ diff --git a/doc/ides/images/jetbrains_open_project_wizard_windows_cmake.png b/doc/ides/images/jetbrains_open_project_wizard_windows_cmake.png new file mode 100644 index 000000000..2366908ec Binary files /dev/null and b/doc/ides/images/jetbrains_open_project_wizard_windows_cmake.png differ diff --git a/doc/ides/images/jetbrains_open_project_wizard_windows_compiler.png b/doc/ides/images/jetbrains_open_project_wizard_windows_compiler.png new file mode 100644 index 000000000..928e0788f Binary files /dev/null and b/doc/ides/images/jetbrains_open_project_wizard_windows_compiler.png differ diff --git a/doc/ides/images/jetbrains_vcpkg.png b/doc/ides/images/jetbrains_vcpkg.png new file mode 100644 index 000000000..31ab265ce Binary files /dev/null and b/doc/ides/images/jetbrains_vcpkg.png differ diff --git a/doc/ides/images/vscode_cmake_preset_selection.png b/doc/ides/images/vscode_cmake_preset_selection.png new file mode 100644 index 000000000..f73ede5be Binary files /dev/null and b/doc/ides/images/vscode_cmake_preset_selection.png differ diff --git a/doc/ides/images/vscode_toolbar.png b/doc/ides/images/vscode_toolbar.png new file mode 100644 index 000000000..13bfcbbde Binary files /dev/null and b/doc/ides/images/vscode_toolbar.png differ diff --git a/doc/ides/jetbrains.md b/doc/ides/jetbrains.md new file mode 100644 index 000000000..09a95b92f --- /dev/null +++ b/doc/ides/jetbrains.md @@ -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) + diff --git a/doc/ides/visual_studio.md b/doc/ides/visual_studio.md new file mode 100644 index 000000000..a08a58ea2 --- /dev/null +++ b/doc/ides/visual_studio.md @@ -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`. diff --git a/doc/ides/vscode.md b/doc/ides/vscode.md new file mode 100644 index 000000000..6814a7a88 --- /dev/null +++ b/doc/ides/vscode.md @@ -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" + } +} +```