cpp-best-practices / cpp-best-practices/cmake_template

include-what-you-use is included but is not presented as a CMake option

Open Beginner friendly
#161 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
CMake
Stars
1.8k
Forks
204
PR merge metrics
No merged PRs in 30d

Description

In /cmake/StaticAnalyzers.cmake, the macro myproject_enable_include_what_you_use is declared.

However, myproject_enable_include_what_you_use is never actually set as an option elsewhere. Therefore, it's not possible to set it as an option in places like cmake-gui or based on the configuration.

For instance, myproject_enable_clang_tidy is right above it. I see that at the bottom of ProjectOptions.cmake that macro is called if myproject_ENABLE_CLANG_TIDY is set to true. There is no equivalent for myproject_enable_include_what_you_use.

It appears when iwyu was added, https://github.com/cpp-best-practices/cmake_template/blob/3a8c8f9793fb9805af558bfe097491e9a6efc97c/cmake/StaticAnalyzers.cmake was simpler. It did have `option(ENABLE_INCLUDE_WHAT_YOU_USE "Enable static analysis with include-what-you-use" OFF)`.

StaticAnalyzers.cmake has had some changes, but it appears

```cmake
macro(myproject_enable_include_what_you_use)
find_program(INCLUDE_WHAT_YOU_USE include-what-you-use)
if(INCLUDE_WHAT_YOU_USE)
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE ${INCLUDE_WHAT_YOU_USE})
else()
message(WARNING "include-what-you-use requested but executable not found")
endif()
endmacro()
```

is orphaned code that doesn't do anything. If I am mistaken hopefully, someone can explain this a little bit better to me. I've had to heavily edit my fork of this template because we can only support CMake 3.12 at this time, due to our usage of MSVS 2017. I'm doing some cleanup and noticed that iwyu is never really used. Looking at the code on the main branch, I don't see it being used so it's not like I unintentionally removed it.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in cmake/StaticAnalyzers.cmake and the bottom of ProjectOptions.cmake, comparing the include-what-you-use path with myproject_enable_clang_tidy and the earlier implementation linked in the issue. Configure the project or open cmake-gui to verify the include-what-you-use option is exposed and that enabling it reaches the existing macro.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake
Domain
build-system
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
82/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.