Some (but not all) targets in this export set were already defined

Viewed 300

I create a CMakeLists.txt and the content is as followed

cmake_minimum_required (VERSION 3.8)
project(CTP_dll)

add_library(CTPdll SHARED CTPdll.cpp)
add_executable(CTPTest CTPTest.cpp)
target_link_libraries(CTPTest CTPdll)

find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
target_link_libraries(CTPdll ${OpenCV_LIBS})

find_package(VTK REQUIRED)
include(${VTK_USE_FILE})
target_link_libraries(CTPTest ${VTK_LIBRARIES})

And the error info is

CMake Error at D:/vcpkg/installed/x64-windows/share/hdf5/hdf5-targets.cmake:37 (message): Some (but not all) targets in this export set were already defined.

Targets Defined: hdf5::hdf5-shared;hdf5::hdf5_hl-shared

Targets not yet defined: hdf5::hdf5_cpp-shared;hdf5::hdf5_hl_cpp-shared

If I delete the including of VTK as followed, no error will be reported. But obvious I can't include VTK in CTPTest.cpp, which is unacceptable.

cmake_minimum_required (VERSION 3.8)
project(CTP_dll)

add_library(CTPdll SHARED CTPdll.cpp)
add_executable(CTPTest CTPTest.cpp)
target_link_libraries(CTPTest CTPdll)

find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
target_link_libraries(CTPdll ${OpenCV_LIBS})

I compile this with Visual Studio 2022 on windows10 platform. There was a similar question on the web but nobody replied. So I propose this question and hope someone can help.

1 Answers
Related