vscode-cmake-tools icon indicating copy to clipboard operation
vscode-cmake-tools copied to clipboard

Custom browse configuration should not include (redundant) per-file arguments

Open Colengms opened this issue 3 years ago • 0 comments

Brief Issue Summary

When using a CMakeLists.txt file such as:

cmake_minimum_required(VERSION 3.23)

project (test)

add_executable (test test.cpp test2.cpp test3.cpp)

set_source_files_properties(test.cpp PROPERTIES COMPILE_FLAGS -someflag1)
set_source_files_properties(test2.cpp PROPERTIES COMPILE_FLAGS -someflag2)

I'm seeing that the following custom browse configuration is being generated:

Custom browse configuration received: {
  "browsePath": [
    "z:/repos/test"
  ],
  "compilerPath": "c:/program files/llvm/bin/clang++.exe",
  "compilerArgs": [],
  "compilerFragments": [
    "-g -Xclang -gcodeview -O0 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd",
    "-someflag1",
    "-g -Xclang -gcodeview -O0 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd",
    "-someflag2",
    "-g -Xclang -gcodeview -O0 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd"
  ]
}

It looks like all possible sets of arguments are being combined into a single set. This will not always produce a valid set of arguments to pass on a single command line (even if duplicates are ignored).

I had actually discussed with Bob changing this structure in the cpptools-api to use an array of command lines, which would address this. Multiple compiler probes could occur, pulling system includes into the browse path from multiple command lines used in the build, instead of just one.

CMake Tools Diagnostics

No response

Debug Log

No response

Additional Information

No response

Colengms avatar Jul 14 '22 22:07 Colengms