-
Notifications
You must be signed in to change notification settings - Fork 29
Fully embrace GNUInstallDirs #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 3.6
Are you sure you want to change the base?
Conversation
CMakeLists.txt
Outdated
| cmake_path(RELATIVE_PATH CMAKE_INSTALL_FULL_LIBDIR BASE_DIRECTORY "${CMAKE_INSTALL_PREFIX}" OUTPUT_VARIABLE RELATIVE_LIBDIR) | ||
| cmake_path(RELATIVE_PATH CMAKE_INSTALL_FULL_INCLUDEDIR BASE_DIRECTORY "${CMAKE_INSTALL_PREFIX}" OUTPUT_VARIABLE RELATIVE_INCLUDEDIR) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use file(RELATIVE_PATH ...) for this. It's been around since before CMake 3, and wasn't even deprecated when cmake_path(RELATIVE_PATH ...) was added as a replacement, so it's not worth worrying about its removal for a long time yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I shied away from that because it requires access to the filesystem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just checked the source code, and the file commands that the docs say have been superseded by the cmake_path commands are purely lexical. E.g. https://gitlab.kitware.com/cmake/cmake/-/blob/master/Source/cmFileCommand.cxx#L1660 implements TO_CMAKE_PATH and TO_NATIVE_PATH, and it's just swapping slashes. RELATIVE_PATH's implementation is also purely lexical, but it calls functions that are spread around loads of files, so I can't be bothered to post links to the proof.
It's a valid reading of the docs, and consistent with the current state of the source code, that the reason the file versions of the commands were superseded was that they were purely lexical operations and lived in the supposedly-real-filesystem-operations command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's also worth pointing out that the explicit lexical implementation here isn't necessarily even correct for Windows, where slashes aren't the only thing that can be an absolute path root (e.g. the classic C:\whatever drive letter rooted path is absolute, but doesn't start with / or \).
|
Are you expecting any of the paths to end up different for platforms that aren't explicitly making them different by customising |
Not at all, except for WIN32's LIBDIR=bin config, that's why this extra handling needs to stay - when we look at the main section determining these install paths for osg-openmw so far, we see this correlating with -SET(INSTALL_INCDIR include)
-SET(INSTALL_BINDIR bin)
-IF(WIN32)
- SET(INSTALL_LIBDIR bin)
- SET(INSTALL_ARCHIVEDIR lib)
-ELSE()
- SET(INSTALL_LIBDIR lib${LIB_POSTFIX})
- SET(INSTALL_ARCHIVEDIR lib${LIB_POSTFIX})
-ENDIF()
|
- Consolidate the use of different variables for bin, lib and include
- Keep ${exec_prefix}/ in pkgconfig, deriving relative paths from std vars
- Use CMAKE_INSTALL_FULL_* where absolute paths are expected
- Ensure GNUInstallDirs is included early in the project
- For WIN32, keep the existing bin installdir for libraries, but set it up
front instead of per-subdirectory conditionals
Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
| LIBRARY DESTINATION lib COMPONENT libopenthreads | ||
| RUNTIME DESTINATION ${INSTALL_BINDIR} COMPONENT libopenthreads | ||
| RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libopenthreads | ||
| LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libopenthreads |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please note this was already deviating from elsewhere in osg where LIBRARY DESTINATION for WIN32 is bin instead of lib, so I kept it that way.
There may be a few occasions of bin/lib in WIN32 branches that I missed yet, and the CMake
<3.20fallback is a bit crude still.