Skip to content

Conversation

@a17r
Copy link

@a17r a17r commented Jan 24, 2026

There may be a few occasions of bin/lib in WIN32 branches that I missed yet, and the CMake <3.20 fallback is a bit crude still.

CMakeLists.txt Outdated
Comment on lines 888 to 889
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)
Copy link
Member

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.

Copy link
Author

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.

Copy link
Member

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.

Copy link
Member

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 \).

@AnyOldName3
Copy link
Member

Are you expecting any of the paths to end up different for platforms that aren't explicitly making them different by customising GNUInstallDirs?

@a17r
Copy link
Author

a17r commented Jan 27, 2026

Are you expecting any of the paths to end up different for platforms that aren't explicitly making them different by customising GNUInstallDirs?

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 GNUInstallDirs defaults:

-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()
  • BINDIR user executables (bin)
  • LIBDIR object code libraries (lib or - if CMAKE_SYSTEM_NAME MATCHES "^(Linux|GNU)$" with further detection - lib64)
  • INCLUDEDIR C header files (include)

a17r added 2 commits January 27, 2026 21:16
- 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>
Comment on lines -51 to +49
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
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants