vscode-cmake-tools icon indicating copy to clipboard operation
vscode-cmake-tools copied to clipboard

CMAKE_INSTALL_PREFIX for install process

Open guestieng opened this issue 5 years ago • 7 comments

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?

guestieng avatar Oct 27 '20 18:10 guestieng

Does it work if you add "--prefix", "<install prefix>" to the cmake.buildArgs array?

bobbrow avatar Oct 27 '20 18:10 bobbrow

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

guestieng avatar Oct 27 '20 20:10 guestieng

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

bobbrow avatar Oct 27 '20 21:10 bobbrow

Alright, can one expect to have that any time soon? Ideally, having the following 2 features would be nice:

  1. A way to do installation only, e.g.: cmake --install . --config <build type> --prefix <install prefix>
  2. A combination of building and pure installation, i.e., combining consecutively cmake --build . --target install or cmake --build . and cmake --install . --config <build type> --prefix <install prefix>

guestieng avatar Oct 28 '20 12:10 guestieng

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.

bobbrow avatar Oct 30 '20 23:10 bobbrow

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.

github-actions[bot] avatar Oct 19 '23 16:10 github-actions[bot]

@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?

gcampbell-msft avatar Oct 02 '24 14:10 gcampbell-msft