Relative paths in `CMAKE_INSTALL_PREFIX`
- Dominant language
- C++
- Stars
- 7.5k
- Forks
- 1.1k
- Avg merge
- 47m
- Merged PRs (30d)
- 1
Description
In `draco_install.cmake`, `CMAKE_INSTALL_FULL_*` are used to define the destination for the different targets.
https://github.com/google/draco/blob/7ec8a2783f4c86d5f3c9120d1d58c7ce1b3094ef/cmake/draco_install.cmake#L26
However, when using these variables, `CMAKE_INSTALL_PREFIX` is effectively prepended twice when using a relative path.
Here is the output of my installation step when using `CMAKE_INSTALL_PREFIX` set to `./install`:
```
[...]
-- Installing: /home/michael/dev/draco/build/./install/./install/include/draco/draco_features.h
-- Installing: /home/michael/dev/draco/build/./install/./install/bin/draco_decoder-1.5.5
-- Installing: /home/michael/dev/draco/build/./install/./install/bin/draco_decoder
-- Installing: /home/michael/dev/draco/build/./install/./install/bin/draco_encoder-1.5.5
-- Installing: /home/michael/dev/draco/build/./install/./install/bin/draco_encoder
-- Installing: /home/michael/dev/draco/build/./install/./install/lib/libdraco.a
-- Installing: /home/michael/dev/draco/build/./install/./install/lib/pkgconfig/draco.pc
-- Installing: /home/michael/dev/draco/build/./install/./install/share/cmake/draco/draco-targets.cmake
-- Installing: /home/michael/dev/draco/build/./install/./install/share/cmake/draco/draco-targets-release.cmake
-- Installing: /home/michael/dev/draco/build/./install/./install/share/cmake/draco/draco-config.cmake
-- Installing: /home/michael/dev/draco/build/./install/./install/share/cmake/draco/draco-config-version.cmake
```
Moreover, it's causing a `find_package` failure.
In my case I'm calling `-Ddraco_DIR=/home/michael/dev/draco/build/install/install/share/cmake/draco` (note the `install` folder specified twice) and I got the following error:
```
CMake Error at
/home/michael/dev/draco/build/install/install/share/cmake/draco/drac
o-targets.cmake:83 (message):
The imported target "draco::draco" references the file
"/home/michael/dev/draco/build/./install/lib/libdraco.a"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete
successfully.
* The installation package was faulty and contained
"/home/michael/dev/draco/build/install/install/share/cmake/draco/dra
co-targets.cmake"
but not all the files it references.
```
As you can see, the `install` folder for `libdraco.a` is specified only once resulting in this failure.
Changing all the `CMAKE_INSTALL_FULL_*` to `CMAKE_INSTALL_*` fixes the problem.
My CMake version is 3.25.0 by the way but it's probably not relevant.
Contributor guide
Assessment
This issue has not been assessed yet.