【已解决】The plain signature for target_link_libraries has already been used with the target “run_imag 2021-05-12 21:57:08

cmake时报错

CMake Error at example/CMakeLists.txt:74 (target_link_libraries):
  The plain signature for target_link_libraries has already been used with
  the target "run_image_slam".  All uses of target_link_libraries with a
  target must be either all-keyword or all-plain.
  The uses of the plain signature are here:
   * /opt/cmake-3.19.1/share/cmake-3.19/Modules/FindCUDA.cmake:1903 (target_link_libraries)

出错的cmakelist代码处

foreach(EXECUTABLE_TARGET IN LISTS EXECUTABLE_TARGETS)
    # Set output directory for executables
    set_target_properties(${EXECUTABLE_TARGET} PROPERTIES
                          RUNTIME_OUTPUT_DIRECTORY_DEBUG "${PROJECT_BINARY_DIR}"
                          RUNTIME_OUTPUT_DIRECTORY_RELEASE "${PROJECT_BINARY_DIR}"
                          RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${PROJECT_BINARY_DIR}"
                          RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${PROJECT_BINARY_DIR}")
    #  if(USE_CUDASIFT)
    #         target_compile_definitions(${EXECUTABLE_TARGET} PRIVATE USE_CUDASIFT)
    #         target_link_libraries(${EXECUTABLE_TARGET} PRIVATE cudasift)#引入cudasift库
    # endif()
    # PangolinViewer is used on a priority basis
    if(USE_PANGOLIN_VIEWER)
        # Set macro flag
        target_compile_definitions(${EXECUTABLE_TARGET} PRIVATE USE_PANGOLIN_VIEWER)
        # Link viewer
        target_link_libraries(${EXECUTABLE_TARGET} PRIVATE pangolin_viewer)
    elseif(USE_SOCKET_PUBLISHER)
        # Set macro flag
        target_compile_definitions(${EXECUTABLE_TARGET} PRIVATE USE_SOCKET_PUBLISHER)
        # Link viewer
        target_link_libraries(${EXECUTABLE_TARGET} PRIVATE socket_publisher)
    endif()
    # Setup stack trace logger
    if(USE_STACK_TRACE_LOGGER)
        target_compile_definitions(${EXECUTABLE_TARGET} PRIVATE USE_STACK_TRACE_LOGGER)
        target_link_libraries(${EXECUTABLE_TARGET} PRIVATE ${GLOG_LIBRARIES})
    endif()
    # Setup google-perftools
    if(USE_GOOGLE_PERFTOOLS)
        target_compile_definitions(${EXECUTABLE_TARGET} PRIVATE USE_GOOGLE_PERFTOOLS)
        target_link_libraries(${EXECUTABLE_TARGET} PRIVATE ${GPERFTOOLS_LIBRARIES})
    endif()
    # Link OpenVSLAM
    target_link_libraries(${EXECUTABLE_TARGET}
                          PRIVATE
                          ${PROJECT_NAME}
                          opencv_imgcodecs
                          opencv_videoio
                          ${CUDA_cudadevrt_LIBRARY}
    #  LINK_DIRECTORIES(${PROJECT_SOURCE_DIR}/build1/lib/cudasift)
    # include popl and spdlog headers
    target_include_directories(${EXECUTABLE_TARGET}
                               PRIVATE
                               $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/3rd/popl/include>
                               $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/3rd/spdlog/include>)
endforeach()

1.2解决方法

将上述代码中的所有private都删除

二、新的问题

2.1问题描述

CMake Error at example/CMakeLists.txt:72 (target_compile_definitions):
  target_compile_definitions called with invalid arguments
CMake Error at example/CMakeLists.txt:103 (target_include_directories):
  target_include_directories called with invalid arguments
CMake Error at example/CMakeLists.txt:72 (target_compile_definitions):
  target_compile_definitions called with invalid arguments
CMake Error at example/CMakeLists.txt:103 (target_include_directories):
  target_include_directories called with invalid arguments
CMake Error at example/CMakeLists.txt:72 (target_compile_definitions):
  target_compile_definitions called with invalid arguments
CMake Error at example/CMakeLists.txt:103 (target_include_directories):
  target_include_directories called with invalid arguments

2.2 问题解决

出现上述错误的原因在于target_compile_definitions与target_include_directories函数需要指定type–<INTERFACE|PUBLIC|PRIVATE>

target_include_directories(<target> [SYSTEM] [BEFORE]
<INTERFACE|PUBLIC|PRIVATE> [items1...] [<INTERFACE|PUBLIC|PRIVATE>
[items2...] ...])

在target_compile_definition和target_include_directories函数中加入类型,如下所示

target_compile_definitions(${EXECUTABLE_TARGET} PUBLIC USE_PANGOLIN_VIEWER)#加入了PUBLIC
    target_include_directories(${EXECUTABLE_TARGET}
                               PUBLIC#加上这句
                               $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/3rd/popl/include>
                               $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/3rd/spdlog/include>)

1.显示The plain signature for target_link_libraries has already been used with the target "run_image_slam". All uses of target_link_libraries with a target must be either all-keyword or all-plain.时,将target_link_libraries函数中的<INTERFACE|PUBLIC|PRIVATE>删掉
2.显示called with invalid arguments时,是自己用的不对,检查函数原型和自己用的函数参数是否都匹配

【已解决】 The plain signature for target_link_libraries has already been used with the target "openvslam". 一、问题描述二、解决方法 一、问题描述 openvslam中用cudasft代替orb特征提取和匹配时,cmake编译报错: 指向src/openvslam/CMakeLists.txt The plain signature for target_link_libraries has already This guide makes several assumptions: 1) You have a Visual C++ compiler version 6.0 or higher. 2) You are an experienced programmer using C++. 3) You have familiarity with the MS-DOS operating system and command line utilities. The manual is intended for developers interested in using the OpenSSL toolkit and interested in using the OpenSSL libraries within their applications. It is also useful for gaining insight into Public Key Infrastructure (PKI) and Certificate Authority management as well as the usefulness of the OpenSSL command line tools. It tells the story of the key tools to build the program - linker and loader, including linking and loading, architecture, object files, memory allocation, symbol management, library relocation, loading and coverage, shared libraries, dynamic linking and loading, dynamically linked shared libraries, as well as some changes aimed at mature modern linker done and introduce an ongoing practice projects that use Perl language can be used to develop a small linker. 【本文目标】 通过本文实践,能在WINDOWS操作系统搭建UBUNTU 18.04 LTS环境,并在此环境编译成功EOS v1.0.5正式发布版本。 【前置条件】 有学习EOS环境搭建意向,不怕折腾。 【技术收获】 1)搭建UBUNTU 18.04 LTS环境 2)在硬件要求不满足官方要求的环境下EOS环境编译成功 3) EOS编译过程中的踩坑排查能力 编译血泪史 EOS主网上线没... 通过本文实践,能在WINDOWS操作系统搭建UBUNTU 18.04 LTS环境,并在此环境编译成功EOS v1.0.5正式发布版本。 【前置条件】 有学习EOS环境搭建意向,不怕折腾。 【技术收获】 1)搭建UBUNTU 18.04 LTS环境 2)在硬件要求不满足官方要求的环境下EOS环境编译成功 3) EOS编译过程中的踩坑排查能力 2,编译血泪史 EOS主网上线没... OpenvSLAM源码解析的博客写完第一篇《开源SLAM框架学习——OpenVSLAM源码解析: 第一节 安装和初探》之后,没想到过了三个月才写第二篇。主要是最近工作确实很忙,现在正在做一个基于全景相机的视觉定位的项目,但是整个项目就我一个人在做。不过幸运的是,这个项目目前已经获得了一些成果了,往后有时间我会在博客中与大家分享。趁着在跑实验数据的间隙开始我OpenVSLAM源码解析的第二篇。 ########################### 我是分割线 ################### 晚上用AS编译FDK-ACC库,百度一圈,WINDOW下 AS编译的配置很少,或者内容很旧,所以直接源码拖到AS中通过CMAKE编译,大体的配置了下结果发现通过这样配置,会报错,源码中的.h文件有的找不到,百度 google没有发现很有用的价值,到GITHUB转一圈,发现有个这个属性target_include_directories也是配置编译的头文件,所以用这个属性替换了上面的include属...