Vscode-cmake-tools: Semicolon in string escaped in CMakeCache.txt

Created on 2 Aug 2019  路  2Comments  路  Source: microsoft/vscode-cmake-tools

Brief Issue Summary

Semicolon (;) in string value of cmake.configureSettings (and potentially elsewhere) gets escaped in resulting CMakeCache.txt.

Expected:

Let's create a simple example project with a string variable that we set when configuring the project:

demo=`mktemp -d`
cd $demo

# Create CMakeLists.txt
cat <<EOF > CMakeLists.txt
project(demo)
set(LLVM_ALL_PROJECTS "clang;clang-tools-extra;compiler-rt;debuginfo-tests;libclc;libcxx;libcxxabi;libunwind;lld;lldb;llgo;openmp;parallel-libs;polly;pstl")
set(LLVM_ENABLE_PROJECTS "" CACHE STRING
    "Semicolon-separated list of projects to build (${LLVM_ALL_PROJECTS}), or \"all\".")
EOF

# Configure
cmake . -DLLVM_ENABLE_PROJECTS="lldb;clang"

# Grep for resulting line in CMakeCache.txt
grep "LLVM_ENABLE_PROJECTS" CMakeCache.txt

Please notice, that the resulting line looks like this:

LLVM_ENABLE_PROJECTS:STRING=lldb;clang

Apparent Behavior:

When I take the above project and configure it in using vscode-cmake-tools I have this cmake.configureSettings in my settings.json:

"cmake.configureSettings": {
    "LLVM_ENABLE_PROJECTS": "lldb;clang",
}

Once configured, the resulting line in CMakeCache.txt looks like this (notice the semicolon being escaped):

LLVM_ENABLE_PROJECTS:STRING=lldb\;clang

This line is supposed to look like this IMHO (notice the semicolon not escaped):

LLVM_ENABLE_PROJECTS:STRING=lldb;clang

Platform and Versions

  • Operating System: Fedora release 28 (Twenty Eight)
  • CMake Version: 3.11.2
  • VSCode Version: 1.36.1
  • CMake Tools Extension Version: 1.1.3
  • Compiler/Toolchain: Clang 6.0.1

Most helpful comment

I did solve the problem myself by using a JSON array instead of a string:

"cmake.configureSettings": {
   "LLVM_ENABLE_PROJECTS": ["lldb", "clang", "lld", "compiler-rt", "clang-tools-extra"],
}

Thank you for this great extension!

All 2 comments

I did solve the problem myself by using a JSON array instead of a string:

"cmake.configureSettings": {
   "LLVM_ENABLE_PROJECTS": ["lldb", "clang", "lld", "compiler-rt", "clang-tools-extra"],
}

Thank you for this great extension!

This should be stated in the documentation. I could make the merge request, but don't have time at the moment to see what other fields are impacted (for example, does this also happen on cmake.configureArgs?).

Was this page helpful?
0 / 5 - 0 ratings