2012-04-04 15 views
16

que estoy tratando de hacerlo misma manera lo hice para impulso:Cómo vincular las bibliotecas de protobuf de google a través de cmake en Linux?

find_package(Boost COMPONENTS system filesystem REQUIRED)              
find_package(ProtocolBuffers)                     

## Compiler flags                        
if(CMAKE_COMPILER_IS_GNUCXX)                     
    set(CMAKE_CXX_FLAGS "-O2")                    
    set(CMAKE_EXE_LINKER_FLAGS "-lsqlite3 -lrt -lpthread")             
endif()                          

target_link_libraries(complex                     
    ${Boost_FILESYSTEM_LIBRARY}                     
    ${Boost_SYSTEM_LIBRARY}                      
    ${PROTOBUF_LIBRARY}                       
) 

(buscado en Google en alguna parte), pero tiene mala salida:

CMake Warning at complex/CMakeLists.txt:18 (find_package): 
    Could not find module FindProtocolBuffers.cmake or a configuration file for 
    package ProtocolBuffers. 

    Adjust CMAKE_MODULE_PATH to find FindProtocolBuffers.cmake or set 
    ProtocolBuffers_DIR to the directory containing a CMake configuration file 
    for ProtocolBuffers. The file will have one of the following names: 

    ProtocolBuffersConfig.cmake 
    protocolbuffers-config.cmake 

¿Cómo puedo vincular con cmake? o tal vez incluso puedo compilar un archivo .proto usando cmake?

Respuesta

25

Usted podría intentar módulo de CMake FindProtobuf:

include(FindProtobuf) 
find_package(Protobuf REQUIRED) 
include_directories(${PROTOBUF_INCLUDE_DIR}) 
... 
target_link_libraries(complex 
    ${Boost_FILESYSTEM_LIBRARY} 
    ${Boost_SYSTEM_LIBRARY} 
    ${PROTOBUF_LIBRARY} 
) 


Para más información, ejecute

cmake --help-module FindProtobuf 
+2

Gracias por esta respuesta. En lugar de '$ {Boost_FILESYSTEM_LIBRARY}' y '$ {Boost_SYSTEM_LIBRARY}' puedes usar '$ {Boost_LIBRARIES}'. –

Cuestiones relacionadas