CMake Tutorial Step5: install()

Hi All, signed up and creating this post to see what you, the community thinks of this issue and what my next steps are in resolving it, (I used PowerShell command Prompt):

PS C:\Work\Cmake\project5\build> cmake …\build
– Configuring done (0.0s)
– Generating done (0.2s)
– Build files have been written to: C:/Work/Cmake/project5/build
PS C:\Work\Cmake\project5\build> cmake --install .
– Install configuration: “Release”
CMake Error at MathFunctions/cmake_install.cmake:39 (file):
file INSTALL cannot find
“C:/Work/Cmake/project5/build/MathFunctions/Release/MathFunctions.lib”: No
error.
Call Stack (most recent call first):
cmake_install.cmake:37 (include)

AFAIK it’s a known limitation, that “install” does not depend on “all”. One has to do the build first.

install does depend on all; install/fast does not. I suspect the problem here is that MathFunctions doesn’t export symbols, so there’s no .lib to install.

1 Like

Cc: @betsy.mcphail since this is a tutorial thing.

Does C:/Work/Cmake/project5/build/MathFunctions/Release/MathFunctions.lib exist? The output does seem to suggest that it hasn’t been built yet. Does the command cmake --build . --target install work?

Hi! Thank you all for your support,
@betsy.mcphail , I’ve ran your command in my PowerShell Administrator, and I’ve gotten a whole bunch of error outputs:

PS C:\Work\Cmake\project5\build> PS C:\Work\Cmake\project5\build> cmake --build . --target install
Get-Process : A positional parameter cannot be found that accepts argument 'cmake'.
At line:1 char:1
+ PS C:\Work\Cmake\project5\build> cmake --build . --target install
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-Process], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.GetProcessCommand

