Visual Studio 2015: How to automate cmake operations? - visual-studio

I'm using Visual Studio 2015 Enterprise Edition. I followed this tutorial
https://www.youtube.com/watch?v=IgvbhyDh8r0
Like Visual Studio creates a .sln file when any new project is saved and then on building it executes it to build the project, in the case of this VTK tutorial, it uses CMake to create the build file .sln for Visual studio to execute. Is there any way I can automate/replace the process of CMake using Visual Studio only?
PS- Just ignore if I have any misunderstanding of the concepts as I'm totally new to this and was not able to find proper documentation on it.

After you've generated a .sln file once, you don't need to run CMake manually again. It hooks itself into ZERO_CHECK project, so it would regenerate the solution every time you change CMakeLists.txt.
But you can't do with VS only, as you have to generate .sln for the first time.

Related

What determines the default startup project?

I have a open source project that include Visual Studio project files. There is a solution file with four projects files. When the source files are distributed and unpacked, Visual Studio picks the wrong project as the default project. New users don't know they need to right click a certain project, and then select Set as Startup Project.
I've tried re-ordering the projects in the solution file so the appropriate project is first, and I tried changing the UUID on the appropriate project so its the lowest. Neither have helped with the problem of Visual Studio selecting the wrong startup project.
The Visual Studio versions I test against are Visual Studio 2005, 2008, 2010, 2012, 2013 and 2015.
What determines the default startup project?
What can I do to ensure Visual Studio selects the correct startup project?
A related question is Why is “Set as Startup” option stored in the suo file and not the sln file?, but it asks "Why..." and does not ask "How To...".
If there is a *.suo file, the Startup Project is saved there.
Otherwise, the first project listed in the *.sln file will be the Startup.
(tested with VS 2013)

Can I use qt5 in visual studio without the add-in?

I understand I can use Qt5 in Visual Studio by using the Visual Studio Add-in for Qt as mentioned in Building Qt5 with Visual Studio 2012 / Visual Studio 2013, and integrating with the IDE.
Is it possible to use Qt5 in Visual Studio without using the Add-in?
Also, I would like to use CMake to generate the Visual Studio Project.
Yup.
I have it working for a pretty complex subdirs template.
Qmake can generate the visual studio solution file and vcxproj, look here:
http://doc.qt.io/qt-5/qmake-platform-notes.html#creating-visual-studio-project-files
What I do is use the Qmake project as the master project, and generate the VS stuff out of folder as temporaries. This prevents Visual studio from tangling up in your source files as well as in the qmake stuff. And you can also port it to other OSs without any hassle. Using this approach, if you want to add files to your project, don't do it through VS, but add it to the .PRO file and re-run qmake.
The only thing (that I've found) is if you change anything that needs to be MOC'd, then re-run qmake.
If you want CMake exclusively then this is a nice guide
http://www.kdab.com/using-cmake-with-qt-5/.
The qmake way is a little cleaner as you don't get all the extra noise of finding Qt libraries as you need in CMake.

Visual Studio needs to make non-functional changes to this project

I have a visual studio solution with a a vs2010 project
Everytime I open it I got this warning.
Visual Studio needs to make non-functional changes to this project in
order to enable the project to open in this version and Visual Studio
2010 SP1 without impacting project behavior.
ANd it generates some xml log files
I need to definitely convert it to vs 2012
How can I do that without breaking anything else?
I was able to solve it by opening the .csproj file and changing this
<FileUpgradeFlags>0</FileUpgradeFlags>
for this
<FileUpgradeFlags></FileUpgradeFlags>

Visual Studio 2010 and .bsc file

I'm using an open source Mozilla project in Visual C++ 2010. The project requires UNIX based build tools and therefore I cannot create a Visual Studio project for it directly. I must use the command line build files (makefile, configure script, etc) bundled with the project to build the project using cl.exe. (This is due to the fact that some .h files are generated by the make utilities.)
The problem is, without creating a Visual Studio project, how do I browse through the project source files using say the "F12 Go To Definition" feature available in Visual Studio? I know I can generate a .bsc file using the /FR compiler option. But, I also found that the Object Browser in Visual Studio 2010 doesn't seem to support a .bsc file. When I open a .bsc file directly using Visual Studio 2010, it says "Class not registered, Looking for object with CLSID: {D9B3211D-E57F-4426-AAEF-30A806ADD397}.
How do we use a .bsc file under Visual Studio 2010?
Unfortunately BSC is not supported anymore for Visual Studio 2010+
More details: http://connect.microsoft.com/VisualStudio/feedback/details/514470/bsc-files-cannot-be-used

How to stop Visual Studio caching Imported MSBuild scripts?

I have a csproj file which references a shared MSBuild script with an <Import> directive. I have noticed that when I change the shared script, I need to close and reopen Visual Studio before it notices the change - a build within Visual Studio notices changes to the csproj file but not the shared file.
This doesn't happen when I build the project with MSBuild from the command line. Is Visual Studio caching the imported script? If so, why? And how can I turn off this behaviour which makes authoring build scripts hard / impossible using Visual Studio?
Thanks!
Instead of closing and re-opening Visual Studio have you tried, unloading and reloading the project (.csproj) which imports the shared script? You can do this from the Solution Explorer in Visual Stduio by right clicking on the loaded project and selecting unload and then on the unloaded project and picking load.
In my experience, Visual Studio 2015 behaves better than Visual Studio 2008.
VS picks up changes from imported files in most cases, at least for C# projects.
YMMV for other project types, though.
While the solution explorer doesn't reflect changes, the build uses the updated version of the import file.
So, the solution may be to use a more recent version of Visual Studio.

Resources