Can not compile active file if definition has quoted text
See original GitHub issueBrief Issue Summary
If CMakeLists.txt has any C++ definition with ampersands char it brokes compiling active file.
It does not mater what kind of cmake command used no one of add_definitions
, add_compile_definitions
nor target_compile_definitions
.
Apparent Behavior:
Just add in the file
add_compile_definitions(_WRONG_CHAR_='&')
First try configure the project and check compile_commands.json
to ensure that it was correctly processed in compilers option -D_WRONG_CHAR_=\"'&'\"
And you can successfully build entire project as expected.
But if you try run compile only one active file with command cmake.compileFile
you will get an error, because this definition will lost first part and leave only "'&'"
Expected:
Compile active file should use the same command from compile_commands.json
as it was used to compile entire project.
Other Notes
Originally the issue was noticed with following cmake code:
string(LENGTH "${CMAKE_SOURCE_DIR}/" __SOURCE_PATH_SIZE)
add_compile_definitions(__FILENAME__=\(&__FILE__[${__SOURCE_PATH_SIZE}]\))
To set __FILENAME__
in relative path of current sorce file.
Platform and Versions
- Operating System: openSUSE 15.0
- CMake Version: 3.13.4
- VSCode Version: 1.40.2
- CMake Tools Extension Version: 1.2.3
- Compiler/Toolchain: GCC 7.4
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:5 (2 by maintainers)
Top GitHub Comments
It’s much easier to just let the shell do its job via
shell: true
or similar. Had the same problem in another extension.We almost have CMake Tools 1.6.0 release out the door. Until then, if you want, you can also verify if this problem has been fixed correctly by installing the vsix built here: https://github.com/microsoft/vscode-cmake-tools/actions/runs/557242002#artifacts.