Skip to content

Commit

Permalink
Respect target type in ov_add_version_defines (openvinotoolkit#22805)
Browse files Browse the repository at this point in the history
### Details:
Make ov_add_version_defines macro respect the original library type
(instead of implicit assumption based on BUILD_SHARED_LIBS).
Note adding objects into a library with $<TARGET_OBJECTS:> does not work
when mixing STATIC and OBJECT targets.

Co-authored-by: Ilya Lavrenov <[email protected]>
  • Loading branch information
lmielick and ilya-lavrenov authored Feb 14, 2024
1 parent 88b792e commit 28ff6ce
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions cmake/developer_package/version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,18 @@ macro (ov_add_version_defines FILE TARGET)
if(NOT EXISTS ${__version_file})
message(FATAL_ERROR "${FILE} does not exists in current source directory")
endif()
if (NOT TARGET ${TARGET})
message(FATAL_ERROR "Invalid target ${TARGET}")
endif()
_remove_source_from_target(${TARGET} ${FILE})
_remove_source_from_target(${TARGET} ${__version_file})
if (BUILD_SHARED_LIBS)
add_library(${TARGET}_version OBJECT ${__version_file})
get_target_property(__target_type ${TARGET} TYPE)
if (__target_type STREQUAL "STATIC_LIBRARY")
set(__lib_type STATIC)
else()
add_library(${TARGET}_version STATIC ${__version_file})
set(__lib_type OBJECT)
endif()
add_library(${TARGET}_version ${__lib_type} ${__version_file})
if(SUGGEST_OVERRIDE_SUPPORTED)
set_source_files_properties(${__version_file}
PROPERTIES COMPILE_OPTIONS -Wno-suggest-override)
Expand Down

0 comments on commit 28ff6ce

Please sign in to comment.