I am using CLion (CMake 3.28.1) with gcc compiler version 14 and ninja version 13.2
All I am trying to do is create a simple module - just to test it for a larger project. But whatever I try to do, it always tells me the module I am exporting doesn't exist - but surely if I'm exporting it, then I'm making it - not trying to find it!
Directory Structure
ModulesTest cmake-build-debug b.cppm CMakeLists.txt main.cpp
CMakeLists.txt
# CMakeLists.txtcmake_minimum_required(VERSION 3.28)project(ModulesTest)set(CMAKE_CXX_STANDARD 20)set(CMAKE_CXX_SCAN_FOR_MODULES ON)add_executable(ModulesTest)target_sources(ModulesTest PUBLIC FILE_SET myModule TYPE CXX_MODULES FILES b.cppm)target_sources(ModulesTest PUBLIC b.cppm main.cpp)
b.cppm
//// Created by maxcu on 24/08/2024.//module;export module myModule;export float exprf(float x){ return x;}
main.cpp
import myModule;int main(){ exprf(3.14); return 0;}
Error
b.cppm: error: failed reading mapper 'CMakeFiles\ModulesTest.dir\b.ccpm.obj.modmap'b.cppm:5:8: error: unknown Compiled Module Interface: no such module5 | export module myModule; | ^~~~~~b.cppm:8: confused by earlier errors, bailing out
It basically says that it can't export myModule
as it's an unknown Compiled Module Interface
and therefore it doesn't exist.But the b.cppm
file is making the module. It's not importing it's exporting therefore it shouldn't be trying to find it, but rather define it. So it can't be an unknown CMI if I'm defining it!
I have tried every tutorial and variation thereof that I can and I always get this exact same error. No other tutorial mentions it being an error, they all assume it to work.