比较冷门的视频网站做搬运,网站怎么做seo关键词,在线制作图片加字合成,网站注册流程1 简介
这篇文章将探讨了在使用CMake构建C项目时#xff0c;调用set_target_properties函数时参数数量不正确所引发的问题。
2 错误案例
以下为可能发生错误的案例
include_directories (${CMAKE_SOURCE_DIR}/common)
find_package(Threads)add_library (libusbmuxd SHARE…1 简介
这篇文章将探讨了在使用CMake构建C项目时调用set_target_properties函数时参数数量不正确所引发的问题。
2 错误案例
以下为可能发生错误的案例
include_directories (${CMAKE_SOURCE_DIR}/common)
find_package(Threads)add_library (libusbmuxd SHARED libusbmuxd.c sock_stuff.c ${CMAKE_SOURCE_DIR}/common/utils.c)
find_library (PTHREAD pthread)
target_link_libraries (libusbmuxd ${CMAKE_THREAD_LIBS_INIT})# lib is a UNIXism, the proper CMake target is usbmuxd
# But we cant use that due to the conflict with the usbmuxd daemon,
# so instead change the library output base name to usbmuxd here
set_target_properties(libusbmuxd PROPERTIES OUTPUT_NAME usbmuxd)
set_target_properties(libusbmuxd PROPERTIES VERSION ${LIBUSBMUXD_VERSION})
set_target_properties(libusbmuxd PROPERTIES SOVERSION ${LIBUSBMUXD_SOVERSION})install(TARGETS libusbmuxdARCHIVE DESTINATION lib${LIB_SUFFIX}LIBRARY DESTINATION lib${LIB_SUFFIX}
)
install(FILES usbmuxd.h usbmuxd-proto.h DESTINATION include)以上文件可能报错如下
CMake error at CMakeLists.txt:12 (set_target_properties):set_target_properties called with incorrect number of arguments3 原因分析
set_target_properties 函数的语法格式为
SET_TARGET_PROPERTIES(target1 target2 ... targetMPROPERTIES prop1 val1 prop2 val2 ... propN valN
)变量LIBUSBMUXD_VERSION和LIBUSBMUXD_SOVERSION未定义因此命令的语法是
SET_TARGET_PROPERTIES(target PROPERTIES name value)很显然这里少了value变量
4 解决方法
要解决这个问题请尝试引用变量;使用“$ {LIBUSBMUXD_SOVERSION}”应确保即使变量未定义它也会采用空字符串的值从而遵守语法。
include_directories (${CMAKE_SOURCE_DIR}/common)
find_package(Threads)add_library (libusbmuxd SHARED libusbmuxd.c sock_stuff.c ${CMAKE_SOURCE_DIR}/common/utils.c)
find_library (PTHREAD pthread)
target_link_libraries (libusbmuxd ${CMAKE_THREAD_LIBS_INIT})# lib is a UNIXism, the proper CMake target is usbmuxd
# But we cant use that due to the conflict with the usbmuxd daemon,
# so instead change the library output base name to usbmuxd here
set_target_properties(libusbmuxd PROPERTIES OUTPUT_NAME usbmuxd)
set_target_properties(libusbmuxd PROPERTIES VERSION ${LIBUSBMUXD_VERSION})
set_target_properties(libusbmuxd PROPERTIES SOVERSION ${LIBUSBMUXD_SOVERSION})install(TARGETS libusbmuxdARCHIVE DESTINATION lib${LIB_SUFFIX}LIBRARY DESTINATION lib${LIB_SUFFIX}
)
install(FILES usbmuxd.h usbmuxd-proto.h DESTINATION include)