V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
MrVito
V2EX  ›  问与答

关于 cmake protobuf_generate_cpp 生成文件位置的疑问

  •  
  •   MrVito · Mar 30, 2020 · 3117 views
    This topic created in 2226 days ago, the information mentioned may be changed or developed.

    我知道这个命令会把文件生成在 build/ 里面,但是我看网上说,用

    target_include_directories(proto PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
    

    这个命令可以让生成的文件可以被其他目录中的文件读取到,但是在我这里没有生效……
    我的文件目录如下:
    ├── build
    ├── data
    ├── example
    ├── include
    │   ├── common
    │   ├── net
    │   ├── proto
    │   └── third_party
    └── server
    生成的文件都在 build 里面,proto 目录下的 CMakeLists.txt 如下

    file(GLOB PROTOFILES *.proto)
    
    protobuf_generate_cpp(PROTOBUFSRCS PROTOBUFHDRS ${PROTOFILES})
    
    message(STATUS ${PROTOBUFSRCS})
    
    add_library(proto ${PROTOBUFSRCS})
    target_link_libraries(proto protobuf)
    target_include_directories(proto PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
    

    求一位好心的大佬帮忙分析一下,感激不尽

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2369 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 05:53 · PVG 13:53 · LAX 22:53 · JFK 01:53
    ♥ Do have faith in what you're doing.