diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index db0cc8da7..cdd237320 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -123,8 +123,6 @@ jobs: run: | set -eux - touch CMakePresets.json - JA2Application=$(echo '${{ matrix.application }}' | tr '[:lower:]' '[:upper:]') echo " diff --git a/.gitignore b/.gitignore index 6466f05cb..a4aee5531 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,6 @@ /.vs/ /build/ /out/ -/CMakePresets.json +/CMakeUserPresets.json /CMakeSettings.json /lib/ diff --git a/CMakeLists.txt b/CMakeLists.txt index ede067867..227b660e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,9 +18,6 @@ if(USE_SCCACHE) endif() endif() -include(cmake/CopyUserPresetTemplate.cmake) -CopyUserPresetTemplate() - set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 000000000..068236716 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,61 @@ +{ + "version": 3, + "cmakeMinimumRequired": { + "major": 3, + "minor": 20, + "patch": 0 + }, + "configurePresets": [ + { + "name": "base", + "hidden": true, + "description": "Applications is JA2|JA2MAPEDITOR|JA2UB|JA2UBMAPEDITOR|empty(all 4); override CMAKE_RUNTIME_OUTPUT_DIRECTORY in CMakeUserPresets.json to debug another install.", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build/${presetName}", + "architecture": { + "value": "x86", + "strategy": "external" + }, + "cacheVariables": { + "CMAKE_RUNTIME_OUTPUT_DIRECTORY": "${sourceDir}/gamedir" + } + }, + { + "name": "msvc", + "hidden": true, + "inherits": "base", + "vendor": { + "microsoft.com/VisualStudioSettings/CMake/1.0": { + "hostOS": [ "Windows" ], + "intelliSenseMode": "windows-msvc-x86" + } + } + }, + { + "name": "msvc-relwithdebinfo", + "inherits": "msvc", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "RelWithDebInfo" + } + }, + { + "name": "msvc-debug", + "inherits": "msvc", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } + }, + { + "name": "msvc-release", + "inherits": "msvc", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release" + } + } + ], + "buildPresets": [ + { "name": "msvc-relwithdebinfo", "configurePreset": "msvc-relwithdebinfo" }, + { "name": "msvc-debug", "configurePreset": "msvc-debug" }, + { "name": "msvc-release", "configurePreset": "msvc-release" } + ] +} diff --git a/README.md b/README.md index d88fd63e0..5f5ec72d1 100644 --- a/README.md +++ b/README.md @@ -65,10 +65,9 @@ Visit the [releases page](https://github.com/1dot13/source/releases) to download * Double-click on `Folder View` in the `Solution Explorer` * Click `Open a local folder` * Use this option if you already cloned the repository yourself. -3. Visual Studio will automatically detect the CMake configuration files and will run the CMake generation. There will bet a CMake error in the logs saying `No existing preset was found, copied a preset template to [some_path]`. This is normal and only happens once. -4. Click on the dropdown that says `x64-Debug` and select `Manage configurations...`. This should trigger Visual Studio to load the `CMakeUserPresets.json` file it just copied. Now you can close the window for managing the configurations. -5. The `x64-Debug` option should have been replaced by `1dot13 Debug`. Click it and select `Manage configurations...` again. Here is where you configure the language for the built executables as well as which ones to build, Most important, here is where you set `CMAKE_RUNTIME_OUTPUT_DIRECTORY` to the path to your JA2 1.13 installation. This will be used for debugging. Note that the path needs to have a working 1.13 installation, and that includes the 1.13 game data. -6. You can use `Build -> Build All` to build the executables you selected in the configuration. +3. Visual Studio detects `CMakePresets.json` and lists the `msvc-*` configurations. Executables are written to `gamedir/`. +4. To build only some applications, or to debug against a different JA2 1.13 install, add/modify a `CMakeUserPresets.json` in the source root that inherits one of the shipped presets and sets the `Applications` and/or `CMAKE_RUNTIME_OUTPUT_DIRECTORY` `cacheVariables`. Language is chosen at runtime, not at configure time. +5. Use `Build -> Build All` to build. ### Reports diff --git a/cmake/CopyUserPresetTemplate.cmake b/cmake/CopyUserPresetTemplate.cmake deleted file mode 100644 index 44fba52e0..000000000 --- a/cmake/CopyUserPresetTemplate.cmake +++ /dev/null @@ -1,10 +0,0 @@ -function(CopyUserPresetTemplate) - if( - NOT DEFINED Applications AND - NOT EXISTS "${CMAKE_SOURCE_DIR}/CMakePresets.json" AND - NOT EXISTS "${CMAKE_SOURCE_DIR}/CMakeUserPresets.json" - ) - file(COPY "${CMAKE_SOURCE_DIR}/cmake/presets/CMakePresets.json" DESTINATION "${CMAKE_SOURCE_DIR}") - message(FATAL_ERROR "No existing preset was found, copied a preset template to ${CMAKE_SOURCE_DIR}/CMakePresets.json.") - endif() -endfunction() diff --git a/cmake/presets/CMakePresets.json b/cmake/presets/CMakePresets.json deleted file mode 100644 index 86202416c..000000000 --- a/cmake/presets/CMakePresets.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "version": 3, - "configurePresets": [ - { - "name": "__userBase", - "hidden": true, - "description": "Applications takes any of JA2, JA2MAPEDITOR, JA2UB, JA2UBMAPEDITOR, and builds all four when empty. Set CMAKE_RUNTIME_OUTPUT_DIRECTORY to a gamedir, e.g. C:/Games/JA2, to put the executables where they can be debugged.", - "generator": "Ninja", - "binaryDir": "${sourceDir}/build/${presetName}", - "cacheVariables": { - "Applications": "JA2", - "CMAKE_RUNTIME_OUTPUT_DIRECTORY": "." - }, - "architecture": { - "value": "x86", - "strategy": "external" - } - }, - { - "name": "1dot13 RelWithDebInfo", - "inherits": "__userBase", - "cacheVariables": { - "CMAKE_BUILD_TYPE": "RelWithDebInfo" - } - }, - { - "name": "1dot13 Release", - "inherits": "__userBase", - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Release" - } - }, - { - "name": "1dot13 Debug", - "inherits": "__userBase", - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Debug" - } - } - ] -}