代码之家  ›  专栏  ›  技术社区  ›  Mouaad Abdelghafour AITALI

调用CMake set target properties的参数数目不正确

  •  0
  • Mouaad Abdelghafour AITALI  · 技术社区  · 5 年前

    我正在尝试整合 抓斗 算法使用 开放简历 库,但在运行时出现此错误:

    生成命令失败。执行进程时出错 D:\Sdk\cmake\3.6.4111459\bin\cmake.exe带参数 {-HC:\Users\Mouad AITALI\AndroidStudioProjects\bgrever\app -BC:\Users\Mouad AITALI\AndroidStudioProjects\bgroove\app.cxx\cmake\debug\arm64-v8a -DANDROID_ABI=arm64-v8a-DANDROID_PLATFORM=android-16-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\Mouad AITALI\AndroidStudioProjects\bGroove\app\build\intermediates\cmake\debug\obj\arm64-v8a -D cmake_BUILD_TYPE=Debug-D android_NDK=D:\Sdk\NDK\19.2.5345600-DCMAKE_CXX_FLAGS=-std=c++11-DCMAKE_TOOLCHAIN_FILE=D:\Sdk\NDK\19.2.5345600\BUILD\cmake\android.TOOLCHAIN.cmake -D cmake_MAKE_PROGRAM=D:\Sdk\cmake\3.6.4111459\bin\ninja.exe-GAndroid Gradle-ninja} --配置不完整,出现错误!另请参见“C:/Users/Mouad AITALI/AndroidStudioProjects/bgrever/app/.cxx/cmake/debug/arm64-v8a/CMakeFiles/CMakeOutput.log”。

    CMake Error at CMakeLists.txt:13(设置目标属性):
    使用不正确的参数数调用set_target_properties。

    CMakeLists.txt文件

    #declare folder path
    set(pathToProject C:\\Users\\Mouad;AITALI\\AndroidStudioProjects\\BGREMOVER)
    
    cmake_minimum_required(VERSION 3.4.1)
    
    set(CMAKE_VERBOSE_MAKEFILE on)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
    
    include_directories(${pathToOpenCv}/sdk/native/jni/include)
    
    #library location
    add_library(lib_opencv SHARED IMPORTED)
    set_target_properties(lib_opencv PROPERTIES IMPORTED_LOCATION ${pathToProject}/app/src/main/jniLibs/${ANDROID_ABI}/libopencv_java3.so)
    
    #define libraries
    add_library(native-lib SHARED src/main/cpp/native-lib.cpp)
    add_library(grabcut SHARED src/main/cpp/jni-grabcut-lib.cpp src/main/cpp/grabcutter_p.cpp src/main/cpp/grabcutter_p.h)
    
    find_library(log-lib log)
    
    #target libraries
    target_link_libraries(native-lib ${log-lib} lib_opencv)
    target_link_libraries(grabcut ${log-lib} lib_opencv)
    
    1 回复  |  直到 5 年前
        1
  •  0
  •   Kevin Boris Azanov    5 年前

    如前所述,CMake使用分号 ; 定义列表。因此,如果路径包含分号,则必须将定义和使用变量的位置括起来 pathToProject 带双引号:

    set(pathToProject "C:\\Users\\Mouad;AITALI\\AndroidStudioProjects\\BGREMOVER")
    
    ...
    
    set_target_properties(lib_opencv PROPERTIES IMPORTED_LOCATION "${pathToProject}/app/src/main/jniLibs/${ANDROID_ABI}/libopencv_java3.so")
    

    这个 IMPORTED_LOCATION 属性只接受一个值。因此,当您提供该属性的列表时 set_target_properties() 命令无法正确分析参数,这将导致错误。