As the title says, setting CMAKE_C(XX)_FLAGS_DEBUG to the empty string “” in a CMakePresets.json, even if architecture is specified to ‘external’ and x64, will make compile for x32.
Is this intended behaviour? Something I am missing?
My CMakePresets.json:
{
"version": 2,
"configurePresets": [
{
"name": "base",
"description": "For more information: http://aka.ms/cmakepresetsvs",
"hidden": true,
"generator": "Ninja",
"binaryDir": "${sourceDir}/o/${presetName}",
"cmakeExecutable": "${sourceDir}/Tools/CMake/Windows/bin/cmake.exe"
},
{
"name": "windows-debug",
"displayName": "Windows Release",
"description": "Sets windows build type and x64 arch",
"inherits": "base",
"architecture":
{
"value": "x64",
"strategy": "external"
},
"cacheVariables":
{
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_CXX_COMPILER": "${sourceDir}/Tools/Compilers/llvm-12.0.1/WIN64/bin/clang++.exe",
"CMAKE_C_COMPILER": "${sourceDir}/Tools/Compilers/llvm-12.0.1/WIN64/bin/clang.exe",
"CMAKE_CXX_FLAGS_DEBUG": ""
},
},
{
"name": "windows-release",
"displayName": "Windows",
"inherits": "windows-debug",
"cacheVariables":
{
"CMAKE_BUILD_TYPE": "Release"
}
}
]
}
CMakeError.log:
Detecting C compiler ABI info failed to compile with the following output:
Change Dir: C:/ws/progrmaming/o/windows-release/CMakeFiles/CMakeTmp
Run Build Command(s):C:/PROGRA~2/MICROS~2/2019/PROFES~1/Common7/IDE/COMMON~1/MICROS~1/CMake/Ninja/ninja.exe cmTC_bab84 && [1/2] Building C object CMakeFiles/cmTC_bab84.dir/CMakeCCompilerABI.c.obj
[2/2] Linking C executable cmTC_bab84.exe
FAILED: cmTC_bab84.exe
cmd.exe /C "cd . && C:\ws\progrmaming\Tools\Compilers\llvm-12.0.1\WIN64\bin\clang.exe -fuse-ld=lld-link -nostartfiles -nostdlib -O0 -fno-inline-functions -Xlinker /subsystem:console CMakeFiles/cmTC_bab84.dir/CMakeCCompilerABI.c.obj -o cmTC_bab84.exe -Xlinker /MANIFEST:EMBED -Xlinker /implib:cmTC_bab84.lib -Xlinker /pdb:cmTC_bab84.pdb -Xlinker /version:0.0 && cd ."
lld-link: error: <root>: undefined symbol: mainCRTStartup
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
Determining if the C compiler works failed with the following output:
Change Dir: C:/ws/progrmaming/o/windows-release/CMakeFiles/CMakeTmp
Run Build Command(s):C:/PROGRA~2/MICROS~2/2019/PROFES~1/Common7/IDE/COMMON~1/MICROS~1/CMake/Ninja/ninja.exe cmTC_84703 && [1/2] Building C object CMakeFiles/cmTC_84703.dir/testCCompiler.c.obj
[2/2] Linking C executable cmTC_84703.exe
FAILED: cmTC_84703.exe
cmd.exe /C "cd . && C:\ws\progrmaming\Tools\Compilers\llvm-12.0.1\WIN64\bin\clang.exe -fuse-ld=lld-link -nostartfiles -nostdlib -O0 -fno-inline-functions -Xlinker /subsystem:console CMakeFiles/cmTC_84703.dir/testCCompiler.c.obj -o cmTC_84703.exe -Xlinker /MANIFEST:EMBED -Xlinker /implib:cmTC_84703.lib -Xlinker /pdb:cmTC_84703.pdb -Xlinker /version:0.0 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -loldnames && cd ."
lld-link: error: <root>: undefined symbol: mainCRTStartup
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
Happens if you set it like this, or in a toolchain file.