Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions Modules/Findjsonnet.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,38 @@ if(${CMAKE_FIND_PACKAGE_NAME}_FOUND)
set(${CMAKE_FIND_PACKAGE_NAME}_INCLUDE_DIRS
${${CMAKE_FIND_PACKAGE_NAME}_INCLUDE_DIRS}
)

# On macOS, fix jsonnet libraries if they have incorrect install_name
if(APPLE)
foreach(_lib ${${CMAKE_FIND_PACKAGE_NAME}_LIBRARY}
${${CMAKE_FIND_PACKAGE_NAME}_CLIBRARY})
if(EXISTS "${_lib}")
# Get the library's current install_name
execute_process(
COMMAND otool -D "${_lib}"
OUTPUT_VARIABLE _install_name_output
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET
)
# Extract just the install_name (second line of output)
string(REGEX REPLACE "^[^\n]+\n(.+)$" "\\1" _current_install_name
"${_install_name_output}"
)
get_filename_component(_lib_name "${_lib}" NAME)
# Check if install_name needs fixing (doesn't start with @ or /)
if(_current_install_name MATCHES "^[^/@]")
message(
STATUS
"Fixing install_name for ${_lib_name}: ${_current_install_name} -> @rpath/${_current_install_name}"
)
execute_process(
COMMAND install_name_tool -id "@rpath/${_current_install_name}"
"${_lib}" ERROR_QUIET
)
endif()
endif()
endforeach()
endif()

if(NOT TARGET jsonnet::lib)
add_library(jsonnet::lib SHARED IMPORTED)
set_target_properties(
Expand All @@ -48,3 +80,4 @@ if(${CMAKE_FIND_PACKAGE_NAME}_FOUND)
)
endif()
endif()

Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

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

Remove this trailing blank line. Files must end with exactly one newline character and no trailing blank lines.

Copilot generated this review using guidance from repository custom instructions.
Copy link
Member Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

Loading