[vtkusers] CMake best practice for using VTK?
Elvis Stansvik
elvis.stansvik at orexplore.com
Mon Jun 27 15:44:14 EDT 2016
I'm using the trio
find_package(VTK REQUIRED)
include(${VTK_USE_FILE})
target_link_libraries(myapp ${VTK_LIBRARIES})
in my CMakeLists.txt, to find and link against VTK, like is done in the VTK
examples.
This results in the final link command:
/usr/bin/g++ -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -DQT_WIDGETS_LIB
-DvtkFiltersFlowPaths_AUTOINIT="1(vtkFiltersParallelFlowPaths)"
-DvtkIOExodus_AUTOINIT="1(vtkIOParallelExodus)"
-DvtkIOGeometry_AUTOINIT="1(vtkIOMPIParallel)"
-DvtkIOImage_AUTOINIT="1(vtkIOMPIImage)"
-DvtkIOParallel_AUTOINIT="1(vtkIOMPIParallel)"
-DvtkIOSQL_AUTOINIT="2(vtkIOMySQL,vtkIOPostgreSQL)"
-DvtkRenderingContext2D_AUTOINIT="1(vtkRenderingContextOpenGL)"
-DvtkRenderingCore_AUTOINIT="3(vtkInteractionStyle,vtkRenderingFreeType,vtkRenderingOpenGL)"
-DvtkRenderingFreeType_AUTOINIT="2(vtkRenderingFreeTypeFontConfig,vtkRenderingMatplotlib)"
-DvtkRenderingLIC_AUTOINIT="1(vtkRenderingParallelLIC)"
-DvtkRenderingVolume_AUTOINIT="1(vtkRenderingVolumeOpenGL)" -Isrc
-I/home/estan/Projekt/orexplore/dev/src/gui/src -I/usr/include/vtk
-I/usr/include/python3.5m -I/usr/include/freetype2 -I/usr/include/libxml2
-isystem /usr/include/qt -isystem /usr/include/qt/QtWidgets -isystem
/usr/include/qt/QtGui -isystem /usr/include/qt/QtCore -isystem
/usr/lib/qt/mkspecs/linux-g++ -O3 -DNDEBUG -fPIC -std=gnu++11 -MMD -MT
src/CMakeFiles/gui.dir/gui_automoc.cpp.o -MF
src/CMakeFiles/gui.dir/gui_automoc.cpp.o.d -o
src/CMakeFiles/gui.dir/gui_automoc.cpp.o -c src/gui_automoc.cpp
[6/6 0.0/sec] : && /usr/bin/g++ -O3 -DNDEBUG
src/CMakeFiles/gui.dir/main.cpp.o src/CMakeFiles/gui.dir/MainWindow.cpp.o
src/CMakeFiles/gui.dir/gui_automoc.cpp.o -o src/gui /usr/lib/
libpython3.5m.so /usr/lib/libvtkInfovisBoostGraphAlgorithms.so.1
/usr/lib/libvtkTestingRendering.so.1 /usr/lib64/libz.so
/usr/lib64/libjpeg.so /usr/lib64/libpng.so /usr/lib64/libtiff.so
/usr/lib/libvtkFiltersParallelFlowPaths.so.1
/usr/lib/libvtkFiltersFlowPaths.so.1 /usr/lib/libvtkRenderingLOD.so.1
/usr/lib64/libfreetype.so /usr/lib/libvtkWrappingTools.a
/usr/lib/libvtkIOMINC.so.1 /usr/lib/libvtkglew.so.1
/usr/lib64/libjsoncpp.so /usr/lib/libvtkRenderingQt.so.1
/usr/lib/libvtkFiltersTexture.so.1 /usr/lib/libvtkViewsContext2D.so.1
/usr/lib64/libgl2ps.so /usr/lib/libvtkFiltersParallelMPI.so.1
/usr/lib/libvtkViewsGeovis.so.1 /usr/lib/libvtkGeovisCore.so.1
/usr/lib64/libexpat.so /usr/lib/libvtkproj4.so.1 /usr/lib64/libxml2.so
/usr/lib/libvtkIOMPIParallel.so.1 /usr/lib/libvtkIOParallel.so.1
/usr/lib/libvtkIONetCDF.so.1 /usr/lib/libvtkRenderingParallelLIC.so.1
/usr/lib/libvtkRenderingLIC.so.1 /usr/lib/libvtkIOMySQL.so.1
/usr/lib/libvtkGUISupportQtWebkit.so.1 /usr/lib/libvtkDomainsChemistry.so.1
/usr/lib/libvtkRenderingFreeTypeFontConfig.so.1
/usr/lib/libvtkIOImport.so.1 /usr/lib/libvtkFiltersReebGraph.so.1
/usr/lib/libvtkFiltersProgrammable.so.1
/usr/lib/libvtkIOParallelExodus.so.1 /usr/lib/libvtkIOExodus.so.1
/usr/lib/libvtkIOFFMPEG.so.1 /usr/lib/libvtkIOMovie.so.1
/usr/lib64/libtheoraenc.so /usr/lib64/libtheoradec.so /usr/lib64/libogg.so
/usr/lib/libvtkIOParallelNetCDF.so.1 /usr/lib/libvtkFiltersGeneric.so.1
/usr/lib/libvtkIOGDAL.so.1 /usr/lib/libvtkRenderingParallel.so.1
/usr/lib/libvtkFiltersParallelStatistics.so.1 /usr/lib/libvtkIOExport.so.1
/usr/lib/libvtkIOGeoJSON.so.1 /usr/lib/libvtkRenderingMatplotlib.so.1
/usr/lib/libvtkPythonInterpreter.so.1 /usr/lib/libvtkIOXdmf3.so.1
/usr/lib/libvtkxdmf3.so /usr/lib/libvtkImagingMath.so.1
/usr/lib/libvtkImagingStatistics.so.1 /usr/lib/libvtkFiltersSMP.so.1
/usr/lib/libvtkIOXdmf2.so.1 /usr/lib/libvtkxdmf2.so.1
/usr/lib/libvtkIOParallelLSDyna.so.1 /usr/lib/libvtkIOLSDyna.so.1
/usr/lib/libvtkIOMPIImage.so.1 /usr/lib/libvtkLocalExample.so.1
/usr/lib/libvtkFiltersPython.so.1 /usr/lib/libvtkIOParallelXML.so.1
/usr/lib/libvtkFiltersVerdict.so.1 /usr/lib/libvtkverdict.so.1
/usr/lib/libvtkInteractionImage.so.1 /usr/lib/libvtkFiltersSelection.so.1
/usr/lib/libvtkIOEnSight.so.1 /usr/lib/libvtkIOInfovis.so.1
/usr/lib/libvtkRenderingImage.so.1 /usr/lib/libvtkIOPLY.so.1
/usr/lib/libvtkFiltersHyperTree.so.1 /usr/lib/libvtkParallelMPI4Py.so.1
/usr/lib/libvtkFiltersParallelImaging.so.1 /usr/lib/libvtkWrappingJava.so.1
/usr/lib/libvtkImagingMorphological.so.1 /usr/lib/libvtkIOPostgreSQL.so.1
/usr/lib/libvtkImagingStencil.so.1 /usr/lib/libvtkIOVPIC.so.1
/usr/lib/libvtkGUISupportQtOpenGL.so.1 /usr/lib/libvtkGUISupportQtSQL.so.1
/usr/lib/libvtkTestingIOSQL.so.1 /usr/lib/libvtkIOAMR.so.1
/usr/lib/libvtkFiltersParallelGeometry.so.1 /usr/lib/libvtkIOVideo.so.1
/usr/lib/libvtkTestingGenericBridge.so.1
/usr/lib/libvtkRenderingVolumeAMR.so.1 /usr/lib/libvtkIOODBC.so.1
/usr/lib/libvtkViewsQt.so.1 /usr/lib/libvtkViewsInfovis.so.1
/usr/lib/libvtkChartsCore.so.1 /usr/lib/libvtkInfovisLayout.so.1
/usr/lib/libvtkViewsCore.so.1 /usr/lib/libvtkexoIIc.so.1
/usr/lib/libvtkNetCDF_cxx.so.1 /usr/lib/libvtkNetCDF.so.1
/usr/lib/libvtkRenderingLabel.so.1 /usr/lib/libvtkRenderingGL2PS.so.1
/usr/lib/libvtkRenderingContextOpenGL.so.1
/usr/lib/libvtkRenderingContext2D.so.1 /usr/lib/libXdmfCore.so
/usr/lib64/libxml2.so /usr/lib/libvtkWrappingPython35Core.so.1
/usr/lib/libvtkInteractionWidgets.so.1 /usr/lib/libvtkFiltersHybrid.so.1
/usr/lib/libvtkRenderingAnnotation.so.1
/usr/lib/libvtkRenderingFreeType.so.1 /usr/lib64/libfreetype.so
/usr/lib/libvtkImagingColor.so.1 /usr/lib/libvtkInfovisCore.so.1
/usr/lib/libvtkIOXML.so.1 /usr/lib/libvtkIOXMLParser.so.1
/usr/lib/libvtkIOGeometry.so.1 /usr/lib/libpython3.5m.so
/usr/lib/libvtkFiltersImaging.so.1 /usr/lib/libvtkFiltersParallel.so.1
/usr/lib/libvtkFiltersModeling.so.1 /usr/lib/libvtkImagingGeneral.so.1
/usr/lib/libvtkImagingSources.so.1 /usr/lib/libvtkVPIC.so.1
/usr/lib/libvtkGUISupportQt.so.1 /usr/lib/libvtkInteractionStyle.so.1
/usr/lib/libQt5Widgets.so.5.7.0 /usr/lib/libQt5Gui.so.5.7.0
/usr/lib/libQt5Core.so.5.7.0 /usr/lib/libvtkhdf5_hl.so.1
/usr/lib/libvtkhdf5.so.1 -lm /usr/lib/libvtkParallelMPI.so.1
/usr/lib/libvtkFiltersAMR.so.1 /usr/lib/libvtkParallelCore.so.1
/usr/lib/libvtkIOLegacy.so.1 /usr/lib/libvtkRenderingVolumeOpenGL.so.1
/usr/lib/libvtkRenderingOpenGL.so.1 /usr/lib/libvtkImagingHybrid.so.1
/usr/lib/libvtkIOImage.so.1 /usr/lib/libvtkDICOMParser.so.1
/usr/lib/libvtkmetaio.so.1 /usr/lib64/libz.so /usr/lib64/libSM.so
/usr/lib64/libICE.so /usr/lib64/libX11.so /usr/lib64/libXext.so
/usr/lib64/libXt.so /usr/lib/libvtkRenderingVolume.so.1
/usr/lib/libvtkRenderingCore.so.1 /usr/lib/libvtkFiltersExtraction.so.1
/usr/lib/libvtkFiltersStatistics.so.1 /usr/lib/libvtkImagingFourier.so.1
/usr/lib/libvtkImagingCore.so.1 /usr/lib/libvtkalglib.so.1
/usr/lib/libvtkCommonColor.so.1 /usr/lib/libvtkFiltersGeometry.so.1
/usr/lib/libvtkFiltersSources.so.1 /usr/lib/libvtkFiltersGeneral.so.1
/usr/lib/libvtkFiltersCore.so.1
/usr/lib/libvtkCommonComputationalGeometry.so.1 /usr/lib/libvtkIOSQL.so.1
/usr/lib/libvtkIOCore.so.1 /usr/lib/libvtkCommonExecutionModel.so.1
/usr/lib/libvtkCommonDataModel.so.1 /usr/lib/libvtkCommonSystem.so.1
/usr/lib/libvtkCommonTransforms.so.1 /usr/lib/libvtksys.so.1 -ldl
/usr/lib/libvtkCommonMisc.so.1 /usr/lib/libvtkCommonMath.so.1
/usr/lib/libvtkCommonCore.so.1 /usr/lib/libvtksqlite.so.1 -lpthread
I'm surprised by two things:
1. The shear amount of libraries that are linked against. Are all these
really necessary, or is it possible to more selective somehow? Is there
something like Qt's CMake system, where you can pull in just a certain Qt
module with target_link_libraries(myapp Qt5::Widgets) ?
2. How come the .so files are specified directly as inputs, with their full
paths? Isn't the common method to just add the appropriate -l (and possibly
-L if needed) flags?
Cheers,
Elvis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160627/92553837/attachment.html>
More information about the vtkusers
mailing list