Source file list from a Visual Studio project - visual-studio

Is there any way of passing the list of source files, that Visual Studio would build, to a makefile. Ideally Visual Studio would set an environment variable with a list of the files to compile. But unfortunately I have not discovered such a variable. I know I could write a script to parse the project file but I would really like to find a method which does not rely on a script. I would like to be able to set up the Visual Studio project so that different source files are built depending on the build configuration, using the Exclude from Build option. I would then like the makefile to only build the files that were not excluded. I am attempting to use Visual Studio as the development environment for a project which runs on different hardware and OS combinations.
P.S. Using Visual Studio is non-optional, and not my personal choice.

Create a MakeFile project within the VS solution.
This should be found under File -> New -> Project -> Visual C++ -> Other -> Makefile Project
Using Visual Studio 2017, there is a MakeFile template that can be used.
Additional instructions on how to do so can be found here

Related

Folder structure for a Visual Studio 2017 with CMake

I am working in a new project in C++ with Qt that is using CMake to generate the solution.
The project is quite big and it's working fine both in Visual Studio 2017 and QtCreator. Most of the people generate the solution for building using Ninja and import the build to QtCreator. But I prefer working with VS IDE.
The problem is that with QtCreator the Solution Explorer is keeping the folder structure, but in VS, all the projects (libs and dlls) hungs up from the solution (root) so I lose some valuable information.
I am quite new in CMake, and I would like to know if there is a way to generate the VS solution with the same folder structure that the source code has without affecting QtCreator solutions.
CMake does support organizing the projects in your Visual Studio Solution Explorer into folders, so you can name the folders to mirror the directory structure on your system. For example, if your projects are organized like this:
Utilities/LibraryA
Utilities/LibraryB
Executables/tools/ParserExecutable
You can use the set_target_properties command with FOLDER to designate the containing folder for each project in the VS Solution Explorer:
Utilities/CMakeLists.txt:
set_target_properties(LibraryA PROPERTIES FOLDER "Utilities")
set_target_properties(LibraryB PROPERTIES FOLDER "Utilities")
Executables/tools/CMakeLists.txt:
set_target_properties(ParserExecutable PROPERTIES FOLDER "Executables/tools")
You can try to automate this by using CMAKE_CURRENT_SOURCE_DIR instead of naming the folder explicitly, but start with a simple case first!
Also, make sure you add this to your top-level CMake to enable VS folders for your projects.
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

Can i change the default settings files used by visual studio 2017?

In general, is there a way to change the default parameters of the various json (and other) config files used by Visual Studio (2017).
My specific case is when working on a cmake project, I would like the CMakeSettings.json to have the vcpkg toolchain parameter set automatically, whenever I open or creates a new cmake project.

CMake and running PC-Lint at file-level in Visual Studio

Is there way to run PC-Lint either for a specific file or for the whole project in CMake-generated Visual Studio projects?
Currently I'm able to run PC-Lint per-project by creating custom targets using Kitware's script, but in my environment linting the whole project may take up to 10 minutes. So, I would also like to have a possibility to lint a specific source file only (and to choose that file from Visual Studio).
I was thinking, if PC lint could be used as custom "compiler" and to create for my target another project_LINT target that uses the lint "compiler". Then I could maybe select individual files to be "compiled". Or is this idea doomed? :)

Is there a Visual Studio C# equivalent of the Visual Studio C++ Makefile project

In Visual C++ inside Visual Studio, one of the project subtypes is a "Makefile Project".
But there doesn't seem to be an equivalent for Visual C# inside Visual Studio?
BTW, a Makefile project is:
If you have a project that you build from the command line with a
makefile, then the Visual Studio development environment will not
recognize your project. To open and build your project using Visual
Studio, first create an empty project containing the appropriate build
settings using the Makefile Project Wizard. You can then use this
project to build your project from the Visual Studio development
environment.
The project displays no files in Solution Explorer. The project
specifies the build settings, which are reflected in the project's
property page.
The equivalent of make in Visual Studio world is msbuild. Visual Studio does not use make. .csproj, .vbproj etc. are input files for msbuild. You can do pretty much the same stuff in them as in conventional makefiles, including command line building, custom targets etc.
There's nothing C++-specific about the Makefile project type; it just runs a command line. It's just that it's listed along with the Visual C++ project types. You can add one to a solution that otherwise contains nothing but C# projects.
Alternatively, you could set up a pre-build step in your C# project that directly runs nmake, msbuild or even NAnt.
Msbuild is what is used to build your projects when you hit the Play button. Personally I like NAnt + NantContrib it was easier for me to pick up and start using right away. For all new projects I use tree surgeon this tool creates a default build script and proper build tree with testing project and code coverage report.

Visual Studio to Make

While I love the Unix toolset family(including its black sheep Make) the project I'm working on currently is cross platform. That means having a Visual studio project ready for build.
So my question is, is there a tool/plugin for importing a Make file into VS or conversely is there a way to export a visual studio project into Make? Or any textual form, actually. I could write a script that parsed that into a Make file.
I would suggest making using Cmake... which will generate a set of makefiles or a visual Studio Project.

Resources