[Pkg-cmake-team] Bug#1102350: cmake 4.0 couldn't find correct std module source file
Leen Hawk
leenhawk at leenhawk.com
Tue Apr 8 06:47:20 BST 2025
Package: cmake
Version: 4.0.0
With these test file:
`CMakeLists.txt`:
```cmake
cmake_minimum_required(VERSION 4.0.0)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "a9e1cf81-9932-4810-974b-6eccaf14e457")
set(CMAKE_CXX_STANDARD_REQUIRED OFF)
set(CMAKE_CXX_MODULE_STD 1)
project(cpptest VERSION 0.1.0 LANGUAGES CXX)
add_executable(cpptest main.cpp)
```
`main.cpp`:
```cpp
import std;
int main(){
std::println("Hello world!");
}
```
It shows:
```shell
CMake Error at build/CMakeFiles/4.0.0/CMakeCXXCompiler.cmake:103 (target_sources):
Cannot find source file:
/usr/lib/gcc/x86_64-linux-gnu/include/c++/15/bits/std.cc
Call Stack (most recent call first):
/usr/share/cmake-4.0/Modules/CMakeTestCXXCompiler.cmake:91 (include)
CMakeLists.txt:8 (project)
CMake Error in CMakeLists.txt:
No SOURCES given to target: __CMAKE__CXX23 at synth_2e5b435a2e6c
CMake Generate step failed. Build files cannot be regenerated correctly.
```
I have change the `CMakeCXXCompiler.cmake`:
```
target_sources(__CMAKE::CXX23
INTERFACE
FILE_SET std TYPE CXX_MODULES
BASE_DIRS "/usr/lib/gcc/x86_64-linux-gnu/15/../include/c++/15/bits"
FILES "/usr/lib/gcc/x86_64-linux-gnu/15/../include/c++/15/bits/std.cc" "/usr/lib/gcc/x86_64-linux-gnu/15/../include/c++/15/bits/std.compat.cc")
endif ()
```
to
```
target_sources(__CMAKE::CXX23
INTERFACE
FILE_SET std TYPE CXX_MODULES
BASE_DIRS "/usr/include/c++/15/bits"
FILES "/usr/include/c++/15/bits/std.cc" "/usr/include/c++/15/bits/std.compat.cc")
endif ()
```
to fix it. And there is my issue on kitware cmake:https://gitlab.kitware.com/cmake/cmake/-/issues/26609
They have fixed in gentoo and fedora. But debian doesn't.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-cmake-team/attachments/20250408/ae27c6d4/attachment.htm>
More information about the Pkg-cmake-team
mailing list