It looks like some third-party package that VTK uses is in /usr/local and its find_package impl does this. CMake should filter out include paths from the default set, but maybe SYSTEM interferes there.
I would run with --trace-expand and search the output for /usr/local/include being put into some INTERFACE_SYSTEM_INCLUDE_DIRECTORIES property. Once you have the target(s) that do it, we can investigate what logic needs improved (while CMake itself looks into fixing the -isystem /default/search/path bit).
Thank you for pointing me to --trace-expand. That was very helpful!
I changed the LZ4, LZMA, Theora, OGG, GL2PS, GLEW, FontConfig to their respective directories in the /usr/local/Cellar and it feels like it made some progress, but it still has a /usr/local/include right after the libogg.
Does VTK use Boost? I use Boost, but I have it set explicitly in my CMakeCache as:
Is there such thing as order of operations? My CMake is finding boost in the right places and going forward, but when VTK is being found, it doesn’t know/care it already has a Boost?
Is there a way to tell cmake when find_package’ing VTK to use my existing Boost?
Or if it is the netCDF or pugixml, I’m not sure how to change it since it is reading the stuff from cmake directories in /usr/local/lib/cmake/netCDF and /usr/local/lib/cmake/pugixml.
I’ve attached the relevant compile line and an excerpt from the trace-expand log.
If you still need it, it could help to find it automatically using FindPackage() ; I would not tamper with / hardcode anything explicit in the the CMakecache.txt file which can be regenerated.
Maybe I misunderstood what you exactly did though?
This is definitely a CMake Boost issue. Here’s what’s happening as far as I can tell:
I use Boost and have as an example in my CMakeLists.txt:
find_package (Boost REQUIRED COMPONENTS program_options)
This will allow me to set the Boost directory to something of my choosing so all my Boost code compiles without issue.
However, if other packages such as Qt or VTK also have a FindBoost, they will find it in /usr/local/include and ignore the boost directory of my choice.
Is this a deficiency of CMake? Is there a way to tell my find_package (VTK) or find_package (Qt) that if you need Boost, it is elsewhere? Or to use the cached directory of Boost so it won’t keep finding it?
Alternatively, am I writing my CMakeLists.txt wrong? I notice if I use Boost::program_options it doesn’t work for the same reason. It needs to link with Boost::program_options, but it puts the -system /usr/local/include on the compile/link line.
Again, the only reason I care is I have Qt5 and Qt6 on my system and would like to just use one or the other and don’t want /usr/local/include on the compile line.
How are you choosing the Boost you want? Does --debug-find show why VTK is searching elsewhere? Are you using a VTK install or build tree? VTK’s build tree (or non-relocatable install tree) will “help” by saying “here’s where I found my dependency X” and guide things in that direction.
Note that using two different Boost installations in the same process usually doesn’t work out well (unless at least one is mangled).