Visual Studio 2017 - Disable CMake for dependencies - c++

I have a Visual Studio 2017 Solution that has some header-only dependencies that are multiplatform and use CMake.
I do not need CMake at all, but I keep getting a lot of warnings and issues because Visual Studio 2017 insists on using CMake, exploring these projects, etc.
Is there a way to completely disable the CMake feature for this solution/project?
Update:
I load the project as a solution not as a CMake project.
It is a header-only library and it does not require CMake to work. It is just using it for testing and other purposes.
I keep the dependency as a git submodule so I don't want to make changes to it. It is correctly working by adding it to the main project as an include path, etc.
The only thing I want I want is to avoid is CMake autodiscovery in these directories because I have no use for it.
For instance:
Add Eigen to your project as a submodule in a directory called Eigen. (This is a header-only library)
Write some code in your solution and reference the header files (you need to add the correct include paths, etc.)
You will see that CMake will pick Eigen (when it is not actually necessary)
You will get warnings and Targets, etc.

Don't open the CMakeLists.txt with File->Open->CMake. Choose File->Open->File. You can also try to uninstall the visual studio c++ tools for cmake portion of Visual Studio 2017 via the installation tool.

In Solution Explorer, locate CMakeLists.txt, right-click it.
Select Custom Build Tool->General.
Erase everything from there. Make sure you have a backup just in case ...

Related

What is the best way to handle source control of an external dependency for a C++ Visual Studio 2019 Solution using Git?

