git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFH] CMake: detect if being run via Visual Studio, independent of build generator?
@ 2021-05-29 15:00 Philip Oakley
  2021-05-29 15:49 ` Matt Rogers
  0 siblings, 1 reply; 14+ messages in thread
From: Philip Oakley @ 2021-05-29 15:00 UTC (permalink / raw)
  To: Git List; +Cc: Sibi Siddharthan, Johannes Schindelin, Danh Doan

Hi,
cc'ing those who've been involved with the CMake tool recently.

I've been looking at part of the Git-for-Windows (GfW) Visual Studio
build process that uses the CMakeLists.txt approach [A,B], which is
based on the git.git version. In part it's now, for an uninformed user,
broken, in an awkward way, hence the subject line question.

An uniformed user is expected to clone git, download Visual Studio, and
file-open the /git directory. Visual Studio will then find the
CMakeLists.txt and create a hidden .sln/.vcproj project ready to build.

In recent times Visual Studio has added the Ninja build generator, in
addition to it's historic visual studio generator, and made Ninja the
default (unless specifically configured otherwise e.g. [1]). This change
of generator breaks the detection of being in Visual Studio (using Win32
and MSVC flags). We used these flags as a cue to pre-load the vcpkg
libraries, but no longer. Also note Visual Studio embeds its own CMake
version.


One issue for creating an update is that the CMake file is meant to be
OS independent, and the Ninja generator is also OS independent, so
shouldn't be used as the indicator of working with Visual Studio.
Likewise using the Win32 CMake flag isn't appropriate for those not
using Visual Studio. So the issue, as best I see it, is how to decide
when to pre-load the vcpkg libraries needed for the build.

The CI for the git.git test of CMake preloads it's essential
pre-requites (as an informed user;-) so avoids those Visual Studio
changes to it's defaults.

The ultimate aim is to make it as simple as possible for GfW users to
browse the Git code, without feeling that they have taken the
developer/contributor commitment step, which appears to scare off some
users.

Part of that simple usage is that existing Visual Studio support tools
can expect  .sln/.vcproj files to be available to 'just work' out of the
box. In particular (for me) Sourcetrail [2,3], with it's easy graphic
visualisation and tracing through the code, is one target. Sourcetrail
isn't quite there yet but..[4]

This issue is tricky to test as it (pretend to be that inexperienced
user) expects a clean VS install and no vcpkg prior install.

I could be totally confused (I am feeling rather dumb on this one), but
I'd be grateful of any help in clarifying a way out for detecting if the
conditions are right to pre-load the vcpkg libraries. I've also raised
an issue at [5]

--
Philip
earlier discussions at
https://github.com/git-for-windows/git/discussions/3176

[A]
https://github.com/git/git/blob/master/contrib/buildsystems/CMakeLists.txt
[B]
https://github.com/git-for-windows/git/blob/main/contrib/buildsystems/CMakeLists.txt
[1] https://github.com/microsoft/vscode-cmake-tools/issues/1084
[2] https://github.com/CoatiSoftware/Sourcetrail
[3]
https://github.com/git-for-windows/git/wiki/Sourcetrail-code-viewer-and-linkage-to-Visual-Studio,-for-Git
[4] https://github.com/CoatiSoftware/Sourcetrail/issues/1179
[5] https://github.com/MicrosoftDocs/cpp-docs/issues/3167

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-05-31 17:14 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-29 15:00 [RFH] CMake: detect if being run via Visual Studio, independent of build generator? Philip Oakley
2021-05-29 15:49 ` Matt Rogers
2021-05-29 16:25   ` Philip Oakley
2021-05-29 18:33     ` Sibi Siddharthan
2021-05-29 20:31       ` Philip Oakley
2021-05-29 22:14         ` Sibi Siddharthan
2021-05-30  0:14           ` Matt Rogers
2021-05-30 10:52             ` Philip Oakley
2021-05-30 13:22               ` Matt Rogers
2021-05-30 14:29                 ` Sibi Siddharthan
2021-05-30 15:24                   ` Philip Oakley
2021-05-30 22:26                     ` Philip Oakley
2021-05-31  0:01                       ` Matt Rogers
2021-05-31 17:12                         ` Philip Oakley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).