2010-07-11 361 views
12

這裏是我的簡單的CMakeLists.txt文件:set_target_properties調用的參數數量不正確?

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 can't 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 libusbmuxd 
    ARCHIVE 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 arguments

CMake error at CMakeLists.txt:13 (set_target_properties):
set_target_properties called with incorrect number of arguments
這些是第二和第三set_target_properties。第一個set_target_properties從來沒有這個問題?
(如果你還沒有已經意識到,我正在試圖建立usbmuxd-1.0.4)

回答

29

SET_TARGET_PROPERTIES的格式爲:

SET_TARGET_PROPERTIES(
    target1 target2 ... targetM 
    PROPERTIES 
    prop1 val1 prop2 val2 ... propN valN 
) 

的原因嗎?問題是你的變量LIBUSBMUXD_VERSION和LIBUSBMUXD_SOVERSION是不確定的,所以你的命令的語法是:

SET_TARGET_PROPERTIES(target PROPERTIES name) 

相反的:

SET_TARGET_PROPERTIES(target PROPERTIES name value) 

要解決此問題,請嘗試引用變量;使用「$ {LIBUSBMUXD_SOVERSION}」應該確保它接受空字符串的值,即使變量未定義也是如此,從而遵守語法。

+2

最後一句話正是解決了我的問題。不幸的是,我只能提出一次答案。謝謝! – ollo 2013-03-06 21:38:50

+0

我可以將一個列表作爲值嗎?立即,你會如何設置帶有多個標誌的LINKER_FLAG? – Royi 2018-02-21 00:29:30

相關問題