VTK v9.1/Qt 5.15.6/${VTK_LIBRARIES} - dependencies wrong?

I am running on a Mac using vtk9.1 and Qt 5.15.6. I installed these via brew.

When I have ${VTK_LIBRARIES} in my “target_link_libraries”, a random -isystem /usr/local/include shows up in my link line breaking my build.

Is there a way to determine what added that random include directory? To the best of my knowledge, there is no way to print out the contents of the VTK:: stuff?

I am using ninja if it matters. The reason I can’t have /usr/local/include is that I also have Qt6 installed and it puts it in /usr/local. If I uninstall Qt6, it does work.

Thanks,
Joey

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).

@brad.king

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:
Boost_INCLUDE_DIR /usr/local/Cellar/boost/1.80.0/include

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.

Thanks for any further insight!

My compile line is:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -DALL_DB -DBOOST_SERIALIZATION_DYN_LINK -DBOOST_SERIALIZATION_NO_LIB -DDIY_NO_THREADS -DFMT_SHARED -DGL_SILENCE_DEPRECATION -DH5_BUILT_AS_DYNAMIC_LIB -DQT_CONCURRENT_LIB -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_OPENGL_LIB -DQT_PRINTSUPPORT_LIB -DQT_QMLMODELS_LIB -DQT_QML_LIB -DQT_QUICK_LIB -DQT_SQL_LIB -DQT_SVG_LIB -DQT_WIDGETS_LIB -DQT_XML_LIB -DVTK_HAS_OGGTHEORA_SUPPORT -DVTK_MAJOR_VERSION=9 -D_G3D_ -D_OPENGL2_ -Dkiss_fft_scalar=double -iframework /usr/local/Cellar/qt@5/5.15.6/lib -isystem /usr/local/Cellar/qt@5/5.15.6/lib/QtCore.framework/Headers -isystem /usr/local/Cellar/qt@5/5.15.6/./mkspecs/macx-clang -isystem /usr/local/Cellar/qt@5/5.15.6/lib/QtWidgets.framework/Headers -isystem /usr/local/Cellar/qt@5/5.15.6/lib/QtGui.framework/Headers -isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/OpenGL.framework/Headers -isystem /usr/local/Cellar/qt@5/5.15.6/lib/QtNetwork.framework/Headers -isystem /usr/local/Cellar/qt@5/5.15.6/lib/QtXml.framework/Headers -isystem /usr/local/Cellar/qt@5/5.15.6/lib/QtPrintSupport.framework/Headers -isystem /usr/local/include/vtk-9.1 -isystem /usr/local/include/vtk-9.1/vtkfreetype/include -isystem /usr/local/Cellar/glew/2.2.0_1/include -isystem /usr/local/Cellar/qt@5/5.15.6/lib/QtOpenGL.framework/Headers -iframework /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks -isystem /usr/local/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 -isystem /usr/local/Cellar/hdf5/1.12.2_2/include -isystem /usr/local/opt/libaec/include -isystem /usr/local/Cellar/theora/1.1.1/include -isystem /usr/local/Cellar/libogg/1.3.5/include -isystem /usr/local/include -isystem /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/libxml2 -isystem /usr/local/Cellar/gl2ps/1.4.2/include -isystem /Library/Frameworks/UnixImageIO.framework/Headers -isystem /usr/local/Cellar/qt@5/5.15.6/lib/QtSql.framework/Headers -isystem /Library/Frameworks/SQLite3.framework/Headers -isystem /usr/local/Cellar/qt@5/5.15.6/lib/QtQuick.framework/Headers -isystem /usr/local/Cellar/qt@5/5.15.6/lib/QtQmlModels.framework/Headers -isystem /usr/local/Cellar/qt@5/5.15.6/lib/QtQml.framework/Headers -isystem /usr/local/include/eigen3 -isystem /usr/local/include/double-conversion -isystem /usr/local/Cellar/lz4/1.9.4/include -isystem /usr/local/Cellar/xz/5.2.6/include -isystem /usr/local/include/utf8cpp -isystem /usr/local/Cellar/qt@5/5.15.6/lib/QtConcurrent.framework/Headers -isystem /usr/local/Cellar/qt@5/5.15.6/lib/QtSvg.framework/Headers -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk -mmacosx-version-min=11.6 -F/Library/Frameworks -fPIC -std=gnu++17 -MD -MT gPlot/VTK-6.0/CMakeFiles/g3d_VTK.dir/g3d_VTK_autogen/mocs_compilation.cpp.o -MF gPlot/VTK-6.0/CMakeFiles/g3d_VTK.dir/g3d_VTK_autogen/mocs_compilation.cpp.o.d -o gPlot/VTK-6.0/CMakeFiles/g3d_VTK.dir/g3d_VTK_autogen/mocs_compilation.cpp.o -c /Users/joey/work/CloudIR/sddas/ninja-mac/gPlot/VTK-6.0/g3d_VTK_autogen/mocs_compilation.cpp

I have this excerpt: grep “usr.local.include[^/]” trace.log | grep “INTERFACE”

