小编Kar*_*yer的帖子

CMake和FindProtobuf

我在协议缓冲区文件位于子目录的项目中使用FindProtobuf模块.我希望该子目录中的CMakeLists.txt文件调用protoc来生成CPP文件.我的项目文件夹结构如下:

cammy/CMakeLists.txt   # Root CMakeLists.txt
cammy/protofiles/test.proto # protofile
cammy/protofiles/CMakeLists.txt
Run Code Online (Sandbox Code Playgroud)

我有include(FindProtobuf),find_package调用和protobuf文件夹中CMakeLists.txt文件中对PROTOBUF_GENERATE_CPP的调用.

可执行构建步骤位于Root CMakeLists.txt文件中,我将生成的文件添加到此文件中的目标可执行文件中,即.

add_executable( ${EXEC} ${SRCS} ${PROTO_SRC} ${PROTO_HEADER} )
target_link_libraries( ${EXEC} ${PROTOBUF_LIBRARIES} )
Run Code Online (Sandbox Code Playgroud)

都在根CMakeLists.txt中定义

当我运行cmake时,它不会运行protoc来生成源文件,即使我将生成的源与可执行文件捆绑在一起从而创建依赖项.

当我将protofiles文件夹中的CMakeLists.txt的所有内容移动到根CMakeLists.txt时,将编译原型文件.

谁能帮我这个?我希望所有协议缓冲区构建内容都包含在protofiles文件夹中创建的CMakeLists.txt文件中.

我还注意到内部CMakeLists.txt(如PROTO_SRC)中生成的变量在打印时在内部文件中定义(即我得到正确生成的CPP文件名),但是当我在根文件中打印相同的变量时,它是空的.它几乎就像我需要"导出"(如果在cmake中有一种方法)变量输出到根文件夹.

任何帮助将非常感激.

谢谢Kartik

cmake protocol-buffers

13
推荐指数
1
解决办法
1万
查看次数

在Scala工作表中打印Futures的结果

我正在参加Coursera的Reactive编程课程,当我做其中一项任务时,我遇到了一些奇怪的东西.无论如何,我通过这个扩展为Future Companion对象添加了一些方法

implicit class FutureCompanionOps[T](val f: Future.type) extends AnyVal {

    /** Returns a future that is always completed with `value`.
     */
    def always[T](value: T): Future[T] = Future(value)

    /** Returns a future that is never completed.
     *
     *  This future may be useful when testing if timeout logic works correctly.
     */
    def never[T]: Future[T] = Promise().future


    /** Given a list of futures `fs`, returns the future holding the list of values of all the futures from `fs`.
     *  The returned future …
Run Code Online (Sandbox Code Playgroud)

monads scala scala-ide

11
推荐指数
2
解决办法
2084
查看次数

标签 统计

cmake ×1

monads ×1

protocol-buffers ×1

scala ×1

scala-ide ×1