# Scanning Control in 3.28 for module dependencies

**URL:** https://discourse.cmake.org/t/scanning-control-in-3-28-for-module-dependencies/9191
**Category:** Usage
**Created:** [October 12, 2023, 10:38pm UTC](https://discourse.cmake.org/t/scanning-control-in-3-28-for-module-dependencies/9191 "2023-10-12T22:38:28Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Codeboybebop](https://discourse.cmake.org/user_avatar/discourse.cmake.org/codeboybebop/32/3910_2.png) [@Codeboybebop](https://discourse.cmake.org/u/Codeboybebop)
#### Post date: [October 12, 2023, 10:38pm UTC](https://discourse.cmake.org/t/scanning-control-in-3-28-for-module-dependencies/9191/1 "2023-10-12T22:38:28Z")

</div>

I don’t understand the behavior of CMake scanning control.

My CmakeLists.txt is modification of example from [here](https://www.kitware.com/import-cmake-c20-modules/)

```auto
cmake_minimum_required(VERSION 3.26)
project(std_module_example CXX)

set(CMAKE_CXX_FLAGS "-lstdc++ -fuse-ld=lld -v")

set(CMAKE_CXX_STANDARD 20)
add_library(foo)
target_sources(foo
  PUBLIC
    FILE_SET cxx_modules TYPE CXX_MODULES FILES
    foo.cxx
)

add_executable(hello main.cxx)
target_link_libraries(hello PRIVATE foo)

#set_target_properties(hello PROPERTIES CXX_SCAN_FOR_MODULES on)

```

According to [cmake-cxxmodules(7)](https://cmake.org/cmake/help/git-stage/manual/cmake-cxxmodules.7.html) main.cxx will be scanned or not by the following rule:

1. If the source file belongs to a file set of type CXX\_MODULES, it will be scanned.

2. If the target does not use at least C++ 20, it will not be scanned.

3. If the source file is not the language CXX, it will not be scanned.

4. If the CXX\_SCAN\_FOR\_MODULES source file property is set, its value will be used.

5. If the CXX\_SCAN\_FOR\_MODULES target property is set, its value will be used. Set the CMAKE\_CXX\_SCAN\_FOR\_MODULES variable to initialize this property on all targets as they are created.

6. Otherwise, the source file will be scanned. See policy CMP0155.

In my case:

1. It does not belong to this set. Go for the next one
2. I hope set(CMAKE\_CXX\_STANDARD 20) will be applied to all target and sources, Go for next one
3. I hope the language is CXX since project(std\_module\_example CXX), Go for next one
4. Value is not set. Go for the next one
5. Value is not set. Go for the next one
6. File should be scanned.

However, if I build my project it fails to find imported module.

But, if I uncomment the last line everything will work perfectly.

Where is the flow in my logic?

---

<div class="post-metadata">

### Author: ![Codeboybebop](https://discourse.cmake.org/user_avatar/discourse.cmake.org/codeboybebop/32/3910_2.png) [@Codeboybebop](https://discourse.cmake.org/u/Codeboybebop)
#### Post date: [October 12, 2023, 10:48pm UTC](https://discourse.cmake.org/t/scanning-control-in-3-28-for-module-dependencies/9191/2 "2023-10-12T22:48:49Z")

</div>

If I use cmake\_minimum\_required(VERSION 3.28) everything works fine. I forgot that it is not just a version checker.
