Hi retif,
initially I used the following CMakeLists.txt:
cmake_minimum_required(VERSION 3.28)
project(std_module_example CXX)
# Turning off extensions avoids and issue with the clang 16 compiler
# clang 17 and greater can avoid this setting
set(CMAKE_CXX_EXTENSIONS OFF)
# Set the version of C++ for the project
set(CMAKE_CXX_STANDARD 20)
# Create a library
add_library(foo)
# Add the module file to the library
target_sources(foo
PUBLIC
FILE_SET CXX_MODULES FILES
foo.cxx
)
# Create an executable
add_executable(hello main.cxx)
# Link to the library foo
target_link_libraries(hello foo)
The contents are the same as in https://www.kitware.com/import-cmake-the-experiment-is-over/. Then, I created a file mystd.cxx with the following contents:
module;
export import <vector>
export module mystd;
and I added an import in main.cxx:
import foo;
import mystd;
...
I used the following commands to generate the appropriate vector.gcm and mystd.gcm:
g++ -std=c++20 -fmodules-ts -flang-info-module-cmi -x c++-system-header
g++ -std=c++20 -fmodules-ts -flang-info-module-cmi -c mystd.cxx
Then I updated the CMakeLists.txt to take into account mystd.o but when I run ninja I get the following error:
main.cxx:2:1:
mystd: error: failed to read compiled module: Unknown CMI mapping
mystd: note: imports must be built before being imported
mystd: fatal error: returning to the gate for a mechanical issue