Skip to content

Fix shared lib symlink installation path#556

Merged
cary-ilm merged 1 commit intoAcademySoftwareFoundation:mainfrom
jhacsonmeza:install_dirs
Mar 26, 2026
Merged

Fix shared lib symlink installation path#556
cary-ilm merged 1 commit intoAcademySoftwareFoundation:mainfrom
jhacsonmeza:install_dirs

Conversation

@jhacsonmeza
Copy link
Copy Markdown
Contributor

When installing Imath with cmake --install . --prefix <custom_path> everything is installed correctly at custom_path except for the shared library symlinks. This is due to the use of CMAKE_INSTALL_FULL_BINDIR and CMAKE_INSTALL_FULL_LIBDIR which default to /usr/local if CMAKE_INSTALL_PREFIX is not set. The proposed changes fixed the problem for me.

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla bot commented Mar 26, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: jhacsonmeza / name: Jhacson Meza (bc5f898)

Signed-off-by: Jhacson Meza <jhacsonmeza@gmail.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes incorrect installation location for shared-library symlinks when using cmake --install . --prefix <custom_path> by avoiding CMAKE_INSTALL_FULL_*DIR variables that can resolve to the configure-time default prefix.

Changes:

  • Replace CMAKE_INSTALL_FULL_BINDIR/CMAKE_INSTALL_FULL_LIBDIR with CMAKE_INSTALL_BINDIR/CMAKE_INSTALL_LIBDIR for shared-lib symlink installation destinations.
  • Apply the same fix consistently across core Imath, Boost.Python PyImath, and pybind11 PyBindImath builds.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/python/PyImath/CMakeLists.txt Installs PyImath shared-library symlink into prefix-relative install dirs.
src/pybind11/PyBindImath/CMakeLists.txt Installs PyBindImath shared-library symlink into prefix-relative install dirs.
src/Imath/CMakeLists.txt Installs core Imath shared-library symlink into prefix-relative install dirs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

set(INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${BASE_LIB_FILENAME} DESTINATION ${INSTALL_DESTINATION})
install(CODE "message(STATUS \"Creating symlink ${INSTALL_DESTINATION}/${BASE_LIB_FILENAME} -> ${VERSIONED_LIB_FILENAME}\")")
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The install-time status message now prints a relative path (because INSTALL_DESTINATION is CMAKE_INSTALL_LIBDIR/CMAKE_INSTALL_BINDIR). Consider prepending ${CMAKE_INSTALL_PREFIX} (and accounting for $ENV{DESTDIR}) so the message matches the real install path when cmake --install --prefix is used.

Suggested change
install(CODE "message(STATUS \"Creating symlink ${INSTALL_DESTINATION}/${BASE_LIB_FILENAME} -> ${VERSIONED_LIB_FILENAME}\")")
install(CODE "message(STATUS \"Creating symlink \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${INSTALL_DESTINATION}/${BASE_LIB_FILENAME} -> ${VERSIONED_LIB_FILENAME}\")")

Copilot uses AI. Check for mistakes.
set(INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${BASE_LIB_FILENAME} DESTINATION ${INSTALL_DESTINATION})
install(CODE "message(STATUS \"Creating symlink ${INSTALL_DESTINATION}/${BASE_LIB_FILENAME} -> ${VERSIONED_LIB_FILENAME}\")")
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After switching INSTALL_DESTINATION to CMAKE_INSTALL_LIBDIR/CMAKE_INSTALL_BINDIR (relative paths), the subsequent status message prints a relative install path. Consider printing the fully resolved install path by including ${CMAKE_INSTALL_PREFIX} (and $ENV{DESTDIR} if set) for clearer install logs.

Suggested change
install(CODE "message(STATUS \"Creating symlink ${INSTALL_DESTINATION}/${BASE_LIB_FILENAME} -> ${VERSIONED_LIB_FILENAME}\")")
install(CODE "message(STATUS \"Creating symlink \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${INSTALL_DESTINATION}/${BASE_LIB_FILENAME} -> ${VERSIONED_LIB_FILENAME}\")")

Copilot uses AI. Check for mistakes.
set(INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${BASE_LIB_FILENAME} DESTINATION ${INSTALL_DESTINATION})
install(CODE "message(STATUS \"Creating symlink ${INSTALL_DESTINATION}/${BASE_LIB_FILENAME} -> ${VERSIONED_LIB_FILENAME}\")")
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The install-time status message now prints a relative path (e.g., lib/...) because INSTALL_DESTINATION is set to CMAKE_INSTALL_LIBDIR/CMAKE_INSTALL_BINDIR. Consider including ${CMAKE_INSTALL_PREFIX} (and respecting $ENV{DESTDIR} if applicable) in the message so the output reflects the actual on-disk install location when using cmake --install --prefix.

Suggested change
install(CODE "message(STATUS \"Creating symlink ${INSTALL_DESTINATION}/${BASE_LIB_FILENAME} -> ${VERSIONED_LIB_FILENAME}\")")
install(CODE "message(STATUS \"Creating symlink \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${INSTALL_DESTINATION}/${BASE_LIB_FILENAME} -> ${VERSIONED_LIB_FILENAME}\")")

Copilot uses AI. Check for mistakes.
@cary-ilm
Copy link
Copy Markdown
Member

Looks good, thanks! Copilot's suggest messages also look helpful, if you don't mind accepting them.

@jhacsonmeza
Copy link
Copy Markdown
Contributor Author

I tested the suggested message by Copilot by installing in a local directory (not in /usr/local), and the message changes from:

-- Creating symlink lib64/libImath.so -> libImath-3_2.so

to:

-- Creating symlink /usr/local/lib64/libImath.so -> libImath-3_2.so

The printed path of the shared lib is not correct. This is because CMAKE_INSTALL_PREFIX also defaults to /usr/local if CMAKE_INSTALL_PREFIX is not set.

@cary-ilm
Copy link
Copy Markdown
Member

Hmm, ok, that's not good. I'm fine with it the way it is, then. Thanks!

@cary-ilm cary-ilm merged commit 54b2326 into AcademySoftwareFoundation:main Mar 26, 2026
38 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.

3 participants