I have built the LLVM using Cmake from the documentation # LLVM on visual studio. I have an existing code project in visual studio, where I want to build my interpretor. I want to set the Platform Toolset to LLVM, however when I navigate to Properties>general>Platform Toolset in VS 2012 for my existing project, I dont see an option to add the LLVM tool chain in the drop down. I must be doing something terribly wrong here. Any help would be appreciated.
The LLVM Platform Toolset is not built by default- it requires a custom installation step and is not as simple as "Just build LLVM". Typically, it's easier to just download the installer from the LLVM Website. If you want to know how to build the Windows installer yourself, you'll have to ask in #llvm on OFTC.net.
Note that the existing LLVM Platform Toolset solution has some serious integration limits, like no exceptions/RTTI and AFAIK no support for the debugger and such too, which makes it seriously limited. Right now it's mostly useful for getting better error messages.
Related
So I am trying to build a basic C++ project on our university Linux server.
I went and checked the CMake version on the server, it is 2.8.12.2
I love using Visual Studio, so i tried using Visual Studio after SSH into my university server to build a basic hello world program on it.
I got the following message in my Visual Studio 2017:
CMake 3.8.x or above is not available on the remote system. See https://aka.ms/linuxcmakeconfig for more info
Is there a way to forcibly make Visual Studio accept a lower version of CMake 2.8.12.2
I made changes to the CMakeLists.txt as follows:
cmake_minimum_required(VERSION 2.8.12.2).
But still Visual Studio was complaining about not having CMake version 3.8 in the University server.
I've attached the screen shots below:
I was told to use some IDE called CLion. But I know Visual Studio is the better option, having used it all my life in the real world/non-university setting.
TL;DR
No, it's not possible.
Reason
The Visual Studio 2017 documentation states here:
The CMake support in Visual Studio requires server mode support introduced in CMake 3.8.
This means VS requires the cmake-server(7) API to query information like where CMake puts the built binaries, what include paths are used, etc. Without this information, VS would not be able to provide all the useful features of an IDE such as debugging, include path checks/auto-completion, etc. So there is no way, the CMake integration of VS (or any other IDE like CLion) is going to work with an CMake version that does not provide the server mode yet, which is definitely the case for all 2.x versions.
More Background
The server mode was actually introduced in CMake 3.7. I don't know why the VS docs suggest it's 3.8 🤷‍♂️. But I guess that's not an important difference for your case anyway.
Newer versions of Visual Studio (since 2019) even use the more recent cmake-file-api(7) introduced in CMake 3.14 as stated here:
Cmake version 3.14 or later should be installed on the target machine.
The server mode was even deprecated in 3.15 and completely removed in 3.20 in favor of the file-based API.
The VS devs even maintain their own CMake fork: github.com/microsoft/CMake.
This is because the server mode didn't provide them all the information they needed, as stated in their blog:
One of the differences in our CMake fork on github was the backtrace information needed for our Targets View feature inside Visual Studio. Prior to CMake 3.14 we needed the CMake version from our fork, in order for Targets View to work properly. Now, with the file-based API this is no longer required.
So maybe with VS 2017 you should use a CMake binary built by Microsoft. For VS 2019+ the "stock" CMake should probably be fine. As of now, they still maintain their fork, but I haven't found any source that indicates you're required to use it. Probably because Microsoft has become more involved in the CMake development the last couple of years and contributes to the upstream repository as well, e.g. cmake-presets(7) is the result of a cooperation between Microsoft and Kitware.
Recommended Solution
As #Shawn already commented, CMake 2.8.12 is seriously outdated (released 2013-10-08) and the best solution would be to ask the admin of your University to update CMake to a more recent version. This has the additional advantage, that you can use and benefit from the "Modern CMake" techniques.
There are some bugs introduced in 16.7 that affect me, and I would like to use 16.6.
Most of the questions I found refer to using VS2017 compiler, I want to use VS 2019 compiler, just an older version.
Best I found in official docs is to remove VS and reinstall, but I would like to avoid that.
I found solution of such problem for myself in following way.
You should locate MSVC build tools of chosen version in your folder like "Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC XX.YY.ZZZZ. If you just upgraded your VS it didn't remove old build tools (I hope). If it did or you just installed newer versions you can use VS Installer to add/download MSVC Build Tools of one of previous version.
You should change links to VCTools of previous version for Toolset v142 (that is 2019). To do his you can change text files located at something like "2019\Enterprise\VC\Auxiliary\Build". Files of our interest are "Microsoft.VCToolsVersion.v142.default.txt" and "Microsoft.VCToolsVersion.v142.default.props".
That simple files just contains names of MSVC Tool version to use for Toolset v142
These changes will affect building of all you projects using toolset v142 (that is VC2019 Compiler)
I am sorry that VS does not currently support the ability to roll back a Visual Studio Update, you can only follow the method in the link. Luckily, Microsoft have already understood this issue and rolling back updates is certainly in their backlog. You could vote on this issue and express your demands.
I have downloaded an installed LLVM 10 on Win 10 machine, which already had VS2019-Enterprise.
Created the Directory.build.props file as:
<Project>
<PropertyGroup>
<LLVMInstallDir>full_path_to_my_llvm</LLVMInstallDir>
</PropertyGroup>
</Project>
Ran MSBuild while on the directory that contains .sln and .vxproj files.
Still cannot get see llvm under ConfigurationProperties->General->PlatformToolset.
How does one add LLVM to VS2019?
You can use the Clang Power Tools extension to add any custom LLVM versions, starting with LLVM 4, directly from Visual Studio. (Disclaimer: I am the author of this extension.)
Go to CPT Settings -> select the LLVM Tab -> select the version you want to install by clicking the install button. No configuration is needed. Here is an article about this feature.
You can install multiple versions and decide later what version is better for you.
I just ran into the same issue myself, so I'll post the solution since I came across this question while searching for an answer.
Clang/LLVM support in Visual Studio projects
For best IDE support in Visual Studio, we recommend using the latest Clang compiler tools for Windows. If you don't already have those, you can install them by opening the Visual Studio Installer and choosing C++ Clang tools for Windows under Desktop development with C++ optional components. If you prefer to use an existing Clang installation on your machine, choose the "C++ Clang-cl for v142 build tools." optional component.
C++ Clang-cl for v142 build tools (MSDN's image)
All you have to do is install the 2nd component as shown. After you install that component, and load up Visual Studio again, you'll be able to select "LLVM (clang-cl)" from the Platform Toolset option.
That's all there was to it!
As far as I understand, Visual Studio 2015 is shipped with clang. First I though this was only for Android and iOS apps, but according to this article it should also be possible to use the clang++ frontend for Windows programs. However, I can't find the according option.
So could you please explain to me, how I can change the used compiler to clang in a c++ project (in VS2015 RC Community Edition).
Starting with VS2015 Update 1 you can install the "Clang with Microsoft CodeGen" template via the New Project window, browse to Installed -> Templates -> Visual C++ -> Cross Platform.
You will then be able to choose the Clang 3.7 with Microsoft CodeGen v140_clang_3_7 Platform Toolset in the properties page of any Windows C++ project.
Clang has a completely different set of command-line options which it recognizes, so when using the v140_clang_3_7 toolset, the project properties must be using Clang-compatible options, which can be recognized as starting with - instead of /. For example, Debug Information Format property set to "Full Debug Information (DWARF2) (-g2 -gdwarf-2)", and Enable C++ Exceptions property set to "Yes (-fexceptions)".
There's more information in this blog post.
As far as I understand it both Clang and GCC are shipped with the Android and iOS crossplatform SDKs/tools for Visual Studio 2015.
From what I've seen it only allows me to choose those while having one of those crossplatform projects.
Using the template project for a GLES C++ application you get the following options:
While for a Windows C++ application you get the dialog below where you can see that Windows target platform is grayed out and read-only, meaning you probably have a set of toolkits for each target platform, but you simply cannot change it, at least for now.
Have no idea how you turn a normal VS project into crossplatform though, and it's likely that you can only target Android or iOS out of the box using 3rd party compilers.
It may be possible, though, to install Clang as another toolkit in the same way the XP toolkits are. So perhaps it's just a matter of someone fiddling with it and making it available as it is already installed.
Caveat: This answer is pre-VS2015 update 1 which didn't have the "Clang with Microsoft CodeGen" option.
After reading through the linked post and especially the comments again, I came to understand, that this is not a feature shipped with VS2015 RC but a possible future feature that might e.g. be shipped in a SP or (more likely) with the next version of VS.
As mentioned by sjdowling, the closest thing you can do at the moment (October 2015, clang 3.7) is to download and install llvm for windows. This should give you a LLVM-vs2014 platform toolset option. For me it works for simple test programs, but apparently this version of "clang-vs" seems to not yet support exceptions. However, according to these notes, that problem should be mostly solved for clang 3.8.
While the above solutions work they require that you have installed clang which is off by default in the visual studio 2015 installation. The accepted answer does show how to install it, though the next page will ask you to close visual studio which you are running the new project from.
If anyone is wondering how to install clang because it does not show up in their list here is another solution:
Control Panel->Programs->Programs and Features.
Right click on “Microsoft Visual Studio Enterprise 2015” (or
“Microsoft Visual
Studio 15 Preview” if you have the preview of the next version of
Visual Studio installed)
Click “Change”
Click “Modify”
Select “Clang with Microsoft CodeGen” – The March 2016 release.
https://blogs.msdn.microsoft.com/vcblog/2016/03/31/clang-with-microsoft-codegen-march-2016-released/
I have the Intel compiler platform install on my development machine, when using Cmake to generate a visual studio 2010 solution, I want to be able to specify the platform toolset to be using "Intel" instead of "vc100".
I cant seem to find the setting to change this, when I change the compiler to icl the solution still builds with the vc100 compiler until I manually change the platform toolset.
I was looking for similar functionality as well, for setting the Windows SDK 7.1 as the default toolset for a large number of projects, without having to go through and change each one by hand.
I believe that the CMAKE people have added that functionality, and you can use something like:
set_target_properties(${YOUR TARGET} PROPERTIES PLATFORM_TOOLSET "Intel C++ Compiler XE 12.1")
Have a look at:
http://public.kitware.com/Bug/view.php?id=12876
for details of the change.
I was able to change the platform toolset by using a command-line option (CMake 3.2):
cmake . -G "Visual Studio 12" -T "LLVM-vs2013"