I want to include a third package (VTK) in my project. The folder is:
Thirdparty
VTK
bin
Debug
xxxd.dll
...
Release
xxx.dll
...
include
xxx
...
lib
Debug
xxx
...
Release
...
In this package (VTK), there is d
suffix in the dll of debug. Just like: vtkCommonCore-9.0d.dll
(debug) vs vtkCommonCore9.0dll
(release).
In my CMakeLists.txt:
set(VTI_DIR "xxx/Thirdparty/VTK")
include_directories(
${VTK_DIR}/include
)
target_link_libraries(Pro
vtkCommonCore-9.0
....
)
If I use target_link_libraries(Pro vtkCommonCore-9.0d ....)
, the code would be ok for debug but wrong for release, because CMake cannot find vtkCommonCore-9.0d.dll
in Thirdparty/VTK/bin/Release
.
How can I implement the correct CMakeLists.txt
for this package (VTK)?
Any suggestion is appreciated!
Update:
After reading the explanation of target_link_libraries, I find a solution for my problem:
target_link_libraries(Pro
debug vtkCommonCore-9.0d
optimized vtkCommonCore-9.0
)
However, this method seem to be inconvenient.
target_link_libraries provides two method:
A plain library name
I use it as:
target_link_libraries(Pro -lvtkCommonCore)
And it failed.
A generator expression I use it as:
target_link_libraries(Pro vtkCommonCore-9.0$<1:d;2:"">)
And it failed.
I don't know how to use the above methods.