I want to use vtk in my team projection. I firstly install vtk, and collect the necessary dll, and the fold is:
In my CMakeLists.txt:
For VTK 8, the CMakeLists.txt is OK, but it cause bug for vtk 9.0.
target_link_libraries(Pro vtkCommonCore-9.0 ....) is OK for release, but it is wrong for debug. Because, the dll is
vtkCommonCore-9.0d for debug. The dll of debug has a more
d than that of release.
If I use
target_link_libraries(Pro vtkCommonCore-9.0d ....) , the code would be ok for debug but wrong for release.
Can I remove the
d in the dll of debug?
How can I fix this problem? Any suggestion is appreciated~~~
As far as I know, the way to do this “properly” is to not use “vtkCommonCore-9.0” as library name in CMake directly, instead, use:
if (VTK_VERSION VERSION_LESS "8.90.0")
For more info I would recommend checking the VTK examples, especially the Tutorial
find_package(VTK) is very convenient if I have compiled VTK from source code in my computer.
However, if I don’t want to compile VTK in my computer, I only want to use VTK by dll/lib/include. How can I do?
I have find one solution after reading the explanation of cmake.
The keyword of
optimized can distinguish debug/release.
But the above solution seem to be inconvenient.
cmake provides another two methods:
A plain library name
I use it as:
target_link_libraries(Pro -lvtkCommonCore), but it failed.
A generator expression.
I use it as
target_link_libraries(Pro vtkCommonCore-9.0$<1:d;2:"">), but it also failed.
You should use
VTK::CommonCore. That is a CMake target which will end up linking to the right thing for you.