# Get the final install prefix at install-time

**URL:** https://discourse.cmake.org/t/get-the-final-install-prefix-at-install-time/2357
**Category:** Code
**Created:** [December 12, 2020, 2:01pm UTC](https://discourse.cmake.org/t/get-the-final-install-prefix-at-install-time/2357 "2020-12-12T14:01:10Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![Artemis](https://discourse.cmake.org/user_avatar/discourse.cmake.org/artemis/32/616_2.png) [@Artemis](https://discourse.cmake.org/u/Artemis)
#### Post date: [December 14, 2020, 8:49pm UTC](https://discourse.cmake.org/t/get-the-final-install-prefix-at-install-time/2357/4 "2020-12-14T20:49:02Z")

</div>

Hi @hex !  
The subproject containing the examples is included with a simple `add_subdirectory()`.  
It’s root `CMakeLists.txt` includes a module called `interface.cmake`.  
This module contains the code that defines the installation.  
When installing the examples subproject, the entire project source dir is copied. A new module called `interface.cmake` is installed in place of the old one. This new module contains the code that imports the installed library. This setup lets me write the example-specific cmake and completely ignore if the subproject is being used through the main library project or standalone, with the library installed.  
That said, the `CMAKE_INSTALL_PREFIX` is indeed set at configure time, but that’s just a default chosen by `GNUInstallDirs` or cmake itself. The actual install path can be specified, for example, in the `cmake --install` cli command. When you run that cli command, the configuration, generation and building phases are already done. I was wondering if it is visible at least to an install script.  
Turned out it is, and everything works. The question now is:

* * *

#### Where can I find a complete documentation of what’s available to cmake code ran in install script mode? And in standard script mode (cmake -P)? And a comparison between the two?

Also, as a side note:

> [@Artemis](#):
>
> I also noticed that the output breaks when installing in windows, using windows-style paths.
> 
> ```auto
> PS D:\Users\Nemo\OneDrive-shared\c\VisualT\cmake-build-debug-win> cmake --install . --component VisualT_examples --prefix "D:\Users\Nemo\Desktop\VisualT" --config Debug
> -- Installing: D:\Users\Nemo\Desktop\VisualT/share/VTExamples
> 
> ```
> 
> The installation process still works, but my `visualt_install_path` replaced with `configure_file` comes out incorrect. I fixed with a `file(TO_CMAKE_PATH ${visualt_install_path} visualt_install_path)` before the file configuration.

---

_[View the full topic](https://discourse.cmake.org/t/get-the-final-install-prefix-at-install-time/2357)._
