Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

24.04 always checking for include-what-you-use and cppcheck #50

Closed
Gerodote opened this issue Apr 16, 2024 · 1 comment
Closed

24.04 always checking for include-what-you-use and cppcheck #50

Gerodote opened this issue Apr 16, 2024 · 1 comment

Comments

@Gerodote
Copy link

How to reproduce:
git clone https://github.com/TheLartians/ModernCppStarter
cd ModernCppStarter
change symbol @ at cmake/tools.cmake:14 to #
cmake -S . -B ./build -DUSE_STATIC_ANALYZER=clang-tidy
should work just fine
change tag version in cmake/tools.cmake:14 from 23.04 to 24.04
get a next error:

|| CMake Error at /home/paxu/.cache/cpm/cmake-scripts/3a2aeaa8fc08089d36c491d5e0bfc2c2b3d9e1ef/tools.cmake:88 (message):
||   include-what-you-use not found!
|| Call Stack (most recent call first):
||   /home/paxu/code/uni/matvienko/lab2/mylab/cmake/tools.cmake:58 (include_what_you_use)
||   CMakeLists.txt:8 (include)
|| 
|| 
|| CMake Error at /home/paxu/.cache/cpm/cmake-scripts/3a2aeaa8fc08089d36c491d5e0bfc2c2b3d9e1ef/tools.cmake:136 (message):
||   cppcheck not found!
|| Call Stack (most recent call first):
||   /home/paxu/code/uni/matvienko/lab2/mylab/cmake/tools.cmake:59 (cppcheck)
||   CMakeLists.txt:8 (include)
|| 

Please, tell what changed, or tell how ModernCppStarter should be reworked

@StableCoder
Copy link
Owner

I had a few emails from people who didn't want to use the options/flags I had used originally, and wanted to have more control via options within their own projects. Thus in 23.09, the tools.cmake items were reworked:

Rework of tools.cmake items. The options of CLANG_TIDY, IWYU and CPPCHECK have been removed. Instead, it is up to the including project on when/how to enable these tools. The ability to 'reset' the tools, to disable them for certain scopes has been accommodated via the use of reset_* macros.

Quite simply, you should be able to add options and put the macro calls of include_what_you_use and cppcheck in an if statement.

To remake the exact behaviour from before for tools.cmake, you can change something like this:

clang_tidy(...)
include_what_you_use(...)
cppcheck(...)

to

option(CLANG_TIDY "Turns on clang-tidy processing if it is found." OFF)
if(CLANG_TIDY)
  clang_tidy(...)
endif()

option(IWYU "Turns on include-what-you-use processing if it is found." OFF)
if(IWYU)
  include_what_you_use(...)
endif()

option(CPPCHECK "Turns on cppcheck processing if it is found." OFF)
if(CPPCHECK)
  cppcheck(...)
endif()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants