mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
Use a modifiable user-preset sample for VS 2022/2019 (#97)
* Use a modifiable user-preset sample for VS 2022/2019 Customizing a repo-tracked preset file doesn't work: Type in your gamedir for debugging, or toggle verbose mode for the build, or configure Chinese UB MapEditor: you now have an unstaged `CMakePresets.json` change in your working directory. very annoying. Also, Visual Studio 2022's preset support has a bug: if you have a `CMakePresets.json` file, no matter in which file (user or repo) the preset you have selected is defined, if you click "Manage Configurations..." it will always open `CMakePresets.json` for editing, setting the user up for failure and editing the commited-to-repository file. Having just the `CMakeUserPresets.json` file also sidesteps another poor Visual Studio 2022 decision: hiding in Folder View files that are .gitignore'd (like `CMakeUserPresets.json`). In the absence of a `CMakePresets.json` file, selecting "Manage Configurations..." will open the right file for editing. The workflow is then: Copy `CMakeUserPresets.json.sample` into `CMakeUserPresets.json` _once_, then customize that to your heart's content without git bothering you and accidentally adding an unwanted change to a patch. Or make your own. * Added auto-copy of profile template. * declutter things a bit move function out of root cmakelists.txt file move user preset template to a presets directory this is horrible and I hate it Co-authored-by: CptMoore <39010654+CptMoore@users.noreply.github.com>
This commit is contained in:
+8
-5
@@ -1,8 +1,11 @@
|
|||||||
|
# CLion
|
||||||
|
.idea/
|
||||||
|
cmake-build-*/
|
||||||
|
|
||||||
|
# Visual Studio 2022
|
||||||
|
.vs/
|
||||||
build/
|
build/
|
||||||
lib/
|
lib/
|
||||||
.vs/
|
out/
|
||||||
.idea/
|
|
||||||
CMakeSettings.json
|
CMakeSettings.json
|
||||||
CMakeUserPresets.json
|
/CMakeUserPresets.json
|
||||||
cmake-build-*
|
|
||||||
out/
|
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ cmake_minimum_required(VERSION 3.20)
|
|||||||
|
|
||||||
project(ja2)
|
project(ja2)
|
||||||
|
|
||||||
|
include(cmake/CopyUserPresetTemplate.cmake)
|
||||||
|
CopyUserPresetTemplate()
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
|||||||
@@ -1,44 +0,0 @@
|
|||||||
{
|
|
||||||
"version": 3,
|
|
||||||
"configurePresets": [
|
|
||||||
{
|
|
||||||
"name": "default",
|
|
||||||
"hidden": true,
|
|
||||||
"generator": "Ninja",
|
|
||||||
"binaryDir": "${sourceDir}/out/build/${presetName}",
|
|
||||||
"cacheVariables": {
|
|
||||||
"Languages": "CHINESE;DUTCH;ENGLISH;FRENCH;GERMAN;ITALIAN;POLISH;RUSSIAN",
|
|
||||||
"Applications": "JA2;JA2MAPEDITOR;JA2UB;JA2UBMAPEDITOR",
|
|
||||||
"CMAKE_RUNTIME_OUTPUT_DIRECTORY": "."
|
|
||||||
},
|
|
||||||
"architecture": {
|
|
||||||
"value": "x86",
|
|
||||||
"strategy": "external"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Debug",
|
|
||||||
"displayName": "Debug",
|
|
||||||
"inherits": "default",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "RelWithDebInfo",
|
|
||||||
"displayName": "RelWithDebInfo",
|
|
||||||
"inherits": "default",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Release",
|
|
||||||
"displayName": "Release",
|
|
||||||
"inherits": "default",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Release"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
function(CopyUserPresetTemplate)
|
||||||
|
if(
|
||||||
|
NOT DEFINED Languages AND
|
||||||
|
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/CMakeUserPresets.json" DESTINATION "${CMAKE_SOURCE_DIR}")
|
||||||
|
message(FATAL_ERROR "No existing preset was found, copied a preset template to ${CMAKE_SOURCE_DIR}/CMakeUserPresets.json.")
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
{
|
||||||
|
"version": 3,
|
||||||
|
"configurePresets": [
|
||||||
|
{
|
||||||
|
"name": "__userBase",
|
||||||
|
"hidden": true,
|
||||||
|
"generator": "Ninja",
|
||||||
|
"binaryDir": "${sourceDir}/build/${presetName}",
|
||||||
|
"cacheVariables": {
|
||||||
|
// Valid choices: ENGLISH;GERMAN;FRENCH;ITALIAN;POLISH;DUTCH;RUSSIAN;CHINESE. If empty (""), will configure all.
|
||||||
|
"Languages": "ENGLISH",
|
||||||
|
// Valid choices: JA2;JA2MAPEDITOR;JA2UB;JA2UBMAPEDITOR. If empty (""), will configure all.
|
||||||
|
"Applications": "JA2",
|
||||||
|
// For debugging: enter your desired gamedir. e.g. C:/Games/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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user