-
Notifications
You must be signed in to change notification settings - Fork 285
Add cmake target creation helpers #2619
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
base: master
Are you sure you want to change the base?
Conversation
194a52d
to
23b87b5
Compare
75b44cc
to
028f3b1
Compare
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.
Pull Request Overview
This PR introduces CMake target creation helpers to streamline build system configuration and eliminate boilerplate code. It encapsulates OpenVINO find_package calls in a function to prevent cmake environment pollution and centralizes output directory management.
- Added helper functions
genai_add_target
,genai_add_tool_target
, andov_add_sample
for declarative target creation - Centralized output directory definitions in
global_properties.cmake
with configurable variables - Replaced repetitive CMakeLists.txt patterns across samples and tools with function calls
Reviewed Changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
cmake/add_target_helpers.cmake | Implements new target creation helper functions with declarative API |
cmake/global_properties.cmake | Defines centralized output directory variables for different target types |
CMakeLists.txt | Wraps OpenVINO find_package in load_openvino() function and includes new helpers |
samples/CMakeLists.txt | Adds ov_add_sample function and output directory configuration |
tools/continuous_batching/*/CMakeLists.txt | Migrates to genai_add_tool_target helper function |
samples/*/CMakeLists.txt | Migrates sample targets to use ov_add_sample helper function |
src/*/CMakeLists.txt | Updates to use centralized output directory variables |
tests/cpp/CMakeLists.txt | Adds output directory configuration for test targets |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
870f836
to
efdbdb9
Compare
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.
Pull Request Overview
Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
src/cpp/CMakeLists.txt:1
- [nitpick] Missing trailing whitespace was removed which improves formatting consistency.
# Copyright (C) 2018-2025 Intel Corporation
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") | ||
target_link_options(${TEST_TARGET_NAME} PRIVATE /IGNORE:4207,4286) | ||
endif() | ||
|
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.
[nitpick] Trailing whitespace was removed which improves formatting consistency.
Copilot uses AI. Check for mistakes.
ARCHIVE_OUTPUT_DIRECTORY "${GENAI_ARCHIVE_OUTPUT_DIRECTORY}" | ||
LIBRARY_OUTPUT_DIRECTORY "${GENAI_LIBRARY_OUTPUT_DIRECTORY}" | ||
RUNTIME_OUTPUT_DIRECTORY "${GENAI_RUNTIME_OUTPUT_DIRECTORY}" |
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.
The generator expressions $<1:...>
were removed from these properties. This could cause issues if these variables don't contain generator expressions themselves, as the original code used generator expressions consistently throughout the project.
ARCHIVE_OUTPUT_DIRECTORY "${GENAI_ARCHIVE_OUTPUT_DIRECTORY}" | |
LIBRARY_OUTPUT_DIRECTORY "${GENAI_LIBRARY_OUTPUT_DIRECTORY}" | |
RUNTIME_OUTPUT_DIRECTORY "${GENAI_RUNTIME_OUTPUT_DIRECTORY}" | |
ARCHIVE_OUTPUT_DIRECTORY "$<1:${GENAI_ARCHIVE_OUTPUT_DIRECTORY}>" | |
LIBRARY_OUTPUT_DIRECTORY "$<1:${GENAI_LIBRARY_OUTPUT_DIRECTORY}>" | |
RUNTIME_OUTPUT_DIRECTORY "$<1:${GENAI_RUNTIME_OUTPUT_DIRECTORY}>" |
Copilot uses AI. Check for mistakes.
add_custom_command( | ||
TARGET ${TARGET_NAME} POST_BUILD | ||
COMMAND ${CMAKE_COMMAND} -E copy | ||
"${CMAKE_CURRENT_SOURCE_DIR}/openvino_genai/__init__.py" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/openvino_genai/__init__.pyi" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/openvino_genai/py_openvino_genai.pyi" | ||
"${GENAI_LIBRARY_OUTPUT_DIRECTORY}") |
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.
The file copy operation has been changed from a configure-time file(COPY ...)
to a build-time add_custom_command
. This could cause build failures if GENAI_LIBRARY_OUTPUT_DIRECTORY
doesn't exist at build time, since the custom command won't create the destination directory.
Copilot uses AI. Check for mistakes.
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.
Please verify after couple of days that the nightly archive samples build isn't broken
Pull Request is not mergeable
PATHS "${OpenVINO_DIR_PY}") | ||
endif() | ||
endfunction() | ||
load_openvino() |
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.
Is there any other places where this function is used?
set_target_properties(${TARGET_NAME} PROPERTIES | ||
ARCHIVE_OUTPUT_DIRECTORY "$<1:${CMAKE_BINARY_DIR}/openvino_genai/>" | ||
LIBRARY_OUTPUT_DIRECTORY "$<1:${CMAKE_BINARY_DIR}/openvino_genai/>" | ||
ARCHIVE_OUTPUT_DIRECTORY "$<1:${GENAI_ARCHIVE_OUTPUT_DIRECTORY}>" |
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.
Why we can't use PROJECT_<>_DIR (BINARY, ARCHIVE etc) here instead?
CVS-146355