2016-07-16 287 views
2

我下面从说明:如何在Windows上使用cmake构建Google protobuf环境?

https://github.com/google/protobuf/tree/master/cmake

cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release 
-DCMAKE_INSTALL_PREFIX=../../../../install/protobuf ../.. 

nmake install 

在我的程序的CMakeLists.txt我使用:

find_package(Protobuf REQUIRED) 

但它告诉我:

-- Could NOT find Protobuf (missing: Protobuf_LIBRARIES Protobuf_INCLUDE_DIR) 

我认为我应该设置设置环境变量。

有没有一种有效的方法来做到这一点?

protobuf-master/cmake/install.cmake

我可以看到这一点:

configure_file(protobuf-config.cmake.in 
    ${CMAKE_INSTALL_CMAKEDIR}/protobuf-config.cmake @ONLY) 
configure_file(protobuf-config-version.cmake.in 
    ${CMAKE_INSTALL_CMAKEDIR}/protobuf-config-version.cmake @ONLY) 
configure_file(protobuf-module.cmake.in 
    ${CMAKE_INSTALL_CMAKEDIR}/protobuf-module.cmake @ONLY) 
configure_file(protobuf-options.cmake 
    ${CMAKE_INSTALL_CMAKEDIR}/protobuf-options.cmake @ONLY) 

这些文件可以通过设置环境变量?我该如何使用它们?

回答

1

我更喜欢在我的项目的构建树中构建第三方库作为静态库。

我创建了一个cmake库来帮助解决这个问题。 protobuf是我支持的第一批图书馆之一。该文档是稀疏所以无论是随意问的问题或代码只是学习文件cmake/require_protobuf.cmake

库是在这里:https://github.com/madmongo1/sanity

如果你觉得自己贡献,我会很感激。

您将看到该脚本执行2次构建。一个在构建机器上构建protoc,另一个构建目标机器的protobuf库。

相关问题