# How CXX\_SCAN\_FOR\_MODULES is connected to precompiled headers?

**URL:** https://discourse.cmake.org/t/how-cxx-scan-for-modules-is-connected-to-precompiled-headers/9631
**Category:** Usage
**Created:** [December 14, 2023, 9:51am UTC](https://discourse.cmake.org/t/how-cxx-scan-for-modules-is-connected-to-precompiled-headers/9631 "2023-12-14T09:51:34Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![ixsci](https://discourse.cmake.org/user_avatar/discourse.cmake.org/ixsci/32/2041_2.png) [@ixsci](https://discourse.cmake.org/u/ixsci)
#### Post date: [December 14, 2023, 9:51am UTC](https://discourse.cmake.org/t/how-cxx-scan-for-modules-is-connected-to-precompiled-headers/9631/1 "2023-12-14T09:51:34Z")

</div>

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

```auto
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?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [December 15, 2023, 1:26pm UTC](https://discourse.cmake.org/t/how-cxx-scan-for-modules-is-connected-to-precompiled-headers/9631/2 "2023-12-15T13:26:59Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ixsci](https://discourse.cmake.org/user_avatar/discourse.cmake.org/ixsci/32/2041_2.png) [@ixsci](https://discourse.cmake.org/u/ixsci)
#### Post date: [December 18, 2023, 6:50am UTC](https://discourse.cmake.org/t/how-cxx-scan-for-modules-is-connected-to-precompiled-headers/9631/3 "2023-12-18T06:50:42Z")

</div>

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](https://developercommunity.visualstudio.com/t/Scan-Sources-for-Module-Dependencies-cau/10541245)).

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [December 19, 2023, 3:53am UTC](https://discourse.cmake.org/t/how-cxx-scan-for-modules-is-connected-to-precompiled-headers/9631/4 "2023-12-19T03:53:58Z")

</div>

Can you please file [a CMake issue](https://gitlab.kitware.com/cmake/cmake/-/issues) 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.

---

<div class="post-metadata">

### Author: ![ixsci](https://discourse.cmake.org/user_avatar/discourse.cmake.org/ixsci/32/2041_2.png) [@ixsci](https://discourse.cmake.org/u/ixsci)
#### Post date: [December 19, 2023, 6:26am UTC](https://discourse.cmake.org/t/how-cxx-scan-for-modules-is-connected-to-precompiled-headers/9631/5 "2023-12-19T06:26:08Z")

</div>

[Done.](https://gitlab.kitware.com/cmake/cmake/-/issues/25519)
