xtensor icon indicating copy to clipboard operation
xtensor copied to clipboard

OpenMP::OpenMP_CXX_xtensor not found

Open WenyinWei opened this issue 2 years ago • 7 comments

Platform: Windows xtensor: 0.23.10

Hi all, I have met some trouble when I use xtensor from my own code by target_link_libraries, could anybody tell me how to do it in the right way? I turned on XTENSOR_USE_OPENMP option when I cmake xtensor, it shall be linked when I cmake my library by targte_include_directory and target_link_libraries.

find_package(xtensor REQUIRED)
target_link_libraries(test_io PUBLIC xtensor xtensor-io)
CMake Error at test/CMakeLists.txt:9 (add_executable):
  Target "test_flt" links to target "OpenMP::OpenMP_CXX_xtensor" but the
  target was not found.  Perhaps a find_package() call is missing for an
  IMPORTED target, or an ALIAS target is missing?

It doesn't help for me to add OpenMP::OpenMP_CXX_xtensor in the lib list of target_link_libraries. The same CMakeLists works fine on Ubuntu with clang 13.0.

WenyinWei avatar Sep 27 '21 13:09 WenyinWei

I don't think that we provide or ask any target OpenMP::OpenMP_CXX_xtensor. I see it being used here https://github.com/xtensor-stack/xtensor/blob/fe81957365ce7eb56ea417bea95476c1344d7c31/CMakeLists.txt#L83-L110 but I think that that is only for testing of xtensor.

My guess is that you are placing xtensor as a subfolder of your package, and I don't think that the CMake support was designed for it. Rather, I think that you should install xtensor

tdegeus avatar Sep 28 '21 12:09 tdegeus

Thank you for your prompt reply on the issue. I didn't put xtensor as a subpackage yet indeed, but installed it. let me try some more commands on linking xtensor.

WenyinWei avatar Sep 28 '21 14:09 WenyinWei

Hi @WenyinWei . Your reply confuses me, if you installed it (using CMake or conda) I don't see for the moment how you could be faced with OpenMP::OpenMP_CXX_xtensor ?

tdegeus avatar Sep 28 '21 14:09 tdegeus

Yes! I am also pretty confused. How can I meet the error even after I have cmaked 'xtensor' and installed it by building INSTALL target in visual studio. Let me check once again when tomorrow I go back to my office desktop.

WenyinWei avatar Sep 28 '21 15:09 WenyinWei

I made sure that I did meet the trouble with the env:

  • Windows 10.0.19041.0,
  • CMake: 3.21.0 with option XTENSOR_USE_OPENMP ON,
  • xsimd: 7.6.0, xtensor: 0.23.10
  • VS 2019

As long as I wanna taget_link_libraries with xtensor, VS would tell me the error LNK110 that it fails opening OpenMP::OpenMP_CXX_xtensor.lib. The trouble could be avoided by XTENSOR_USE_OPENMP OFF brute-forcedly.

WenyinWei avatar Sep 30 '21 05:09 WenyinWei

@tdegeus There is another mention of OpenMP::OpenMP_CXX_xtensor in https://github.com/xtensor-stack/xtensor/blob/fe81957365ce7eb56ea417bea95476c1344d7c31/CMakeLists.txt#L240-L243 Should it be removed?

alexanderustinov avatar Aug 05 '22 02:08 alexanderustinov