Bug 2276578 - Using iwyu with CMake does not produce output
Summary: Using iwyu with CMake does not produce output
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: iwyu
Version: 39
Hardware: x86_64
OS: Linux
unspecified
high
Target Milestone: ---
Assignee: Vitaly
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2024-04-23 07:43 UTC by lagoho7
Modified: 2024-04-24 01:17 UTC (History)
1 user (show)

Fixed In Version: iwyu-0.21-1.fc39
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2024-04-24 01:17:26 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description lagoho7 2024-04-23 07:43:03 UTC
This kinda feels like a repeat of https://bugzilla.redhat.com/show_bug.cgi?id=2215937.

Integrating iwyu into a CMake build system using CMAKE_C_INCLUDE_WHAT_YOU_USE and CMAKE_CXX_INCLUDE_WHAT_YOU_USE does not produce output.

The same steps work on Fedora 38.

There are 2 test files needed to reproduce this: `main.cpp` and `CMakeLists.txt`.

main.cpp:

```c++
#include <iostream>

#include <cstdio>

int main()
{
    std::cout << "Hello, World!" << std::endl;
    return 0;
}
```

CMakeLists.txt:

```cmake
cmake_minimum_required(VERSION 3.22)
project(iwyu_test)

set(CMAKE_CXX_STANDARD 17)

add_executable(iwyu_test main.cpp)
```

Reproducible: Always

Steps to Reproduce:
1. Fresh install Fedora 39 with the "C Development Tools and Libraries" group selected.
2. Update all packages: sudo dnf upgrade --refresh
3. Install required packages: sudo dnf install cmake iwyu
4. Put test files `main.cpp` and `CMakeLists.txt` into the same directory.
5. Configure CMake: cmake -B build -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE=include-what-you-use -DCMAKE_C_INCLUDE_WHAT_YOU_USE=include-what-you-use -DCMAKE_BUILD_TYPE=RelWithDebInfo
6. Start the build: cd build && cmake --build .
Actual Results:  
Build succeeds but there is no iwyu output.

Expected Results:  
```
Warning: include-what-you-use reported diagnostics:

/home/f38-test/iwyu-test/main.cpp should add these lines:

/home/f38-test/iwyu-test/main.cpp should remove these lines:
- #include <cstdio>  // lines 3-3

The full include-list for /home/f38-test/iwyu-test/main.cpp:
#include <iostream>  // for char_traits, operator<<, basic_ostream, endl, cout
---

```

Comment 1 Vitaly 2024-04-23 16:01:43 UTC
Good catch. Thank you.

I forgot to rebase F39 branch to version 0.21 with LLVM 17 support. It will be fixed shortly. Please test this update and give it positive karma.

Comment 2 Fedora Update System 2024-04-23 16:17:43 UTC
FEDORA-2024-c4396f7682 (iwyu-0.21-1.fc39) has been submitted as an update to Fedora 39.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-c4396f7682

Comment 3 Fedora Update System 2024-04-24 01:17:26 UTC
FEDORA-2024-c4396f7682 (iwyu-0.21-1.fc39) has been pushed to the Fedora 39 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.