Skip to content

Commit

Permalink
Simplify cmake and refine error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanUnderhill committed Feb 21, 2025
1 parent b3fb7de commit 059bb01
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ target_link_libraries(onnxruntime-genai PRIVATE onnxruntime_extensions)
target_link_directories(onnxruntime-genai PRIVATE ${ORT_LIB_DIR})
target_link_libraries(onnxruntime-genai PRIVATE Threads::Threads)

# The genai library itself is always embedded in the shared library
list(APPEND ortgenai_embed_libs "$<TARGET_FILE:onnxruntime-genai>")

# we keep the shared libraries disconnected on Android as they will come from separate AARs and we don't want to force
# the ORT version to match in both.
if(CMAKE_SYSTEM_NAME STREQUAL "Android" OR CMAKE_SYSTEM_NAME STREQUAL "Linux" OR (CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND (NOT BUILD_APPLE_FRAMEWORK) AND (NOT MAC_CATALYST)))
Expand Down
2 changes: 1 addition & 1 deletion src/generators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ struct LibraryHandle {
auto path = Ort::GetCurrentModuleDir() + "/" + filename;
handle_ = dlopen(path.c_str(), RTLD_NOW | RTLD_LOCAL);
if (!handle_)
throw std::runtime_error(std::string("Failed to load library: ") + path + " Error:" + dlerror());
throw std::runtime_error(std::string("Failed to load library: ") + dlerror()); // dlerror() includes the path
}
~LibraryHandle() {
dlclose(handle_);
Expand Down
7 changes: 0 additions & 7 deletions src/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,6 @@ if(BUILD_WHEEL)
file(COPY "${CMAKE_SOURCE_DIR}/ThirdPartyNotices.txt" DESTINATION ${WHEEL_TARGET_NAME}/)
file(COPY "${CMAKE_SOURCE_DIR}/LICENSE" DESTINATION ${WHEEL_TARGET_NAME}/)

# Copy over the onnxruntime-genai.dll shared library
add_custom_command(TARGET python POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
$<TARGET_FILE:onnxruntime-genai> $<TARGET_FILE:python>
${WHEEL_TARGET_NAME}
COMMENT "Copying files to wheel directory: ${WHEEL_TARGET_NAME}"
)
add_custom_command(TARGET python POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${ortgenai_embed_libs} $<TARGET_FILE:python>
Expand Down

0 comments on commit 059bb01

Please sign in to comment.