我有一个错误,而试图编译瓦尔哈拉应用我尝试编译使用cmake这样的代码:
find_package(Protobuf REQUIRED)
message(" --> PROTOBUF LIB: ${PROTOBUF_LIBRARIES}")
message(" --> PROTOBUF INCLUDE: ${PROTOBUF_INCLUDE_DIRS}")
message(" --> PROTOBUF VERSION: ${Protobuf_VERSION}")
message(" --> PROTOBUF Found: ${Protobuf_FOUND}")
if(EXISTS protobuf::libprotobuf-lite)
set(valhalla_protobuf_targets protobuf::libprotobuf-lite)
elseif(EXISTS protobuf::libprotobuf)
set(valhalla_protobuf_targets protobuf::libprotobuf)
else()
message(FATAL_ERROR "Required target protobuf::libprotobuf-lite or protobuf::libprotobuf is not defined")
endif()
这是CMake的代码给出了一个错误:
-- Found Protobuf: /usr/local/lib/libprotobuf.so;-pthread;-pthread (found version "3.6.1")
--> PROTOBUF LIB: /usr/local/lib/libprotobuf.so;-pthread;-pthread
--> PROTOBUF INCLUDE: /usr/local/include
--> PROTOBUF VERSION: 3.6.1
--> PROTOBUF Found: TRUE
CMake Error at CMakeLists.txt:143 (message):
Required target protobuf::libprotobuf-lite or protobuf::libprotobuf is not defined
我不明白为什么这个代码给我一个错误“要求的目标的protobuf :: libprotobuf - 精简版或protobuf的:: libprotobuf没有定义”
我试图改变存在于目标,但没有任何反应,结果是一样的
if(TARGET protobuf::libprotobuf-lite)
set(valhalla_protobuf_targets protobuf::libprotobuf-lite)
elseif(TARGET protobuf::libprotobuf)
set(valhalla_protobuf_targets protobuf::libprotobuf)
else()
message(FATAL_ERROR "Required target protobuf::libprotobuf-lite or protobuf::libprotobuf is not defined")
endif()
谁能帮我?我花了2天左右来解决这个
在FindProtobuf.cmake
的脚本version 3.7没有关于protobuf::*
目标概念:该脚本设置唯一的变量。 IMPORTED目标由自version 3.9脚本设置。
我是构建cmake的3.13,并安装它后,我尝试建立Valhall油田,但还是没有结果....我是打破我的头,但undestood认为原因是“>”:
if(TARGET protobuf::libprotobuf-lite>)
set(valhalla_protobuf_targets protobuf::libprotobuf-lite)
elseif(TARGET protobuf::libprotobuf>)
set(valhalla_protobuf_targets protobuf::libprotobuf)
else()
message(FATAL_ERROR "Required target protobuf::libprotobuf-lite or protobuf::libprotobuf is not defined")
endif()
之后,我删除“>”构建成功!