Home:ALL Converter>CMake CMAKE_INSTALL_PREFIX completely ignored

CMake CMAKE_INSTALL_PREFIX completely ignored

Ask Time:2021-10-12T22:33:11         Author:hasdrubal

Json Formatter

I'm trying to build protobuf on my windows machine according to this guide (official proto guide). Compiling works fine. But. I would like to install it in my workspace, where other project can have easy access to it. According to the guide I should specify the install prefix like so:

 C:\Path\to\protobuf\cmake\build\release>cmake -G "NMake Makefiles" ^
 -DCMAKE_BUILD_TYPE=Release ^
 -DCMAKE_INSTALL_PREFIX=../../../../install ^
 ../..

This does not have the desired effect as the end result installs in C:\ . Also if I use an env variable:

 $Env:CMAKE_INSTALL_PREFIX="C:/Users/uname/Workspace/protobuf-3.18.0/install"
 cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release ..\..

Or

 $Env:CMAKE_INSTALL_PREFIX="C:\Users\uname\Workspace\protobuf-3.18.0\install"
 cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release ..\..

I get a slightly different outcome. It tries to install in:

C:\Program files (x86)\Protobuf\lib

And off course fails due to lack of priveliges. Is it possible to arrange the env in powershell in such a way that cmake actually picks up the install prefix that I want?

Author:hasdrubal,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/69542399/cmake-cmake-install-prefix-completely-ignored
yy