Show case:
// test.ixx
export module foo;
// No member is declared with dllexport, this is the simplest case.
// test.cpp
import foo;
int main() {}
CMakeLists.txt:
cmake_minimum_required(VERSION 4.1)
project(test)
set(BUILD_SHARED_LIBS ON)
set(CMAKE_CXX_STANDARD 23)
add_library(test)
add_executable(t
test.cpp
)
target_sources(test
INTERFACE
FILE_SET CXX_MODULES
FILES
test.ixx
)
target_link_libraries(t
PRIVATE
test
)
Apparently there is no test.lib
generated because target test
doesn’t export any symbol, and result in “LNK1104 cannot open file Debug\test.lib
”. As a workaround I must set CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS
to ON.
In header files time, I can add it as an interface library, but interface library doesn’t support modules…
So what is the solution for this problem? Thanks!