Fix CMake install absolute path to support --prefix option
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
In the line 898 of [libc/include/CMakeLists.txt](https://github.com/llvm/llvm-project/blob/main/libc/include/CMakeLists.txt), the variable `install_dir` is set to be absolute. And then it is used as the install destination in line 901.
```
set(install_dir ${CMAKE_INSTALL_PREFIX}/${resource_dir}/llvm_libc_wrappers/${nested_dir})
install(FILES ${decls_file}
DESTINATION ${install_dir}
COMPONENT libc-headers)
```
However, when attempting to use the --prefix option to relocate the installation destination, using an absolute path causes the installation to fail. This prevents the installation to custom prefixes and could lead to unintended issues. CMake also recommends using realtive path in `install(destination)`.
There are numerous similar fixes, such as this [example](https://github.com/rose-compiler/rose/commit/82ea6ae677a29fdab89b063073261a08be9387d4).
I think the variable `install_dir` should be set to a relative path, excluding `${CMAKE_INSTALL_PREFIX}`.
Contributor guide
Research direction
Start at libc/include/CMakeLists.txt lines 898-901 and inspect how install_dir is formed and passed to install(). Verify the behavior with a custom --prefix installation. Done means the libc wrapper headers install successfully under the requested prefix without using an absolute destination.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 65/100