fileapi: Flags from CMAKE_<LANG>_COMPILER_ARG1 aren't exposed
It's possible to pass additional compilation flags in CMake via CMAKE_<LANG>_COMPILER_ARG1
variables. However, these flags will not be visible from file-based API.
E.g., here's an example CMakeLists.txt:
cmake_minimum_required(VERSION 3.21)
set(CMAKE_CXX_COMPILER_ARG1 "-DBLABLA")
project(untitled19)
set(CMAKE_CXX_STANDARD 14)
add_executable(foo main.cpp)
Flag -DBLABLA
will be directly passed to the compiler, however in target-foo-Debug.json
this flag is missing.
"compileCommandFragments" :
[
{
"fragment" : "-g"
},
{
"fragment" : "-std=gnu++14"
}
]
Use-case:
Yocto project uses environment scripts to set up additional environment. One of the variable it sets is CC
with the value <compiler-executable> -mcpu=cortex-a57 -march=armv8-a+crc -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=<sysroot>
. All those flags are passed directly to the compiler and not available in file-based API.
Edited by Brad King