PS C:\Work\Cmake\project5\build> MSBuild version 17.6.3+07e294721 for .NET Framework
MSBuild : The term 'MSBuild' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ MSBuild version 17.6.3+07e294721 for .NET Framework
+ ~~~~~~~
    + CategoryInfo          : ObjectNotFound: (MSBuild:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS C:\Work\Cmake\project5\build>
PS C:\Work\Cmake\project5\build>   SqrtLibrary.vcxproj -> C:\Work\Cmake\project5\build\MathFunctions\Debug\SqrtLibrary.lib
SqrtLibrary.vcxproj : The term 'SqrtLibrary.vcxproj' is not recognized as the name of a cmdlet, function, script file,
or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and
try again.
At line:1 char:3
+   SqrtLibrary.vcxproj -> C:\Work\Cmake\project5\build\MathFunctions\D ...
+   ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (SqrtLibrary.vcxproj:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS C:\Work\Cmake\project5\build>   MathFunctions.vcxproj -> C:\Work\Cmake\project5\build\MathFunctions\Debug\MathFunctions.lib
MathFunctions.vcxproj : The term 'MathFunctions.vcxproj' is not recognized as the name of a cmdlet, function, script
file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct
and try again.
At line:1 char:3
+   MathFunctions.vcxproj -> C:\Work\Cmake\project5\build\MathFunctions ...
+   ~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (MathFunctions.vcxproj:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS C:\Work\Cmake\project5\build>   Tutorial.vcxproj -> C:\Work\Cmake\project5\build\Debug\Tutorial.exe
Tutorial.vcxproj : The term 'Tutorial.vcxproj' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
At line:1 char:3
+   Tutorial.vcxproj -> C:\Work\Cmake\project5\build\Debug\Tutorial.exe
+   ~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Tutorial.vcxproj:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException


Suggestion [3,General]: The command Tutorial.vcxproj was not found, but does exist in the current location. Windows PowerShell does not load commands from the current location by default. If you trust this command, instead type: ".\Tutorial.vcxproj". See "get-help about_Command_Precedence" for more details.
PS C:\Work\Cmake\project5\build>   -- Install configuration: "Debug"
At line:1 char:5
+   -- Install configuration: "Debug"
+     ~
Missing expression after unary operator '--'.
At line:1 char:6
+   -- Install configuration: "Debug"
+      ~~~~~~~
Unexpected token 'Install' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : MissingExpressionAfterOperator

PS C:\Work\Cmake\project5\build>   -- Installing: C:/Program Files (x86)/Tutorial/lib/MathFunctions.lib
At line:1 char:5
+   -- Installing: C:/Program Files (x86)/Tutorial/lib/MathFunctions.li ...
+     ~
Missing expression after unary operator '--'.
At line:1 char:6
+   -- Installing: C:/Program Files (x86)/Tutorial/lib/MathFunctions.li ...
+      ~~~~~~~~~~~
Unexpected token 'Installing:' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : MissingExpressionAfterOperator

PS C:\Work\Cmake\project5\build>   CMake Error at MathFunctions/cmake_install.cmake:37 (file):
file : The term 'file' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:56
+   CMake Error at MathFunctions/cmake_install.cmake:37 (file):
+                                                        ~~~~
    + CategoryInfo          : ObjectNotFound: (file:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS C:\Work\Cmake\project5\build>     file INSTALL cannot copy file
file : The term 'file' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:5
+     file INSTALL cannot copy file
+     ~~~~
    + CategoryInfo          : ObjectNotFound: (file:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS C:\Work\Cmake\project5\build>     "C:/Work/Cmake/project5/build/MathFunctions/Debug/MathFunctions.lib" to
At line:1 char:74
+ ... :/Work/Cmake/project5/build/MathFunctions/Debug/MathFunctions.lib" to
+                                                                        ~~
Unexpected token 'to' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken

PS C:\Work\Cmake\project5\build>     "C:/Program Files (x86)/Tutorial/lib/MathFunctions.lib": Permission denied.
At line:1 char:60
+     "C:/Program Files (x86)/Tutorial/lib/MathFunctions.lib": Permissi ...
+                                                            ~
Unexpected token ':' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken

PS C:\Work\Cmake\project5\build>   Call Stack (most recent call first):
most : The term 'most' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:15
+   Call Stack (most recent call first):
+               ~~~~
    + CategoryInfo          : ObjectNotFound: (most:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS C:\Work\Cmake\project5\build>     cmake_install.cmake:37 (include)
include : The term 'include' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:29
+     cmake_install.cmake:37 (include)
+                             ~~~~~~~
    + CategoryInfo          : ObjectNotFound: (include:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS C:\Work\Cmake\project5\build>
PS C:\Work\Cmake\project5\build>
PS C:\Work\Cmake\project5\build> C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(160,5): e
C:\Program : The term 'C:\Program' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Micro ...
+ ~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Program:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS C:\Work\Cmake\project5\build> rror MSB3073: The command "setlocal [C:\Work\Cmake\project5\build\install.vcxproj]
>> C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(160,5): e
>> rror MSB3073: "C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=Debug -P cmake_install.cmake [C:\Work\Cmake\project5\
>> build\install.vcxproj]
>> C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(160,5): e
>> rror MSB3073: if %errorlevel% neq 0 goto :cmEnd [C:\Work\Cmake\project5\build\install.vcxproj]
>> C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(160,5): e
>> rror MSB3073: :cmEnd [C:\Work\Cmake\project5\build\install.vcxproj]
>> C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(160,5): e
>> rror MSB3073: endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone [C:\Work\Cmake\project5\build\install.vcxproj]
>> C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(160,5): e
>> rror MSB3073: :cmErrorLevel [C:\Work\Cmake\project5\build\install.vcxproj]
>> C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(160,5): e
>> rror MSB3073: exit /b %1 [C:\Work\Cmake\project5\build\install.vcxproj]
>> C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(160,5): e
>> rror MSB3073: :cmDone [C:\Work\Cmake\project5\build\install.vcxproj]
>> C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(160,5): e
>> rror MSB3073: if %errorlevel% neq 0 goto :VCEnd [C:\Work\Cmake\project5\build\install.vcxproj]
>> C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(160,5): e
>> rror MSB3073: :VCEnd" exited with code 1. [C:\Work\Cmake\project5\build\install.vcxproj]
rror : The term 'rror' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ rror MSB3073: The command "setlocal [C:\Work\Cmake\project5\build\ins ...
+ ~~~~
    + CategoryInfo          : ObjectNotFound: (rror:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

@Alex_Gaidachev you’ve run this:

but you were supposed to run

Sure, I ran your recommended line script:

PS C:\Work\Cmake\project5\build> cmake --build . --target install
MSBuild version 17.6.3+07e294721 for .NET Framework

  SqrtLibrary.vcxproj -> C:\Work\Cmake\project5\build\MathFunctions\Debug\SqrtLibrary.lib
  MathFunctions.vcxproj -> C:\Work\Cmake\project5\build\MathFunctions\Debug\MathFunctions.lib
  Tutorial.vcxproj -> C:\Work\Cmake\project5\build\Debug\Tutorial.exe
  -- Install configuration: "Debug"
  -- Installing: C:/Program Files (x86)/Tutorial/lib/MathFunctions.lib
  -- Installing: C:/Program Files (x86)/Tutorial/lib/SqrtLibrary.lib
  -- Installing: C:/Program Files (x86)/Tutorial/include/MathFunctions.h
  -- Installing: C:/Program Files (x86)/Tutorial/bin/Tutorial.exe
  -- Installing: C:/Program Files (x86)/Tutorial/include/TutorialConfig.h
PS C:\Work\Cmake\project5\build>

Which makes it so weird that it worked considering that my previous line was exactly like yours:

cmake --build . --target install

Your previous line started with PS C:\Work\Cmake\project5\build> (i.e. you copy-and-pasted the command prompt as part of the command to execute).