SyneRBI / SIRF

Main repository for the CCP SynerBI software
http://www.ccpsynerbi.ac.uk
Other
60 stars 29 forks source link

Linking errors for "Eigen3::Eigen" while compiling SIRF from source #1061

Open mscipio opened 2 years ago

mscipio commented 2 years ago

Hi, I managed to build locally (I believe) all the dependencies for SIRF, but when I try to generate the build with cmake I get the following warning:

Target "MR_PROCESS_TESTDATA" links to target "Eigen3::Eigen" but the target
   was not found.  Perhaps a find_package() call is missing for an IMPORTED
   target, or an ALIAS target is missing?

I call it a warning as the generation of the build supposedly succeeds, but then when I try to run make install The process stops at some point and I believe it's because of this error in linking libraries.

I have tried to install Eigen3 with conda, and I have also compiled it manually (v3.4)

Do you have any suggestions about how to work around this issue?

I will attach the complete log or "missed links" I get from ccmake when I try to generate the build.

CMake Error at src/xGadgetron/cGadgetron/tests/CMakeLists.txt:74 (add_executable):
   Target "MR_PROCESS_TESTDATA" links to target "Eigen3::Eigen" but the target
   was not found.  Perhaps a find_package() call is missing for an IMPORTED
   target, or an ALIAS target is missing?

 CMake Error at /autofs/space/celer_001/users/software/miniconda3/envs/gadgetron/share/cmake-3.21/Modules/UseSWIG.cmake:894 (add_library):
   Target "_pygadgetron" links to target "Eigen3::Eigen" but the target was
   not found.  Perhaps a find_package() call is missing for an IMPORTED
   target, or an ALIAS target is missing?
 Call Stack (most recent call first):
   src/xGadgetron/pGadgetron/CMakeLists.txt:36 (SWIG_ADD_LIBRARY)

 CMake Error at /autofs/space/celer_001/users/software/miniconda3/envs/gadgetron/share/cmake-3.21/Modules/UseSWIG.cmake:894 (add_library):
   Target "_pyreg" links to target "Eigen3::Eigen" but the target was not
   found.  Perhaps a find_package() call is missing for an IMPORTED target, or
   an ALIAS target is missing?
 Call Stack (most recent call first):
   src/Registration/pReg/CMakeLists.txt:39 (SWIG_ADD_LIBRARY)

 CMake Error at /autofs/space/celer_001/users/software/miniconda3/envs/gadgetron/share/cmake-3.21/Modules/UseSWIG.cmake:894 (add_library):
   Target "_pystir" links to target "Eigen3::Eigen" but the target was not
   found.  Perhaps a find_package() call is missing for an IMPORTED target, or
   an ALIAS target is missing?
 Call Stack (most recent call first):
   src/xSTIR/pSTIR/CMakeLists.txt:37 (SWIG_ADD_LIBRARY)

 CMake Error at /autofs/space/celer_001/users/software/miniconda3/envs/gadgetron/share/cmake-3.21/Modules/UseSWIG.cmake:894 (add_library):
   Target "_pysirf" links to target "Eigen3::Eigen" but the target was not
   found.  Perhaps a find_package() call is missing for an IMPORTED target, or
   an ALIAS target is missing?
 Call Stack (most recent call first):
   src/common/CMakeLists.txt:66 (SWIG_ADD_LIBRARY)

 CMake Error at src/xGadgetron/cGadgetron/CMakeLists.txt:64 (add_library):
   Target "cgadgetron" links to target "Eigen3::Eigen" but the target was not
   found.  Perhaps a find_package() call is missing for an IMPORTED target, or
   an ALIAS target is missing?

 CMake Error at src/xGadgetron/cGadgetron/tests/CMakeLists.txt:98 (add_executable):
   Target "MR_TESTS_CPLUSPLUS" links to target "Eigen3::Eigen" but the target
   was not found.  Perhaps a find_package() call is missing for an IMPORTED
   target, or an ALIAS target is missing?

 CMake Error at src/xGadgetron/cGadgetron/tests/CMakeLists.txt:71 (add_library):
   Target "MR_TESTS_CPP_AUXILIARY" links to target "Eigen3::Eigen" but the
   target was not found.  Perhaps a find_package() call is missing for an
   IMPORTED target, or an ALIAS target is missing?

 CMake Error at src/Registration/cReg/CMakeLists.txt:127 (ADD_EXECUTABLE):
   Target "sirf_change_datatype" links to target "Eigen3::Eigen" but the
   target was not found.  Perhaps a find_package() call is missing for an
   IMPORTED target, or an ALIAS target is missing?

 CMake Error at src/Registration/cReg/CMakeLists.txt:48 (ADD_LIBRARY):
   Target "Reg" links to target "Eigen3::Eigen" but the target was not found.
   Perhaps a find_package() call is missing for an IMPORTED target, or an
   ALIAS target is missing?

 CMake Error at src/Registration/cReg/CMakeLists.txt:127 (ADD_EXECUTABLE):
   Target "sirf_nifti_maths" links to target "Eigen3::Eigen" but the target
   was not found.  Perhaps a find_package() call is missing for an IMPORTED
   target, or an ALIAS target is missing?

 CMake Error at src/Registration/cReg/CMakeLists.txt:127 (ADD_EXECUTABLE):
   Target "sirf_tensor_split_join" links to target "Eigen3::Eigen" but the
   target was not found.  Perhaps a find_package() call is missing for an
   IMPORTED target, or an ALIAS target is missing?

 CMake Error at src/Registration/cReg/CMakeLists.txt:127 (ADD_EXECUTABLE):
