Skip to content

Conversation

@ArcEarth
Copy link

The standard way of cmake install to a destination folder is the following pattern:

cd <BUILD_DIR>
cmake <SRC_DIR>
cmake --build <BUILD_DIR>
cmake --install <BUILD_DIR> --prefix <INSTALL_DIR>

Right now, the <INSTALL_DIR> folder passed in cmake --install command is ignored,
and always installed into C:/Program Files(x86)/..., which is the default
CMAKE_INSTALL_PREFIX value passed at the cmake <SRC_DIR> call.
Thus, it is not possible to install the binaries into different folders
without rerun the cmake/build process.

The important thing here is, the cmake variable CMAKE_INSTALL_PREFIX
is supposed to be passed at cmake --install time with the --prefix argument.
In cmake file, install with relative path will use that prefix automaticlly.
And it is the best practice to not include CMAKE_INSTALL_PREFIX
in the install(... DESTINATION ) argument:

In particular, there is no need to make paths absolute by prepending
CMAKE_INSTALL_PREFIX; this prefix is used by default if the DESTINATION is a relative path.

referenced from: https://cmake.org/cmake/help/latest/command/install.html

The standard way of cmake install to a destination folder is the following pattern:
```shell
cd <BUILD_DIR>
cmake <SRC_DIR>
cmake --build <BUILD_DIR>
cmake --install <BUILD_DIR> --prefix <INSTALL_DIR>
```
Right now, the `<INSTALL_DIR>` folder passed in cmake --install command is ignored,
and always installed into `C:/Program Files(x86)/...`, which is the default
`CMAKE_INSTALL_PREFIX` value passed at the `cmake <SRC_DIR>` call.
Thus, it is not possible to install the binaries into different folders
without rerun the cmake/build process.

The important thing here is, the cmake variable `CMAKE_INSTALL_PREFIX`
is supposed to be passed at `cmake --install` time with the `--prefix` argument.
In cmake file, `install` with relative path will use that prefix automaticlly.
And it is the best practice to not include CMAKE_INSTALL_PREFIX
in the `install(... DESTINATION )` argument:
```
In particular, there is no need to make paths absolute by prepending
CMAKE_INSTALL_PREFIX; this prefix is used by default if the DESTINATION is a relative path.
```
referenced from: https://cmake.org/cmake/help/latest/command/install.html
@daanx daanx changed the base branch from master to dev May 21, 2021 19:15
@daanx
Copy link
Collaborator

daanx commented May 21, 2021

Thanks @ArcEarth ; and thanks for the explanation; I will merge this :-)

@daanx daanx merged commit a732b76 into microsoft:dev May 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants