Skip to content

CMake: fix absolute install dirs #2006

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

Merged
merged 2 commits into from
Aug 16, 2025
Merged

CMake: fix absolute install dirs #2006

merged 2 commits into from
Aug 16, 2025

Conversation

nim65s
Copy link
Contributor

@nim65s nim65s commented Aug 8, 2025

CMAKE_INSTALL_*DIR can be set as absolute.
In that case, it should not be prefixed with CMAKE_INSTALL_PREFIX.
Use CMAKE_INSTALL_FULL_*DIR instead.

ref. https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html#result-variables


Before creating a pull request

  • Document new methods and classes
  • Format new code files using ClangFormat by running make format
  • Build with -DDART_TREAT_WARNINGS_AS_ERRORS=ON and resolve all the compile warnings

Before merging a pull request

  • Set version target by selecting a milestone on the right side
  • Summarize this change in CHANGELOG.md
  • Add unit test(s) for this change
  • Add Python bindings for new methods and classes

`CMAKE_INSTALL_*DIR` can be set as absolute.
In that case, it should not be prefixed with `CMAKE_INSTALL_PREFIX`.
Use `CMAKE_INSTALL_FULL_*DIR` instead.
@nim65s nim65s marked this pull request as ready for review August 8, 2025 11:12
@jslee02
Copy link
Member

jslee02 commented Aug 8, 2025

I'm not familiar with CMAKE_INSTALL_FULL_*DIR. Could you let me know how this is better than before? The CMake documentation says it shouldn't be used with install(), but we're using PC_CONFIG_INSTALL_DIR in install():

These variables shouldn't be used in install() commands as they do not work with the cmake --install command's --prefix option, or with the cpack installer generators.

Would dart.pc still be relocatable?

@jslee02
Copy link
Member

jslee02 commented Aug 8, 2025

Could we handle this conditionally?

  • If CMAKE_INSTALL_*DIR is relative: keep Make dart.pc relocatable #1529’s relocatable .pc (rebuild prefix from ${pcfiledir}, make libdir/includedir relative, keep DESTINATION relative).
  • If absolute: write absolute paths as is (and install to that explicit path).

This might preserve relocatability, fixes the absolute-dir case, and avoids using CMAKE_INSTALL_FULL_*DIR in install(). How do you think?

@nim65s
Copy link
Contributor Author

nim65s commented Aug 10, 2025

Yes, I think you are right, I've been to quick here. Thanks for the review :)

@nim65s nim65s marked this pull request as draft August 10, 2025 09:53
Copy link

@jslee02
Copy link
Member

jslee02 commented Aug 16, 2025

Looks good now. Thanks for the fix!

@jslee02 jslee02 marked this pull request as ready for review August 16, 2025 22:07
@jslee02 jslee02 merged commit 6f3d608 into dartsim:main Aug 16, 2025
11 of 12 checks passed
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