CMake / MSVC project files on Windows

Programmers discuss here anything related to FreeOrion programming. Primarily for the developers to discuss.

Moderator: Committer

Post Reply
Message
Author
User avatar
Vezzra
Release Manager, Design
Posts: 6090
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

CMake / MSVC project files on Windows

#1 Post by Vezzra »

I'm opening this thread to continue a discussion that started in the comment section of PR#2747 to the forum (where it belongs). I'm going to copy the various respective posts in that comment section over to this thread within the next minutes. Please continue the discussion here.

User avatar
Vezzra
Release Manager, Design
Posts: 6090
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: CMake / MSVC project files on Windows

#2 Post by Vezzra »

Geoff the Medio wrote:I just want the MSVC project files to also be committed after being generated, so that people using MSVC don't need to use CMake to generate the project files.
Why? CMake isn't that hard to use? I don't see the problem with expecting anyone who wants to build FO by themselves to be able to handle CMake. Keeping files which get generated (for whatever purpose by whatever means) in version control kind of defeats the purpose of generating them...?

I mean, there is a reason why it's usually not done...

User avatar
Vezzra
Release Manager, Design
Posts: 6090
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: CMake / MSVC project files on Windows

#3 Post by Vezzra »

Geoff the Medio wrote:The point of generating them from CMake is/would be that one only needs to edit CMake files to do the project file updates for all build systems, including windows, and can do so even without having MSVC to open and do the edits.

The point of generating the MSVC project files and committing them is that people who are using MSVC don't have to generate new project files whenever the CMake files change; the updated files will already be present at whatever commit one is currently on.

I frequently jump around in the commit log and switch between branches. If I have to check every time whether I need to generate new project files, and then do so, that is a major delay and disruption in workflow. If I can just switch branches and be sure that the MSVC project files are already in working order, then that's much easier to work with. To clarify, I work within MSVC mostly, not command line except for some git stuff that doesn't work well within TortoiseGit (mainly pulling branches from pull requests), so I'm not switching branches using console command most of the time, and expect MSVC to immediately update itself after I switch branches or revert to a previous commit using the popup menus.

Having the MSVC project files already available also means that someone who wants to work with them doesn't need to install and use CMake. It's not a matter of whether they can learn to do so, but rather a matter of it being an annoying hassle to need to do so.

Apparently I don't understand CMake, so perhaps the build happens with XCode and GCC without a separate project file generation step. Even if that's the case, it doesn't matter for me, as I'd still need to generate the project files as a separate step in order to see the result of changing the project files. Even if MSVC can be configured to run CMake when building a project or a solution, that doesn't fix the issue, as I want Visual Studio to update before I start a build.

User avatar
Vezzra
Release Manager, Design
Posts: 6090
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: CMake / MSVC project files on Windows

#4 Post by Vezzra »

adrian_broher wrote:
Geoff the Medio wrote:If I have to check every time whether I need to generate new project files, and then do so, that is a major delay and disruption in workflow.
The solution is refreshed on every build when required without manual intervention. MSVC will at most ask for a reload of the solution.
Geoff the Medio wrote:Having the MSVC project files already available also means that someone who wants to work with them doesn't need to install and use CMake. It's not a matter of whether they can learn to do so, but rather a matter of it being an annoying hassle to need to do so.
So its the best course of action to load the additional effort required on long time contributors and increasing the maintaince effort for everything related around the build system like documentation, consistency accross platforms and automation efforts. Add another dimension of pain by 'supporting' multiple versions of MSVC at the same time. 10 out of 10 prioritisation.
Geoff the Medio wrote:Apparently I don't understand CMake, so perhaps the build happens with XCode and GCC without a separate project file generation step.
Again, apart from the initial build tree, this is done without manual intervention. This is done on every platform and switching between branches is handled just fine.
Geoff the Medio wrote:Even if that's the case, it doesn't matter for me, as I'd still need to generate the project files as a separate step in order to see the result of changing the project files.
What kind of change do you expect to see that needs to be reviewed?

User avatar
Vezzra
Release Manager, Design
Posts: 6090
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: CMake / MSVC project files on Windows

#5 Post by Vezzra »

o01eg wrote:With CMake we have other issue, it requires more time to build on AppVeyor than MSVS project.

User avatar
Vezzra
Release Manager, Design
Posts: 6090
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: CMake / MSVC project files on Windows

#6 Post by Vezzra »

I think what Geoff is concerned about, or it's not clear to him how it is supposed to work, is how Visual Studio handles a switching between branches when one creates the project files via cmake and then opens these project files with VS (assuming of course the case where the project structure is different between the branches in question, files added/removed etc.).

Because doing it like this would result in the problems Geoff is concerned about. However, that's not how you work with CMake projects in VS. VS is actually capable of handling CMake projects just fine, you just have to open the CMake project, well, as a CMake project in VS, and not the project files CMake produces. Instead, you open the topmost CMakeLists.txt with "File/Open/Cmake..." (in VS 2017).

AFAIK you need CMake installed on your system of course, and the "Visual C++ tools for CMake" component also needs to be installed (although I think that's the case with a default VS install anyway, as I just tried that with the VS development environment on my Windows machine, which is a default install, and it opened FO as cmake project).

If you do it that way, things work as Marcel described. If you switch branches (which you can do directly within VS), VS reconfigures the project immediately without any user intervention, so switching back and forth between branches should work just fine.

The only issue right now (aside from build issues) is that VS (version 2017) currently gives an error when processing the CMakeLists.txt file: "list GET given empty list" on line 162 of the topmost CMakeLists.txt. But that doesn't sound like something that can't be fixed.

Here are two links I found when googling about cmake integration in VS, which describe working with cmake within VS:

https://docs.microsoft.com/en-us/cpp/bu ... ew=vs-2017
https://devblogs.microsoft.com/cppblog/ ... al-studio/

Regarding the additional "burden" od having to install CMake alongside VS, I agree with Marcel. That really isn't that much of a hassle that it can't be asked of someone who wants to build FO for themselves, or of people on Windows who want to contribute as developers. CMake has become a standard tool for cross-platform development, any serious developer can be expected to at least install it when setting up their development environment.

Personally I also much prefer how the project layout is presented when you open FO source in VS as cmake project vs. when you open the VS project files.

User avatar
em3
Vacuum Dragon
Posts: 630
Joined: Sun Sep 25, 2011 2:51 pm

Re: CMake / MSVC project files on Windows

#7 Post by em3 »

Am I right to assume this conversation didn't go anywhere?
https://github.com/mmoderau
[...] for Man has earned his right to hold this planet against all comers, by virtue of occasionally producing someone totally batshit insane. - Randall Munroe, title text to xkcd #556

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13586
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: CMake / MSVC project files on Windows

#8 Post by Geoff the Medio »


User avatar
em3
Vacuum Dragon
Posts: 630
Joined: Sun Sep 25, 2011 2:51 pm

Re: CMake / MSVC project files on Windows

#9 Post by em3 »

Geoff the Medio wrote: Mon Aug 03, 2020 12:15 pm See viewtopic.php?f=4&t=11732&p=102823#p102791 at bottom
Thank you, Geoff. :) I thought that was only about possible GiGi replacements, so I skimmed the thread (as I was aware that final decisions will be in further threads).
https://github.com/mmoderau
[...] for Man has earned his right to hold this planet against all comers, by virtue of occasionally producing someone totally batshit insane. - Randall Munroe, title text to xkcd #556

Post Reply