Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

include ITK #22641

Closed
Eric-JH opened this issue Jan 19, 2022 · 3 comments
Closed

include ITK #22641

Eric-JH opened this issue Jan 19, 2022 · 3 comments
Assignees
Labels
category:port-bug The issue is with a library, which is something the port should already support

Comments

@Eric-JH
Copy link

Eric-JH commented Jan 19, 2022

Describe the bug
I used vcpkg to manage the inclusion. In the CMakeLists.txt of my project, I included ITK. But the error occured. The content of CMakeLists is same as the example given by ITK docs.

Environment

  • OS: Windows 10
  • Compiler: msvc 2022

Failure logs
The log was given by MSVC
CMake Error at F:/Github/vcpkg/scripts/buildsystems/vcpkg.cmake:540 (_add_executable): Target "TestDll" links to target "GTest::Main" but the target was not found. Perhaps a find_package() call is missing for an IMPORTED target, or an ALIAS target is missing?

Additional context
CMakeLists.txt

@Cheney-W Cheney-W added the category:question This issue is a question label Jan 20, 2022
@Cheney-W
Copy link
Contributor

If you use the itk from vcpkg, please ensure that your project contains the following:
CMakeSettings.json:

"variables": [
   {
     "name": "CMAKE_TOOLCHAIN_FILE",
     "value": "{vcpkg_path}/scripts/buildsystems/vcpkg.cmake"
   }
 ]

CMakeLists.txt:

find_package(ITK CONFIG REQUIRED)
target_link_libraries(TestDll PRIVATE ITKFFT ITKVTK ITKznz itksys)

@Eric-JH
Copy link
Author

Eric-JH commented Jan 20, 2022

If you use the itk from vcpkg, please ensure that your project contains the following: CMakeSettings.json:

"variables": [
   {
     "name": "CMAKE_TOOLCHAIN_FILE",
     "value": "{vcpkg_path}/scripts/buildsystems/vcpkg.cmake"
   }
 ]

CMakeLists.txt:

find_package(ITK CONFIG REQUIRED)
target_link_libraries(TestDll PRIVATE ITKFFT ITKVTK ITKznz itksys)

I'm sure of my cmake-toolchain is right. And the main problem is why i can't use the example in ITK docs. I proposed the issue in ITK issues. And they thought the error was caused by vcpkg.
I understand the usage of target_link_libraries(TestDll PRIVATE ITKFFT ITKVTK ITKznz itksys). But I want a more convenient way to include, like ${g2o_LIBS} ${ceres_LIBRARIES} ${OpenCV_LIBS} so that I don't need to specify the module in CMakeLists. Now the problem is there is a similar way to include ITK according to ITK docs, but it's not feasible maybe due to vcpkg.

@dg0yt
Copy link
Contributor

dg0yt commented Jan 20, 2022

Thanks for pointing to the documentation. It gives another entry for #20190. It is a pity that not only the documented pattern of usage is not working, but also the vcpkg tool is promoting wrong usage patterns.

@Cheney-W Cheney-W added category:port-bug The issue is with a library, which is something the port should already support and removed category:question This issue is a question labels Jan 21, 2022
@Eric-JH Eric-JH closed this as completed Feb 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:port-bug The issue is with a library, which is something the port should already support
Projects
None yet
Development

No branches or pull requests

3 participants