How CXX_SCAN_FOR_MODULES is connected to precompiled headers?

Suppose we have the following files: src/main.cpp and src/PCH.h and the following cmake file:

cmake_minimum_required(VERSION 3.28)
project(Test)

set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_SCAN_FOR_MODULES ON)

add_executable(${PROJECT_NAME} src/main.cpp)
#target_precompile_headers("${PROJECT_NAME}" PRIVATE src/PCH.h)

If I generate a solution for MSVS 2022 I will have no ScanSourceforModuleDependencies property set in the project. But if I uncomment the PCH line I will have it in the project and it will be set to true for the main.cpp file. Why? What is the connection?

That is…interesting. Thanks for the report; I’ll look into it.

So it shouldn’t happen after all? That’s good to know because this behavior breaks the development on MSVS 2022 for me so I have to disable CMAKE_CXX_SCAN_FOR_MODULES as nothing else seems to help (see this bug report).

Can you please file a CMake issue as well? I don’t know when I’ll get the time to look at it (thought it’d be this week, but that is looking unlikely) and GitLab is far easier to manage these things than Discourse bookmarks.

Done.