V3.0.0 beta2以及之后都是CMake 創建VS Solution,project。 因為只能創建x64的項目工程,有時候需要x86的, 只能創建完x64后,自己修改工程配置弄成x86。
創建步驟參考 protobuf-3.0.0-beta-2/cmake/readme.md
C:\Path\to\protobuf\cmake\build>mkdir release & cd release
C:\Path\to\protobuf\cmake\build\release>cmake -G "NMake Makefiles" ^
-DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_INSTALL_PREFIX=../../../../install ^
../..
C:\Path\to\protobuf\cmake\build>mkdir debug & cd debug
C:\Path\to\protobuf\cmake\build\debug>cmake -G "NMake Makefiles" ^
-DCMAKE_BUILD_TYPE=Debug ^
-DCMAKE_INSTALL_PREFIX=../../../../install ^
../..
C:\Path\to\protobuf\cmake\build>mkdir solution & cd solution
C:\Path\to\protobuf\cmake\build\solution>cmake -G "Visual Studio 14 2015 Win64" ^
-DCMAKE_INSTALL_PREFIX=../../../../install ^
../..
cmake -G "Visual Studio 14 2015 Win64" ^
這里cmake只能創建x64的工程屬性,要不然是ARM的。 參考 https://cmake.org/cmake/help/v3.3/generator/Visual Studio 14 2015.html
只能生成x64的之后,在VS工程屬性中 【Link】
修改
【TargetMachine】
【addition options】
release 默認, debug 有debug
x86 ,x64
都有不同,看下拉設置。
To compile protobuf:
C:\Path\to\protobuf\cmake\build\release>nmake
or
C:\Path\to\protobuf\cmake\build\debug>nmake
Testing
To run unit-tests:
C:\Path\to\protobuf\cmake\build\release>nmake check
or
C:\Path\to\protobuf\cmake\build\debug>nmake check
Installing
To install protobuf to the specified install folder:
C:\Path\to\protobuf\cmake\build\release>nmake install
or
C:\Path\to\protobuf\cmake\build\debug>nmake install
