Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a modifiable user-preset sample for VS 2022/2019 #97

Merged
merged 3 commits into from
Jan 21, 2023

Conversation

majcosta
Copy link
Contributor

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.

@CptMoore
Copy link
Contributor

CptMoore commented Jan 20, 2023

issues

  1. CMakeUserPresets is not supported for (all/official versions of cmake provided by) VS2019
  2. call it CMakePresets.template.json to avoid explorer complaining about a change of the extension (dont make the last extension contain the to-be-removed name
  3. make only a single app/lang combination the default, EN and JA2, Kitty complained that there are more than one combination possible for each file. keep the CMAKE_RUNTIME_OUTPUT_DIRECTORY default as "." so its at least a valid default after copying.
  4. comment "//" in jsons are not valid, it makes it an invalid json. you should add fake fields (which are supported by cacheVariables), e.g. "Languages_Description" or "Languages_Comment"

I would suggest to add the trick of copying this file automatically as part of the cache generation. That works really well and the user will actually have a good default instead of a broken project configuration in VS when initially opening it.

@majcosta majcosta marked this pull request as draft January 20, 2023 08:47
@majcosta majcosta force-pushed the pr_iteration_on_vspresets branch from 06fd452 to 43fb8b0 Compare January 21, 2023 02:20
@majcosta
Copy link
Contributor Author

  1. it does work on vs2019 I tested it

implemented 2 and 3

as for 4, if you pass cmake a variable and don't use it, he will pop out a scary message of how "such and such were not used in the project" which I'd rather avoid. in my testing, VS didn't even notice the json is invalid, and while clion does complain, it recognizes the presets and it works fine.

last suggestion is good and I tried it, problem is, vs2019 ships with cmake 3.20 which doesn't have FILE(COPY_FILE ...) which pours cold water on the whole thing

@majcosta majcosta marked this pull request as ready for review January 21, 2023 02:23
@CptMoore
Copy link
Contributor

CptMoore commented Jan 21, 2023

  1. ok, i must have misinterpreted the information on the net

--

  1. many tools who can modify json or read it wont work, what about just reading the descriptions in the cmakelists file but afterwards ignoring them?

regarding the file copy, there are many ways to copy files in cmake, the older ones are available since almost the first v3 of cmake, I'll check

majcosta and others added 3 commits January 21, 2023 16:04
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.
move function out of root cmakelists.txt file
move user preset template to a presets directory

this is horrible and I hate it
@majcosta majcosta force-pushed the pr_iteration_on_vspresets branch from 38ed64e to a6b568b Compare January 21, 2023 20:24
@majcosta majcosta merged commit 57d2674 into 1dot13:master Jan 21, 2023
@majcosta majcosta deleted the pr_iteration_on_vspresets branch January 21, 2023 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants