How to use vtk in Cutsom C++ Project using CLion/CMake and Win10

Hello guys,

somehow I can’t get vtk to properly run in my project.
I have downloaded, build and installed vtk-9.3 on my local machine.
I can also find the VTK Packages and it’s modules, as well as reference the Header-Files.
For the Unit-Tests I’m using Googletest.

Implementation:

set(VTK_DIR "${CPP_LIBS_DIR}/vtk")
set(VTK_LIBRARIES "${VTK_DIR}/lib")
include_directories("${VTK_LIBRARIES}/vtk/lib")
..
find_package(VTK
        COMPONENTS REQUIRED
        CommonCore
        ImagingCore
        RenderingCore
        RenderingVolume
        RenderingOpenGL2
        RenderingVolumeOpenGL2
        IOLegacy
        FiltersCore
        vtksys)
..

target_link_libraries(aws_3d_nesting PRIVATE ${VTK_LIBRARIES})
vtk_module_autoinit(
        TARGETS aws_3d_nesting
        MODULES VTK::CommonCore VTK::ImagingCore VTK::RenderingCore VTK::RenderingVolume VTK::RenderingOpenGL2 VTK::RenderingVolumeOpenGL2 VTK::IOLegacy VTK::FiltersCore VTK::vtksys
)

Only when calling my Unit-Tests some Linker-Errors occure:

UnitTests.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl vtkDebugLeaksManager::vtkDebugLeaksManager(void)" (__imp_??0vtkDebugLeaksManager@@QEAA@XZ) referenced in function "void __cdecl `dynamic initializer for 'vtkDebugLeaksManagerInstance''(void)" (??__EvtkDebugLeaksManagerInstance@@YAXXZ)".

UnitTests.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl vtkDebugLeaksManager::~vtkDebugLeaksManager(void)" (__imp_??1vtkDebugLeaksManager@@QEAA@XZ) referenced in function "void __cdecl `dynamic atexit destructor for 'vtkDebugLeaksManagerInstance''(void)" (??__FvtkDebugLeaksManagerInstance@@YAXXZ)".

UnitTests.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl vtkObjectFactoryRegistryCleanup::vtkObjectFactoryRegistryCleanup(void)" (__imp_??0vtkObjectFactoryRegistryCleanup@@QEAA@XZ) referenced in function "void __cdecl `dynamic initializer for 'vtkObjectFactoryRegistryCleanupInstance''(void)" (??__EvtkObjectFactoryRegistryCleanupInstance@@YAXXZ)".

UnitTests.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl vtkObjectFactoryRegistryCleanup::~vtkObjectFactoryRegistryCleanup(void)" (__imp_??1vtkObjectFactoryRegistryCleanup@@QEAA@XZ) referenced in function "void __cdecl `dynamic atexit destructor for 'vtkObjectFactoryRegistryCleanupInstance''(void)" (??__FvtkObjectFactoryRegistryCleanupInstance@@YAXXZ)".

unitTest.exe : fatal error LNK1120: 4 unresolved externals

Also when i try to execute the .exe file I receive some missing dll errors (vtksys-9.3.dll etc.)
In my solution build folder there are also no DLL’s present.
I can’t find the issue that is causing this problems.
Has anybody an idea what might be the root of this?

Thanks in advance and best regards!

Can you show how UnitTests.cpp is getting compiled? I suspect that is not linking to VTK and might need to?