Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@ What it does:
- Checks for Ninja/Visual Studio generator (required for modules)
- Sets up clang-tidy if enabled
- Adds compile_commands.json copy target
- Globally injects `-Qunused-arguments` into `CMAKE_CXX_FLAGS` for Clang/AppleClang

> [!NOTE]
>
> `-Qunused-arguments` is appended to `CMAKE_CXX_FLAGS` (not
> `add_compile_options`) so it is visible to CMake's C++20 module dependency
> scanning commands for imported targets. During scanning, `clang-scan-deps`
> passes both `--precompile` and `-c` to the compiler, making `-c` unused and
> producing noisy `clang++: warning: argument unused during compilation: '-c'`
> diagnostics. `-Qunused-arguments` suppresses this at the Clang driver level,
> where `-Wno-unused-command-line-argument` does not.

```cmake
libhal_project_init()
Expand Down
11 changes: 11 additions & 0 deletions v5/cmake/LibhalCMakeUtilConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ function(libhal_project_init)
message(FATAL_ERROR "C++20 modules require Ninja or Visual Studio generator")
endif()

# Suppress clang's "argument unused during compilation: '-c'" warning that
# fires during CMake's C++20 module dependency scanning phase.
# clang-scan-deps passes both --precompile and -c to the compiler, making
# -c unused. Using -Qunused-arguments via CMAKE_CXX_FLAGS (not
# add_compile_options) ensures the flag is visible to module scanning
# commands for imported targets.
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang")
string(APPEND CMAKE_CXX_FLAGS " -Qunused-arguments")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" PARENT_SCOPE)
endif()

# Set up clang-tidy if enabled
libhal_setup_clang_tidy()

Expand Down