VS: C++ modules fail when source files have same name
If two CXX_MODULES
file set members have the same name (in different directories), the generated .vcxproj
file fails to build:
>type ..\CMakeLists.txt
cmake_minimum_required(VERSION 3.27)
project(Example LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "aa1f7df0-828a-4fcd-9afc-2dc80491aca7")
add_executable(main main.cxx)
target_sources(main PUBLIC FILE_SET CXX_MODULES FILES a/same.cxx b/same.cxx)
>type ..\main.cxx
import a.same;
import b.same;
int main()
{
return a_same() + b_same();
}
>type ..\a\same.cxx
export module a.same;
export int a_same()
{
return 0;
}
>type ..\b\same.cxx
export module b.same;
export int b_same()
{
return 0;
}
>cmake --version
cmake version 3.27.0-rc3
...
>cmake .. -G "Visual Studio 17 2022"
...
>cmake --build . --config Debug
...
C:\...\a\same.cxx(6,1): error C3474: could not open output file 'C:\...\build\main.dir\Debug\same.cxx.ifc' [C:\...\build\main.vcxproj]
The problem is that both files use the same path and name for their .ifc
file.