2016-07-16 286 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庫。

相關問題