TL;DR: what is the best way to handle external dependencies in C++ Visual Studio projects in the context of source control? Ideally I want other people/devices to be able to just clone my repository, open the .sln file with Visual Studio 2019 and press F5 to compile without having to modify the compilation links for external libraries etc. each time a new clone is made.
I want to use an external library (GLFW, https://github.com/glfw/glfw) in a C++ Project in a Visual Studio 2019 Solution, and I want the project to be easily sharable via Git, both for other devices and other people.
There seems to be a few different approaches to handling this:
Download the binaries and simply store them in my external/glfw folder. This makes linking and including easy. The downside is that this requires manual updates and I would prefer to not redistribute someone else's binaries.
Use Git submodules/subtree to include the glfw source code in my external/glfw folder. My problem here is that I don't know of an easy way to compile the glfw source code as part of my Visual Studio build process since glfw uses CMake, and it doesn't seem to be possible to add a CMake project to a Visual Studio Solution unless the entire solution uses CMake which I want to avoid.
Make a separate repository just for compiling the external libraries. This repository would exist merely to compile external libraries, and the main repository would then use git submodules/subtree to fetch the appropriate binaries/libraries into external/glfw. The problem with this approach is that the overhead of managing a separate repository just for the purpose of compiling external libraries seems excessive.
Approach 2 holds the most appeal as it is simple yet flexible, however, I have been unable to make it work in Visual Studio since I can't seem to add a CMake Project to an existing solution. Is there a way to compile external CMake projects when needed, and have that script automatically execute when I press F5 in Visual Studio?
I'd suggest what you seem to have partially deduced. Instead of using your existing Visual Studio project/solution directly, convert your build to CMake and use a submodule.
Converting basically entails writing a CMakeLists.txt file with your build instructions, and you'll have one line in there that makes it traverse into the submodule. When you run CMake, it'll configure your code as well as the submodule, and generate a Visual Studio project that compiles and links both.
Added bonus is your code will be one step closer to being cross-platform too, since CMake will just as easily generate build systems for Mac, WSL, Linux, etc.

(Visual Studio) How can I use googletest libs and headers from outside my solution?

I'm using the built-in Google Test Adapter to write unit tests for a project in Visual Studio 2017. When I create the unit test project in my solution VS creates a package directory with the libs and header files for googletest, along with a package.config file. However I'd like to keep the googletest files out of my solution directory (and source control, though obviously I could just ignore them), and in a shared directory like the windows or standard library headers.
How can I configure my solution to get the libs and header files from a shared directory outside of my solution?
Not quite the answer I was looking for, but I learned that Visual Studio can automatically download NuGet packages when they are missing from solutions. Therefor you can just ignore the package directory from your source control but include packages.config, and whenever you clone the project Visual Studio will download the missing packages. This was good enough for my needs.

Point Cloud Library with Visual Studio 2017

I'm having trouble using Point Cloud Library with Microsoft Visual Studio 2017.
I have installed [PCL-1.8.1-AllInOne-msvc2017-win64.exe] and I've followed the steps mentioned
here. to link it to my Visual Studio 2017 project.
My problem is that Visual Studio is not finding the header nor the source files of the library I need.
The error I'm getting is as follows:
[fatal error C1083: Cannot open include file: 'pcl/io/pcd_io.h': No such file or directory]
To be more precise about my problem, I need to include three PCL header files in order to run thisIterative Closest Point Tutorial
I've followed the following steps to include the PCL into my project:
Added the include directories to my project at the Project Properties/Configuration Properties/VC++ Directories/Include Directories field - here I specified the path to my PCL/include directory and to all 3rd party include directories (PCL/3rdParty)
Added the library directories on the same settings page (Library Directories field) - hereI specified the path to my PCL/lib directory and to all non-header-only 3rd party libs (Boost, Flann, VTK)
Chose the libs to be used in the linker. In Project Properties/Configuration Properties/Linker/Input/Additional Dependencies field. I added all the libs required. As I'm trying to run it in debug mode for now, I've picked the "_debug.lib" library files.
Finally, I've added the PCL/bin folder to my system path variable.
Does anyone know if I'm missing something configuration-wise?
I've seen several old posts about incompatibility between older Point Cloud Libraries and older versions of Visual Studio. As far as I understood, the new versions are supposed to work well together, but it's not the case for me.
Installing pcl is tough because there are dozens of dependencies used along with pcl software. But with with vcpkg,a command line package manager, the installation becomes just like a one liner command.
Use Microsoft vcpkg to build a static or dynamic library for your project automatically. All the dependencies like boost,tiff,openssl,flann,szip,etc will be downloaded and installed by itself. After installing vcpkg type the following on Powershell.
.\vcpkg install pcl:x64-windows-static
The link you referenced is 3-4 years old. At the time, any binary build of PCL for Visual Studio 2012 or later was not provided, and thus. PCL needed to be built with target VS. And every include/library directory of PCL and any related library have to be manually added to setup the IDE. Since PCL is a large-scale collection of libraries, this made it difficult for its users to setup VS.
Now early 2018, binary builds of PCL for VS 2015/2017 and more automatic way to setup VS (e.g., adding library/include directories) using CMake are provided. Thus, installing PCL and creating a VS project using PCL does not take more than 10 minutes. I think you'd better follow the recommended way rather than setting VS by yourself.
the previous answer use vcpkg is good,but is better to use:
.\vcpkg install pcl:x64-windows
It can let you have fewer problems.
A small note for anyone who has issues with the install listed above, occasionally an install will get corrupted and not work. I got:
LINK : fatal error LNK1201
on a build, and the solution for that is find the downloaded item. This will be located in the vcpkg/downloads/ directory. Delete the item that was having issues and try the install again.

Adding projects to a visual studio c++ solution via a script

I usually work on multi-project solutions in visual studio.
Since the solutions themselves are not stored in the repository, I spend some time adding in the various projects via visual studio(from a list which is part of the 'parent' project).
I am wondering if I can acommplish this via a script.
ie: 1. create a solution. 2 add projects to that solution.
I have a supplementary I need to add to the above question.
I can use the File.AddProject from within the command window of visual studio(assuming you have a project open).
I can also use File.OpenExistingProject from outside of visual studio using devenv /command ..
Now the only missing piece is how do I add exisitng project to the project(solution) that is open, from outside of visual studio.
You should give a try to CMake. Here is a CMakeLists.txt example that creates a library and two binaries using that library. After using CMake program, you end up with a solution and 3 projects inside.
project(MyProject)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/common)
file(GLOB_RECURSE common_files common/*.h common/*.cpp)
add_library(commonLibrary ${common_files})
file(GLOB_RECURSE projectA_files projA/*.h projA/*.cpp)
add_executable(ProgramA ${projectA_files})
target_link_libraries(ProgramA commonLibrary)
file(GLOB_RECURSE projectB_files projB/*.h projB/*.cpp)
add_executable(ProgramB ${projectB_files})
target_link_libraries(ProgramB commonLibrary)
I have to admit , I did'nt try Cmake , mostly because I thought what I was looking for should be exposed in visual studio itself. I have the elements of the solution.
windows command prompt to add an alias for AddExistingProject followed by a command prompt run of devenv /commandline. It should be possible to write a script that utilizes these elements.

How to build wxmathPlot for win32?

I downloaded the latest wxmathplot but the readme is a bit sparse with instructions on how to build on win32 platform.
Has anyone used this library for win32? Can someone point me to the docs or give some hints/advice on how to build for win32 targets.
We'll eventually use this for cross platform stuff, for now it is just win32 until we port our other code.
I presume I have to use CMake, but have not used it before and it is not obvious to me how to build this all - I have already installed CMake, but I am apparently too stupid to figure out how to build this library/samples.
Well, I managed to make an SLN file, but it was not obvious.
I use wxMathPlot. I simply add mathplot.cpp and mathplot.h to the MSVS2008 C++ projects that need to use it. This compiles and links without my having to do anything special.
Here is a partial answer - to get
CMake to build an sln file:
Well, unfortunately there is no good
documentation on how to build
wxMathPlot on Windows, but it is very
simple. Just use CMake:
http://www.cmake.org/
Download and install it, then open
CMake gui, selecting the directory
where you uncompressed wxMathPlot and
a target build directory. click
Configure twice and then click
Generate. CMake does all its magic and
you'll get project files to build
wxMathPlot depending on your compiler.
For example, if you use Visual Studio,
a solution sln file is generated: open
it and build.
That works for building an sln file