Understanding “requests linking to directory” cmake warning

梦想与她 提交于 2020-12-26 08:27:24

问题


I am compiling an enormous code (100,000+ lines) on an Ubuntu 16.04 machine. In the process of doing so, during the cmake (v3.5.1) build process (before running make), I generate a raft of WARNINGS.

E.g.

WARNING: Target "gadgetron_moco" requests linking to directory "/usr/lib".  Targets may link only to libraries.  CMake is dropping the item.

Obviously, I can't repost the code here, but within the source code I found a moco/CMakeLists.txt. Here is a code fragment from that file:

if(CUDA_FOUND)
    add_library(gadgetron_moco SHARED
        cpuRegistrationAveragingGadget.h
        gadgetron_moco_export.h
        gpuRegistrationAveragingGadget.h
        gpuRegistrationScatteringGadget.h
        RegistrationAveragingGadget.h
        RegistrationScatteringGadget.h
        ${CPU_GADGETS}
        ${GPU_GADGETS}
      )

    set_target_properties(gadgetron_moco PROPERTIES VERSION ${GADGETRON_VERSION_STRING} SOVERSION ${GADGETRON_SOVERSION})

    target_link_libraries(gadgetron_moco
      gadgetron_gadgetbase
      gadgetron_toolbox_cpucore gadgetron_mricore ${CPU_LIBS} ${GPU_LIBS}
      ${Boost_LIBRARIES} ${ISMRMRD_LIBRARIES}
      optimized ${ACE_LIBRARIES} debug ${ACE_DEBUG_LIBRARY}
      )

    install (TARGETS gadgetron_moco DESTINATION lib COMPONENT main)
endif()

The command that I used to call cmake:

cmake -DCMAKE_INSTALL_PREFIX=/opt/gadgetron/ \
    -DCMAKE_CXX_COMPILER=/usr/bin/g++-5 \
    -DCMAKE_C_COMPILER=/usr/bin/gcc-5 \
    -DBoost_INCLUDE_DIR=/usr/include/ \
    -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-8.0/ \
    -DARMADILLO_LIBRARY=/usr/lib/ \
    -DARMADILLO_INCLUDE_DIR=/usr/include/ \
    -DMKLROOT_PATH=/opt/intel/ \
    -DZFP_INCLUDE_DIR=/opt/ZFP/inc \
    -DZFP_LIBRARY=/opt/ZFP/lib \
    -DCMAKE_PREFIX_PATH=/opt/ismrmrd/:/opt/siemens_to_ismrmrd:/usr/lib/ \
    -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON ..

Question: What is the warning exactly telling me? How do I go about debugging it?


回答1:


A "library" is a --file--!

The warning is about meaning of the word "library": it is a file (/path/to/xxx.so, /path/to/xxx.a or so), not a directory.

Assuming the project is correct, the warning signals about incorrect user-specified settings.

You set a variable ARMADILLO_LIBRARY, which is intended to contain a library, but you assign /usr/lib directory to that variable.



来源:https://stackoverflow.com/questions/54540885/understanding-requests-linking-to-directory-cmake-warning

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!