What about tears of joy when you get it working? Hehehe.
Ok so here’s the deal. NEVER edit the CMake cache directly. That will only cause you grief, and CMake will likely just overwrite it making your changes pointless. The CMake cache is for CMake to use, not us humans.
With that out of the way, the basic idea behind CMake is that it is a build system generator. So on Unix systems, running CMake will by default give you a Makefile. On Windows, you will want to get a Visual Studio solution out (.sln file).
So the directory structure might look like (just create / copy paste the files from the tutorial)
For CMake, you’ll want to remember to always do something called “building out of source”. Real reasons aside, it makes it easier for you to start over.
$ cd path\to\someFolder
$ mkdir build
$ cd build
Now we are in this nice and self contained build directory, which if we ever mess things up, we can just delete the whole thing and start again. An unfortunate blunder (by Microsoft, not CMake) is how to generate this .sln file. Run this
$ cmake -G
That will list all of the available generators, for which a few different versions of Visual Studio should show up. If you wanted to generate for Visual Studio 15, it might look like this
$ cmake -G "Visual Studio 14 2015 Win64” ..
Note 1: “Visual Studio 14 2015”: their version numbers are annoying, but that will never change.
Note 2: Win64: unless you need a 32 bit build, make sure you generate a 64bit solution. Default is 32 bit.
Note 3: The ‘..’ is the actual argument to CMake, it should point to wherever the root CMakeLists.txt is. In this case, since we went into the `build` directory, .. points to the parent where someFolder/CMakeLists.txt lives.
This is how you should always CMake: make a build directory, enter it and `cmake ..` to get your project.
Assuming there were no errors during generation, you should now have a .sln file which you can double-click and it’ll open in Visual Studio. Alternatively, noting that the CMakeCache is generated in this build/ folder, we can run
$ cmake --build . --config Release
Note: the `.` rather than `..`. cmake `--build` is looking for the cache, not CMakeLists.txt.
That’ll just run msbuild from the command line. In truth, I think thats less common, I do it that way because I hail from Unix, where building and running from the command line is more natural than running from a GUI ;)
I don’t think I skipped any steps there, but getting started with this stuff can be very frustrating as you have expressed. Please ask questions if you are getting stuck still :)
P.S. A note about the build/ directory and the cmake cache. When you do more complicated things, such as finding other libraries and adding dependencies etc, this is where making this self-contained build directory becomes paramount. I can’t tell you the number of times that I’ve edited my CMakeLists.txt, re-ran `cmake ..` and had build failures….only to completely delete the build directory and start over fresh and have it work. It depends a lot on what you changed (it’s not always necessary), but a “stale cache” is a common grievance in CMake, which is why we always build out of source.
So I think the answer is neither needs to be solved, rather you should undo some stuff. To be clear, I don’t have access to Windows (I selfishly tried to take my boot cycle back to defaulting to Linux…and now Windows boot loader is gone *sigh*). But in my experience I have never had to set CXX for CMake. So
1) You shouldn’t need to set CXX manually, go undo that if you did it in a startup script of some kind.