arget "sirf_crop_image" links to target "Eigen3::Eigen" but the target was
   not found.  Perhaps a find_package() call is missing for an IMPORTED
   target, or an ALIAS target is missing?

 CMake Error at src/Registration/cReg/CMakeLists.txt:127 (ADD_EXECUTABLE):
   Target "sirf_print_nifti_info" links to target "Eigen3::Eigen" but the
   target was not found.  Perhaps a find_package() call is missing for an
   IMPORTED target, or an ALIAS target is missing?

 CMake Error at src/Registration/cReg/CMakeLists.txt:127 (ADD_EXECUTABLE):
   Target "sirf_flip_or_mirror_image" links to target "Eigen3::Eigen" but the
   target was not found.  Perhaps a find_package() call is missing for an
   IMPORTED target, or an ALIAS target is missing?

 CMake Error at src/Registration/cReg/CMakeLists.txt:127 (ADD_EXECUTABLE):
   Target "sirf_inverse_transform" links to target "Eigen3::Eigen" but the
   target was not found.  Perhaps a find_package() call is missing for an
   IMPORTED target, or an ALIAS target is missing?

 CMake Error at src/Registration/cReg/CMakeLists.txt:127 (ADD_EXECUTABLE):
   Target "sirf_affine_to_disp" links to target "Eigen3::Eigen" but the target
   was not found.  Perhaps a find_package() call is missing for an IMPORTED
   target, or an ALIAS target is missing?

 CMake Error at src/Registration/cReg/tests/CMakeLists.txt:20 (ADD_EXECUTABLE):
   Target "REG_TEST_CPLUSPLUS" links to target "Eigen3::Eigen" but the target
   was not found.  Perhaps a find_package() call is missing for an IMPORTED
   target, or an ALIAS target is missing?

 CMake Error at src/xSTIR/cSTIR/CMakeLists.txt:37 (add_library):
   Target "cstir" links to target "Eigen3::Eigen" but the target was not
   found.  Perhaps a find_package() call is missing for an IMPORTED target, or
   an ALIAS target is missing?

 CMake Error at src/xSTIR/cSTIR/tests/CMakeLists.txt:24 (add_executable):
   Target "cstir_test4" links to target "Eigen3::Eigen" but the target was not
   found.  Perhaps a find_package() call is missing for an IMPORTED target, or
   an ALIAS target is missing?

 CMake Error at src/xSTIR/cSTIR/tests/CMakeLists.txt:20 (add_executable):
   Target "cstir_tests" links to target "Eigen3::Eigen" but the target was not
   found.  Perhaps a find_package() call is missing for an IMPORTED target, or
   an ALIAS target is missing?

 CMake Error at src/Synergistic/CMakeLists.txt:30 (ADD_EXECUTABLE):
   Target "sirf_convert_image_type" links to target "Eigen3::Eigen" but the
   target was not found.  Perhaps a find_package() call is missing for an
   IMPORTED target, or an ALIAS target is missing?

 CMake Error at src/Synergistic/CMakeLists.txt:30 (ADD_EXECUTABLE):
   Target "sirf_resample" links to target "Eigen3::Eigen" but the target was
   not found.  Perhaps a find_package() call is missing for an IMPORTED
   target, or an ALIAS target is missing?

 CMake Error at src/Synergistic/CMakeLists.txt:30 (ADD_EXECUTABLE):
   Target "sirf_do_images_match" links to target "Eigen3::Eigen" but the
   target was not found.  Perhaps a find_package() call is missing for an
   IMPORTED target, or an ALIAS target is missing?

 CMake Error at src/Synergistic/CMakeLists.txt:30 (ADD_EXECUTABLE):
   Target "sirf_registration" links to target "Eigen3::Eigen" but the target
   was not found.  Perhaps a find_package() call is missing for an IMPORTED
   target, or an ALIAS target is missing?

