vscode-cmake-tools
vscode-cmake-tools copied to clipboard
CMAKE_INSTALL_PREFIX for install process
With cmake (directly) it is possible to install a project with "temporarily" setting the install prefix, in the sense that CMAKE_INSTALL_PREFIX is not changed within the CmakeCache file.
The corresponding command would look like this:
cmake --install . --config <build type> --prefix <install prefix>
Is there a way to do this with cmake-tools, i.e., I guess cmake.install?
Does it work if you add "--prefix", "<install prefix>" to the cmake.buildArgs array?
I tried
"cmake.buildArgs": ["--prefix", "<install prefix>" ]
in the workspace settings (do you mean it this way?).
This does not work and yields the error
MSBUILD : error MSB1001: unknown switch
Switch: --prefix.vcxproj
MSBUILD : error MSB1009: Project file does not exis.
Switch: <install prefix>.vcxproj
Otherwise I tried
"cmake.buildArgs": ["--prefix <install prefix>" ] .
This yields the error
MSBUILD : error MSB1001: unknown switch
Switch: --prefix <install prefix>.vcxproj
Yes, I meant the first one. I haven't used it in my own projects, but looking at the code I thought it might have been supported. It seems that the --prefix might only be supported for the newer --install switch which is not currently used by this extension. It still generates a command like --build . --target install
Alright, can one expect to have that any time soon? Ideally, having the following 2 features would be nice:
- A way to do installation only, e.g.:
cmake --install . --config <build type> --prefix <install prefix> - A combination of building and pure installation, i.e., combining consecutively
cmake --build . --target installorcmake --build .andcmake --install . --config <build type> --prefix <install prefix>
I can't promise when this might be done, but we would accept a PR from the community that implements this behavior. It's possible all that needs to happen is to update the command based on the version of cmake being used and expose a new setting cmake.installArgs that will allow you to set additional switches during an "install".
Number 1. should definitely be implemented. Number 2. seems to be a lower priority to us since you would already be able to invoke both commands in sequence, but could perhaps be implemented by creating a new setting for it.
This issue is now marked as 'stale-old' due to there being no activity on it for the past 720 days. Unless the 'stale-old' label is removed or the issue is commented on, this will be remain open for at least 14 days and then it may be closed. If you would like to make this issue exempt from getting stale, please add the 'stale-exempt' label.
@guestieng CMake Presets supports the installDir field which should help you solve this. We also have the CMake: Install command.
Do these things help solve this issue?