MSVC default compiler/linker settings invoked by CMake

Hi,

I wonder where CMake gets the default settings when building the toolchain from scratch…?

So with a primitive 3 line CMakeLists.txt

cmake_minimum_required(VERSION 3.22.0)

project(DEFAULT_TEST VERSION 0.1.1)

add_executable(${PROJECT_NAME} main.cpp)

the resulting MSVC solution still includes e.g. the libraries “kernel32.lib” “user32.lib” etc (selected here just as an example since it is easy to search for), although (!!), and this is key, I removed them from

“Microsoft.Cpp.CoreWin.props”

This .props file is where the MSbuild takes the infos from, simply listed as text one after the other, which I edited/removed, so any solution created within the MSVC IDE does NO MORE include these libraries. But still Cmake does include them

Means, Cmake does include settings on top (!?) of what the MSBuild process does?

How can I control what settings Cmake is at the end generating?

(using any late MSVC version or Cmake version on Windows)

Cheers

Ebbo

update: I found, that Cmake does indeed compose the settings by its own (still not sure how the relation with MSbuild is). Line 256 in Windows-MSVC.cmake does create the string with the libs (and other default setting above and below).

CMAKE_C_STANDARD_LIBRARIES_INIT creates CMAKE_C_STANDARD_LIBRARIES, and this one is finally visible in the camke-gui, It even can be edited there, but of course only after (!) the configure is done. And then the libs are already listed. And I want them not even to show up.

If I set it in top level CMakeLists.txt

set( CMAKE_C_STANDARD_LIBRARIES “” )

it doesn’t change anything, looks like this is too late. And it’s anyways just for one special linker setting, it would take ~100 set() commands to individually change all of them (after reverse engineering the according name)

I’m new to cmake, but setting the basic compile/link parameters shouldn’t be such a pain for a make tool

solved: use the …CXX… variable, since my sample is a .cpp source, so

set( CMAKE_CXX_STANDARD_LIBRARIES “” )

does the job.

And so I learned, whatever general default setting I want to change, I have to parse the internal .cmake files to find out which variable finally sets the compiler and linker option. Still not sure, if this can be called cool…