-
Notifications
You must be signed in to change notification settings - Fork 333
Enable GENAI with FetchContent or find_package() for client projects
#1858
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
Changes from all commits
47a5965
05f5749
0691161
68a545d
4e628e3
5f7aeea
5305384
a7b6ff2
9285680
fdbaffc
006bf1a
0d7b08e
4ac8295
893560a
f24dbf1
38a4346
b84ab59
e9b479a
3401949
4e623ea
a7d4a51
83c18bd
6f9e3b8
1fd3a6d
a6a3a85
6009a52
e8311ee
c1241ff
b77750e
0d461a4
37e63ed
7f04a01
11311dd
9546c37
4e23a0e
1fcce6e
beee6b5
c82b6d7
3c768e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,9 +8,13 @@ else() | |
| cmake_minimum_required(VERSION 3.26) | ||
| endif() | ||
|
|
||
| include(cmake/version.cmake) | ||
|
|
||
| project(Generators VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} LANGUAGES C CXX) | ||
|
|
||
| include(GNUInstallDirs) | ||
| include(FetchContent) | ||
| include(CMakeDependentOption) | ||
| project(Generators LANGUAGES C CXX) | ||
|
|
||
| # All Options should be defined in cmake/options.cmake This must be included before any other cmake file is included | ||
| include(cmake/options.cmake) | ||
|
|
@@ -98,7 +102,6 @@ endif() | |
|
|
||
| include(cmake/ortlib.cmake) | ||
|
|
||
|
|
||
| include(cmake/external/onnxruntime_external_deps.cmake) | ||
| # All Global variables, including GLOB, for the top level CMakeLists.txt should be defined here | ||
| include(cmake/global_variables.cmake) | ||
|
|
@@ -158,23 +161,36 @@ find_package(Threads REQUIRED) | |
| if(WIN32) | ||
| add_library(onnxruntime-genai SHARED ${generator_srcs} "${GENERATORS_ROOT}/dll/onnxruntime-genai.rc") | ||
| target_compile_definitions(onnxruntime-genai PRIVATE VERSION_INFO=\"${VERSION_INFO}\") | ||
| target_compile_definitions(onnxruntime-genai PRIVATE VERSION_MAJOR=${VERSION_MAJOR}) | ||
| target_compile_definitions(onnxruntime-genai PRIVATE VERSION_MINOR=${VERSION_MINOR}) | ||
| target_compile_definitions(onnxruntime-genai PRIVATE VERSION_PATCH=${VERSION_PATCH}) | ||
| target_compile_definitions(onnxruntime-genai PRIVATE VERSION_MAJOR=${PROJECT_VERSION_MAJOR}) | ||
| target_compile_definitions(onnxruntime-genai PRIVATE VERSION_MINOR=${PROJECT_VERSION_MINOR}) | ||
| target_compile_definitions(onnxruntime-genai PRIVATE VERSION_PATCH=${PROJECT_VERSION_PATCH}) | ||
| target_compile_definitions(onnxruntime-genai PRIVATE VERSION_SUFFIX=${VERSION_SUFFIX}) | ||
| target_compile_definitions(onnxruntime-genai PRIVATE FILE_NAME=\"onnxruntime-genai.dll\") | ||
| else() | ||
| add_library(onnxruntime-genai SHARED ${generator_srcs}) | ||
| set_target_properties(onnxruntime-genai PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}) | ||
| endif() | ||
|
|
||
| target_include_directories(onnxruntime-genai INTERFACE | ||
| $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src> $<INSTALL_INTERFACE:include>) | ||
|
Comment on lines
+174
to
+175
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this leak all internal headers to consumers?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, only the headers marked public and interface.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Those are all the files installed on Windows with the |
||
|
|
||
| target_include_directories(onnxruntime-genai PRIVATE ${ORT_HEADER_DIR}) | ||
| target_include_directories(onnxruntime-genai PRIVATE ${onnxruntime_extensions_SOURCE_DIR}/shared/api) | ||
| 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>") | ||
| if(WIN32 OR ANDROID OR IOS) | ||
| list(APPEND ortgenai_embed_libs "$<TARGET_FILE:onnxruntime-genai>") | ||
| else() | ||
| if (ENABLE_PYTHON) | ||
| list(APPEND python_embed_libs "$<TARGET_SONAME_FILE:onnxruntime-genai>") | ||
| endif() | ||
| if (ENABLE_JAVA) | ||
| list(APPEND java_embed_libs "$<TARGET_LINKER_FILE:onnxruntime-genai>") | ||
| endif() | ||
| endif() | ||
|
|
||
| # 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. | ||
|
|
@@ -191,7 +207,6 @@ if(APPLE) | |
| target_link_libraries(onnxruntime-genai PRIVATE "-framework Foundation" "-framework CoreML") | ||
| endif() | ||
|
|
||
|
|
||
| # Build all source files using CUDA as a separate shared library we dynamically load at runtime | ||
| if((USE_CUDA OR USE_TRT_RTX) AND CMAKE_CUDA_COMPILER) | ||
| # Suppress nvcc warnings: | ||
|
|
@@ -241,9 +256,8 @@ if((USE_CUDA OR USE_TRT_RTX) AND CMAKE_CUDA_COMPILER) | |
| endif() | ||
| endif() | ||
|
|
||
|
|
||
| if(USE_GUIDANCE) | ||
| target_include_directories(onnxruntime-genai PUBLIC ${llguidance_SOURCE_DIR}/parser/) | ||
| target_include_directories(onnxruntime-genai PRIVATE ${llguidance_SOURCE_DIR}/parser/) | ||
| target_link_libraries(onnxruntime-genai PRIVATE llguidance) | ||
| if (WIN32) | ||
| # bcrypt is needed for the rust std lib | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| @PACKAGE_INIT@ | ||
| if (NOT TARGET onnxruntime::onnxruntime-genai) | ||
| include(${CMAKE_CURRENT_LIST_DIR}/onnxruntime-genai-targets.cmake) | ||
| endif() | ||
| check_required_components(onnxruntime-genai) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicate?