This seems to work fine, but I am getting a long list of compiler warnings from A) the dictionary generated, e.g.
/build/myLibrary_dict.cxx:76:38: warning: use of old-style cast [clang-diagnostic-old-style-cast]
if (!fgIsA.load()) { R__LOCKGUARD(gInterpreterMutex); fgIsA = ::ROOT::GenerateInitInstanceLocal((const ::MLogging*)nullptr)->GetClass(); }
and B) ROOT itself, e.g.:
/root/include/THashTable.h:48:73: warning: conversion to ‘Int_t’ {aka ‘int’} from ‘UInt_t’ {aka ‘unsigned int’} may change the sign of the result [-Wsign-conversion]
48 | Int_t GetHashValue(const char *str) const { return ::Hash(str) % fSize; }
What is the recommended way of suppressing these warnings in the CMake configuration? It would be great if this could be added to the documentation!
You can try to disable the warnings for specific source files using something like: set_source_files_properties(myLibrary_dict.cxx PROPERTIES COMPILE_FLAGS "-Wno-old-style-cast")
And possibly the same for source files using ROOT headers (-Wno-sign-conversion)
(check for the correct flags)
You can also disable the warnings for the whole project, but I would advise not to.
And FYI, I’m just trying to guess here…
Checking /workspaces/build/myLibrary_dict.cxx ...
/root/include/ROOT/span.hxx:18:0: error: failed to evaluate #if condition [preprocessorErrorDirective]
# if __has_include(<span>)
Everyting compiles fine, but I am wondering whether you are aware of this and where this comes from. I am using ROOT Version: 6.30/06.
I also think its worth putting this in the documentation (e.g. Integrating ROOT into CMake projects - ROOT) as people will likely always want to disable warnings from third-party libaries and we definitely should not encourage them to disable the warnings on a project level.
Thanks for the feedback and for the solution. We’ll see where to add add a clang-tidy specific paragraph in the doc. Note that you can also open a GH pull request if you want…
I’m not aware, but I’m working on Windows… I’ll check on other platforms, but I think we would have seen it in our CI if it was the case…