/usr/local/lib/cmake/boost_headers-1.80.0/boost_headers-config.cmake(30): set_target_properties(Boost::headers PROPERTIES INTERFACE_INCLUDE_DIRECTORIES /usr/local/include )
/usr/local/lib/cmake/boost_headers-1.80.0/boost_headers-config.cmake(30): set_target_properties(Boost::headers PROPERTIES INTERFACE_INCLUDE_DIRECTORIES /usr/local/include )
/usr/local/lib/cmake/boost_program_options-1.80.0/libboost_program_options-variant-mt-shared.cmake(65): set_target_properties(Boost::program_options PROPERTIES INTERFACE_INCLUDE_DIRECTORIES /usr/local/include INTERFACE_COMPILE_DEFINITIONS BOOST_PROGRAM_OPTIONS_NO_LIB )
/usr/local/lib/cmake/boost_system-1.80.0/libboost_system-variant-mt-shared.cmake(65): set_target_properties(Boost::system PROPERTIES INTERFACE_INCLUDE_DIRECTORIES /usr/local/include INTERFACE_COMPILE_DEFINITIONS BOOST_SYSTEM_NO_LIB )
/usr/local/lib/cmake/boost_python-1.80.0/libboost_python-variant-mt-shared-py3.10.cmake(89): set_target_properties(Boost::python PROPERTIES INTERFACE_INCLUDE_DIRECTORIES /usr/local/include INTERFACE_COMPILE_DEFINITIONS BOOST_PYTHON_NO_LIB )
/usr/local/lib/cmake/netCDF/netCDFTargets.cmake(61): set_target_properties(netCDF::netcdf PROPERTIES INTERFACE_INCLUDE_DIRECTORIES /usr/local/include;/usr/local/include INTERFACE_LINK_LIBRARIES /usr/local/lib/libhdf5_hl.dylib;/usr/local/lib/libhdf5.dylib;/usr/local/lib/libsz.dylib;/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/lib/libz.tbd;/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/lib/libdl.tbd;/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/lib/libm.tbd;/usr/local/lib/libzstd.dylib;/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/lib/libbz2.tbd;/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/lib/libcurl.tbd;/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/lib/libxml2.tbd )
/usr/local/lib/cmake/vtk-9.1/FindJsonCpp.cmake(39): set_target_properties(JsonCpp::JsonCpp PROPERTIES IMPORTED_LOCATION /usr/local/lib/libjsoncpp.dylib IMPORTED_IMPLIB /usr/local/lib/libjsoncpp.dylib INTERFACE_INCLUDE_DIRECTORIES /usr/local/include )
/usr/local/lib/cmake/pugixml/pugixml-targets.cmake(56): set_target_properties(pugixml::pugixml PROPERTIES INTERFACE_INCLUDE_DIRECTORIES /usr/local/include INTERFACE_LINK_LIBRARIES pugixml::shared )
/usr/local/lib/cmake/pugixml/pugixml-targets.cmake(64): set_target_properties(pugixml::shared PROPERTIES INTERFACE_COMPILE_DEFINITIONS $<$BOOL:OFF:PUGIXML_WCHAR_MODE>;$<$BOOL:OFF:PUGIXML_COMPACT>;$<$BOOL:OFF:PUGIXML_NO_XPATH>;$<$BOOL:OFF:PUGIXML_NO_STL>;$<$BOOL:OFF:PUGIXML_NO_EXCEPTIONS> INTERFACE_INCLUDE_DIRECTORIES /usr/local/include )
/usr/local/lib/cmake/pugixml/pugixml-targets.cmake(72): set_target_properties(pugixml::static PROPERTIES INTERFACE_COMPILE_DEFINITIONS $<$BOOL:OFF:PUGIXML_WCHAR_MODE>;$<$BOOL:OFF:PUGIXML_COMPACT>;$<$BOOL:OFF:PUGIXML_NO_XPATH>;$<$BOOL:OFF:PUGIXML_NO_STL>;$<$BOOL:OFF:PUGIXML_NO_EXCEPTIONS> INTERFACE_INCLUDE_DIRECTORIES /usr/local/include )
/usr/local/lib/cmake/boost_serialization-1.80.0/libboost_serialization-variant-mt-shared.cmake(65): set_target_properties(Boost::serialization PROPERTIES INTERFACE_INCLUDE_DIRECTORIES /usr/local/include INTERFACE_COMPILE_DEFINITIONS BOOST_SERIALIZATION_NO_LIB )
/usr/local/lib/cmake/boost_headers-1.80.0/boost_headers-config.cmake(30): set_target_properties(Boost::headers PROPERTIES INTERFACE_INCLUDE_DIRECTORIES /usr/local/include )
/usr/local/lib/cmake/boost_program_options-1.80.0/libboost_program_options-variant-mt-shared.cmake(65): set_target_properties(Boost::program_options PROPERTIES INTERFACE_INCLUDE_DIRECTORIES /usr/local/include INTERFACE_COMPILE_DEFINITIONS BOOST_PROGRAM_OPTIONS_NO_LIB )

Joey

Don’t need boost anymore since I can use latest C++20 that includes all i needed before from boost. The following works beautifully for me:

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

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?

Oops, I didn’t edit my CMakeCache. I used ccmake to make the edits. I should have said that instead. And I am using a precompiled VTK. I’m not sure if it needs Boost.

It can. The Infovis and some IO bits use Boost (if you enable them). It is by no means a required dependency.

Sure, but VTK has code that uses Boost’s graph library which…C++20 definitely doesn’t have.

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.

Thanks,
Joey

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).