cmake and make in Windows

前端 未结 2 1079
后悔当初
后悔当初 2021-02-04 10:09

I understand that in linux cmake, make and make install can be combined together to produce a release. For example:

cmake -DCMAKE_BUILD_TYPE=Release ..
make
make         


        
2条回答
  •  眼角桃花
    2021-02-04 11:00

    In addition to Fraser's answer, to get the first solution to work, one might need to call MSBuild in CMD as Administrator from the original path

    cmake ..
    "C:\Program Files (x86)\Microsoft Visual Studio\YEAR\EDITION\MSBuild\15.0\Bin\MSBuild.exe" INSTALL.vcxproj -p:Configuration=Release
    

    Replace YEAR and EDITION with your corresponding values e.g. 2017 and Community

    You might receive the following error, which means your enviroment variable is not set.

    error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.

    The enviroment variable can be set directly in the system settings or with CMD as Administrator. (Source for reference)

    for Visual Studio 2015 and below:

    SET VCTargetsPath="C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\vXXX\"
    

    Replace vXXX with your corresponding version e.g. 140

    for Visual Studio 2017 and above:

    SET VCTargetsPath="C:\Program Files (x86)\Microsoft Visual Studio\YEAR\EDITION\Common7\IDE\VC\VCTargets\"
    

    Replace YEAR and EDITION with your corresponding values e.g. 2017 and Community


    Edit:

    I've also noticed that some solutions in Visual Studio 2017 wont show their contents in the Solution Explorer if the enviroment variable is set. Just remove them again if necessary.

提交回复
热议问题