CMake Error at src/Synergistic/cSyn/CMakeLists.txt:24 (add_library):
   Target "csyn" links to target "Eigen3::Eigen" but the target was not found.
   Perhaps a find_package() call is missing for an IMPORTED target, or an
   ALIAS target is missing?

 CMake Error at src/Synergistic/cSyn/tests/CMakeLists.txt:21 (ADD_EXECUTABLE):
   Target "test_conv_img" links to target "Eigen3::Eigen" but the target was
   not found.  Perhaps a find_package() call is missing for an IMPORTED
   target, or an ALIAS target is missing?

 CMake Error at src/Synergistic/tests/CMakeLists.txt:42 (ADD_EXECUTABLE):
   Target "SYN_TEST_CPLUSPLUS" links to target "Eigen3::Eigen" but the target
   was not found.  Perhaps a find_package() call is missing for an IMPORTED
   target, or an ALIAS target is missing?

 CMake Error at src/common/CMakeLists.txt:23 (add_library):
   Target "csirf" links to target "Eigen3::Eigen" but the target was not
   found.  Perhaps a find_package() call is missing for an IMPORTED target, or
   an ALIAS target is missing?

 Generating done
KrisThielemans commented 2 years ago

Which version of Gadgetron are you using? The default one set by SIRF-SuperBuild/version_config.cmake?

I've had a look there and see the following occurences of Eigen in the CMake files:

gadgets/mri_core/CMakeLists.txt:                                    GenericReconEigenChannelGadget.h 
gadgets/mri_core/CMakeLists.txt:                                GenericReconEigenChannelGadget.cpp 
toolboxes/denoise/CMakeLists.txt:        ${EIGEN_INCLUDE_DIR}
toolboxes/solvers/CMakeLists.txt:  eigenTester.h
toolboxes/solvers/cpu/CMakeLists.txt:        ../eigenTester.h
test/performance/CMakeLists.txt:find_package(Eigen3)
test/performance/CMakeLists.txt:include_directories(${EIGEN_INCLUDE_DIR})

It doesn't make too much sense to me that find_package(Eigen3) occurs only in the test/performance but is used in toolboxes/denoise, but aside from that, I guess we'll need find_package(Eigen3) in our own CMakeLists.txt, if the Gadgetron toolboxes are used.

Possibly this is an optional dependency and none of our test systems has it, but you do.

can you try this, and generate a PR?

mscipio commented 2 years ago

Which version of Gadgetron are you using? The default one set by SIRF-SuperBuild/version_config.cmake?

This might be the issue, here, as I think I pulled the latest version of Gadgetron available on master

Before I try to recompile Gadgetron to the commit used in the SuperBuild (which I probably will have to do anyway at some point) do you have any suggestion about which (SIRF) CMakeLists.txt file should include

find_package(Eigen3)
include_directories(${EIGEN_INCLUDE_DIR})
KrisThielemans commented 2 years ago

I think you'll only need the find_package statement and put it here

I'm not sure if Gadgetron master will work. @evgueni-ovtchinnikov might be able to tell you (but not now). We know it needs a lot of adaptations to the SuperBuild for the dependencies, https://github.com/SyneRBI/SIRF-SuperBuild/pull/438, but SIRF is probably alright.

Let us know