With this snipped, the example works with clang++-16
, but not with MSVC ?
#
# module with one internal partition
# see too:
# https://learn.microsoft.com/en-us/cpp/build/reference/internal-partition?view=msvc-170
#
add_library(mod2)
target_sources(
mod2
PRIVATE mod2/mod2price.cpp
PUBLIC FILE_SET
cxx_modules
TYPE
CXX_MODULES
FILES
mod2/mod2.cppm
mod2/mod2order.cppm # internal partition
)
set_target_properties(mod2 PROPERTIES CXX_STANDARD ${CMAKE_CXX_STANDARD})
if(CMAKE_SKIP_INSTALL_RULES AND CMAKE_BUILD_TYPE STREQUAL "Debug")
target_link_libraries(mod2 PUBLIC $<BUILD_INTERFACE:project_warnings project_options>)
endif()
add_executable(testmod2 mod2/testmod2.cpp)
target_link_libraries(testmod2 mod2)
add_test(NAME testmod2 COMMAND testmod2)
The log and the code can be found here: Build all modules with cmake and clang-16 on OSX · ClausKlein/cppstd20-code@71876d0 · GitHub
@ben.boeckel is this a usage error or an CMake
generator error?
@bill.hoffman Is there a portable way to work with partitions?
I tried also this branch Commits · mathstuf/cxx-modules-sandbox · GitHub without success.
Are you using the VS generator? This was recently fixed in VS and CMake.
https://gitlab.kitware.com/cmake/cmake/-/merge_requests/8471
So, you need a new version of CMake ad VS.
With WindowsToolchain
and current ninja
it works for static libs.
Only shared libs
still makes trouble: Build all modules with cmake and clang-16 on OSX · ClausKlein/cppstd20-code@58d6611 · GitHub
This seems an other problem.
[5/359] Linking CXX shared library bin\mod0D.dll
...
[7/359] Scanning D:\a\cppstd20-code\cppstd20-code\modules\mod0main.cpp for CXX dependencies
[8/359] Generating CXX dyndep file modules\CMakeFiles\mod0main.dir\CXX.dd
...
[14/359] Building CXX object modules\CMakeFiles\mod0main.dir\mod0main.cpp.obj
[15/359] Linking CXX executable bin\mod0main.exe
FAILED: bin/mod0main.exe
cmd.exe /C "cd . && "C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe --intdir=modules\CMakeFiles\mod0main.dir
--rc=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\mt.exe --manifests
-- C:\PROGRA~1\MICROS~2\2022\ENTERP~1\VC\Tools\MSVC\1435~1.322\bin\Hostx64\x64\link.exe /nologo
modules\CMakeFiles\mod0main.dir\mod0main.cpp.obj /out:bin\mod0main.exe /implib:modules\mod0main.lib /pdb:bin\mod0main.pdb
/version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console
-LIBPATH:C:\PROGRA~1\MICROS~2\2022\ENTERP~1\VC\Tools\MSVC\1435~1.322\ATLMFC\lib\x64
-LIBPATH:C:\PROGRA~1\MICROS~2\2022\ENTERP~1\VC\Tools\MSVC\1435~1.322\lib\x64
-LIBPATH:C:\PROGRA~1\MICROS~2\2022\ENTERP~1\VC\Tools\MSVC\1435~1.322\lib\x86\store\REFERE~1
-LIBPATH:C:\PROGRA~2\WI3CF2~1\10\lib\100226~1.0\ucrt\x64 -LIBPATH:C:\PROGRA~2\WI3CF2~1\10\lib\100226~1.0\um\x64
-LIBPATH:"C:\Program Files (x86)\Windows Kits\10\References\x64" modules\mod0D.lib kernel32.lib user32.lib gdi32.lib
winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
LINK Pass 1: command "C:\PROGRA~1\MICROS~2\2022\ENTERP~1\VC\Tools\MSVC\1435~1.322\bin\Hostx64\x64\link.exe /nologo
modules\CMakeFiles\mod0main.dir\mod0main.cpp.obj /out:bin\mod0main.exe /implib:modules\mod0main.lib /pdb:bin\mod0main.pdb
/version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console
-LIBPATH:C:\PROGRA~1\MICROS~2\2022\ENTERP~1\VC\Tools\MSVC\1435~1.322\ATLMFC\lib\x64
-LIBPATH:C:\PROGRA~1\MICROS~2\2022\ENTERP~1\VC\Tools\MSVC\1435~1.322\lib\x64
-LIBPATH:C:\PROGRA~1\MICROS~2\2022\ENTERP~1\VC\Tools\MSVC\1435~1.322\lib\x86\store\REFERE~1
-LIBPATH:C:\PROGRA~2\WI3CF2~1\10\lib\100226~1.0\ucrt\x64 -LIBPATH:C:\PROGRA~2\WI3CF2~1\10\lib\100226~1.0\um\x64
-LIBPATH:C:\Program Files (x86)\Windows Kits\10\References\x64 modules\mod0D.lib kernel32.lib user32.lib gdi32.lib
winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST
/MANIFESTFILE:modules\CMakeFiles\mod0main.dir/intermediate.manifest modules\CMakeFiles\mod0main.dir/manifest.res" failed
(exit code 1104) with the following output:
LINK : fatal error LNK1104: cannot open file 'modules\mod0D.lib'
Claus Klein:
bin\mod0D.dll
Looks like that problem to me. It is creating the .dll and that dll does not have a .lib file that happens when no symbols are exported. Are you doing anything to export symbols in your code?
OK, I have no export → no lib; I have to fix it. Thanks