Visual Studio 2017, CMake and launch settings

Long story short, documentation for CMake related features in Visual Studio 2017 sucks. It’s scattered among a ton of blog post where most of the code samples are outdated or contain errors. Here is an example launch.vs.json that I’m using for reference:

    "version": "0.2.1",
    "defaults": {},
    "configurations": [
            "type": "Debug",
            "project": "CMakeLists.txt",
            "projectTarget": "foo.exe",
            "name": "foo.exe",

            // currentDir and not cwd like we can read in most examples ...
            "currentDir": "${workspaceRoot}",

            // this one is pretty straightforward
            "args": [ "arg0", "arg1" ],

            // env overwrites all the environment variables ...
            // separate vars by a null (\u0000) character. You can use existing env vars, see PATH
            "env": "TEST_ENV=foo\u0000HELLO=World\u0000PATH=${env.PATH};${workspaceRoot}"