jirislaby
(Jiri Slaby)
July 27, 2022, 6:01am
1
During debugging of this issue in stp’s cmake:
opened 04:59AM - 26 Jul 22 UTC
openSUSE build system defines:
```
-DCMAKE_INSTALL_PREFIX:PATH=%{_prefix}
-… DCMAKE_INSTALL_LIBDIR:PATH=%{_lib}
```
where:
```
$ rpm -E '%{_prefix} XX %{_lib}'
/usr XX lib64
```
I.e. `CMAKE_INSTALL_LIBDIR` is relative. Which is perfectly fine -- in fact https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html says:
> It should typically be a path **relative** to the installation prefix so that it can be converted to an absolute path in a relocatable way (see CMAKE_INSTALL_FULL_<dir>). However, an absolute path is also allowed.
So this test doesn't work properly:
https://github.com/stp/stp/blob/e8d153f196dcdf609add70e867f2188d58ffcc97/CMakeLists.txt#L191-L194
and rpath is set to "lib64". If you used `GNUInstallDirs`, you could use `CMAKE_INSTALL_FULL_LIBDIR` in the test above. I don't know how to solve it without `GNUInstallDirs`.
BTW. minisat has exactly the same problem:
https://github.com/stp/minisat/blob/37158a35c62d448b3feccfa83006266e12e5acb7/CMakeLists.txt#L86
We’ve come back to:
https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling#always-full-rpath
I don’t understand this part there:
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
...
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
if("${isSystemDir}" STREQUAL "-1")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
endif("${isSystemDir}" STREQUAL "-1")
What’s the purpose of the whole if
given CMAKE_INSTALL_RPATH
is set to ${CMAKE_INSTALL_PREFIX}/lib
above unconditionally?
ben.boeckel
(Ben Boeckel (Kitware))
August 2, 2022, 11:16am
2
I agree that it does look odd at least. I’d have to dig in more to figure out what it’s trying to do to figure it out myself though. It seems like it’s trying to make sure that the destination is in the rpath set, but only if it isn’t already a system location.