Skip to content

Commit 28ff6ce

Browse files
Respect target type in ov_add_version_defines (openvinotoolkit#22805)
### 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 <ilya.lavrenov@intel.com>
1 parent 88b792e commit 28ff6ce

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

cmake/developer_package/version.cmake

+8-3
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,18 @@ macro (ov_add_version_defines FILE TARGET)
160160
if(NOT EXISTS ${__version_file})
161161
message(FATAL_ERROR "${FILE} does not exists in current source directory")
162162
endif()
163+
if (NOT TARGET ${TARGET})
164+
message(FATAL_ERROR "Invalid target ${TARGET}")
165+
endif()
163166
_remove_source_from_target(${TARGET} ${FILE})
164167
_remove_source_from_target(${TARGET} ${__version_file})
165-
if (BUILD_SHARED_LIBS)
166-
add_library(${TARGET}_version OBJECT ${__version_file})
168+
get_target_property(__target_type ${TARGET} TYPE)
169+
if (__target_type STREQUAL "STATIC_LIBRARY")
170+
set(__lib_type STATIC)
167171
else()
168-
add_library(${TARGET}_version STATIC ${__version_file})
172+
set(__lib_type OBJECT)
169173
endif()
174+
add_library(${TARGET}_version ${__lib_type} ${__version_file})
170175
if(SUGGEST_OVERRIDE_SUPPORTED)
171176
set_source_files_properties(${__version_file}
172177
PROPERTIES COMPILE_OPTIONS -Wno-suggest-override)

0 commit comments

Comments
 (0)