@@ -112,6 +112,12 @@ if(MP_UNITS_BUILD_CXX_MODULES)
112112 message (FATAL_ERROR "CMake versions before 3.29 do not support C++ modules properly" )
113113 endif ()
114114 set (MP_UNITS_TARGET_SCOPE "PUBLIC" )
115+ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" )
116+ # Workaround for CMake 4.3 + Clang 20/21 incompatibility:
117+ # CMake 4.3 generates both `--precompile` and `-c` for @synth targets (CMake bug);
118+ # Clang 20/21 reports this as -Wunused-command-line-argument (now a default-on warning)
119+ add_compile_options (-Wno-error=unused-command-line-argument )
120+ endif ()
115121else ()
116122 set (MP_UNITS_TARGET_SCOPE "INTERFACE" )
117123endif ()
@@ -124,13 +130,11 @@ if(CMAKE_CXX_MODULE_STD)
124130 message (FATAL_ERROR "`import std;` requires at least C++23" )
125131 endif ()
126132 if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" )
127- # Workaround for two CMake 4.3 + Clang 21 incompatibilities:
128- # 1. CMake 4.3 generates both `--precompile` and `-c` for @synth targets (CMake bug);
129- # Clang 21 reports this as -Wunused-command-line-argument (now a default-on warning)
130- # 2. Clang 21 reports `export module std;` in libc++'s std.cppm as
131- # -Wreserved-module-identifier (now a default-on warning), because CMake compiles
132- # the stdlib module with the project's compiler flags
133- add_compile_options (-Wno-error=unused-command-line-argument -Wno-error=reserved-module-identifier )
133+ # Workaround for CMake 4.3 + Clang 21 incompatibility:
134+ # Clang 21 reports `export module std;` in libc++'s std.cppm as
135+ # -Wreserved-module-identifier (now a default-on warning), because CMake compiles
136+ # the stdlib module with the project's compiler flags
137+ add_compile_options (-Wno-error=reserved-module-identifier )
134138 endif ()
135139endif ()
136140
0 commit comments