Skip to content

Commit e4dbd33

Browse files
CMAKE: fixed GPU plugin build within vcpkg infra (openvinotoolkit#28816)
### Details: - Reorder includes to have headers in OpenVINO source tree to come first. ### Tickets: - Closes openvinotoolkit#28790
1 parent 842a81d commit e4dbd33

File tree

5 files changed

+43
-37
lines changed

5 files changed

+43
-37
lines changed

cmake/developer_package/compile_flags/os_flags.cmake

+34
Original file line numberDiff line numberDiff line change
@@ -669,3 +669,37 @@ function(ov_try_use_gold_linker)
669669
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=gold" PARENT_SCOPE)
670670
endif()
671671
endfunction()
672+
673+
#
674+
# ov_target_link_libraries_as_system(<TARGET NAME> <PUBLIC | PRIVATE | INTERFACE> <target1 target2 ...>)
675+
#
676+
function(ov_target_link_libraries_as_system TARGET_NAME LINK_TYPE)
677+
message("Link to ${TARGET_NAME} using ${LINK_TYPE} the following ${ARGN}")
678+
target_link_libraries(${TARGET_NAME} ${LINK_TYPE} ${ARGN})
679+
680+
# include directories as SYSTEM
681+
foreach(library IN LISTS ARGN)
682+
if(TARGET ${library})
683+
get_target_property(include_directories ${library} INTERFACE_INCLUDE_DIRECTORIES)
684+
if(include_directories)
685+
foreach(include_directory IN LISTS include_directories)
686+
# cannot include /usr/include headers as SYSTEM
687+
if(NOT "${include_directory}" MATCHES ".*/usr/include.*$")
688+
# Note, some include dirs can be wrapper with $<BUILD_INTERFACE:dir1 dir2 ...> and we need to clean it
689+
string(REGEX REPLACE "^\\$<BUILD_INTERFACE:" "" include_directory "${include_directory}")
690+
string(REGEX REPLACE ">$" "" include_directory "${include_directory}")
691+
target_include_directories(${TARGET_NAME} SYSTEM ${LINK_TYPE} $<BUILD_INTERFACE:${include_directory}>)
692+
else()
693+
set(_system_library ON)
694+
endif()
695+
endforeach()
696+
endif()
697+
endif()
698+
endforeach()
699+
700+
if(_system_library)
701+
# if we deal with system library (e.i. having /usr/include as header paths)
702+
# we cannot use SYSTEM key word for such library
703+
set_target_properties(${TARGET_NAME} PROPERTIES NO_SYSTEM_FROM_IMPORTED ON)
704+
endif()
705+
endfunction()

src/cmake/ov_parallel.cmake

+3-31
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ macro(ov_find_package_openmp)
318318

319319
# falling back to system OpenMP then
320320
if(NOT TARGET IntelOpenMP::OpenMP_CXX)
321-
_ov_target_link_libraries(${TARGET_NAME} ${LINK_TYPE} OpenMP::OpenMP_CXX)
321+
ov_target_link_libraries_as_system(${TARGET_NAME} ${LINK_TYPE} OpenMP::OpenMP_CXX)
322322
endif()
323323
endif()
324324
endmacro()
@@ -360,34 +360,6 @@ function(ov_set_threading_interface_for TARGET_NAME)
360360
message(WARNING "Unknown target type")
361361
endif()
362362

363-
function(_ov_target_link_libraries TARGET_NAME LINK_TYPE)
364-
target_link_libraries(${TARGET_NAME} ${LINK_TYPE} ${ARGN})
365-
366-
# include directories as SYSTEM
367-
foreach(library IN LISTS ARGN)
368-
if(TARGET ${library})
369-
get_target_property(include_directories ${library} INTERFACE_INCLUDE_DIRECTORIES)
370-
if(include_directories)
371-
foreach(include_directory IN LISTS include_directories)
372-
# cannot include /usr/include headers as SYSTEM
373-
if(NOT "${include_directory}" MATCHES ".*/usr/include.*$")
374-
target_include_directories(${TARGET_NAME} SYSTEM
375-
${LINK_TYPE} $<BUILD_INTERFACE:${include_directory}>)
376-
else()
377-
set(_system_library ON)
378-
endif()
379-
endforeach()
380-
endif()
381-
endif()
382-
endforeach()
383-
384-
if(_system_library)
385-
# if we deal with system library (e.i. having /usr/include as header paths)
386-
# we cannot use SYSTEM key word for such library
387-
set_target_properties(${TARGET_NAME} PROPERTIES NO_SYSTEM_FROM_IMPORTED ON)
388-
endif()
389-
endfunction()
390-
391363
set(_ov_thread_define "OV_THREAD_SEQ")
392364

393365
if(NOT TARGET openvino::threading)
@@ -423,13 +395,13 @@ function(ov_set_threading_interface_for TARGET_NAME)
423395
set_target_properties(openvino_threading PROPERTIES INTERFACE_LINK_LIBRARIES ${_ov_threading_lib})
424396

425397
# perform linkage with target
426-
_ov_target_link_libraries(${TARGET_NAME} ${LINK_TYPE} ${_ov_threading_lib})
398+
ov_target_link_libraries_as_system(${TARGET_NAME} ${LINK_TYPE} ${_ov_threading_lib})
427399
endif()
428400

429401
target_compile_definitions(${TARGET_NAME} ${COMPILE_DEF_TYPE} OV_THREAD=${_ov_thread_define})
430402

431403
if(NOT THREADING STREQUAL "SEQ")
432404
find_package(Threads REQUIRED)
433-
_ov_target_link_libraries(${TARGET_NAME} ${LINK_TYPE} Threads::Threads)
405+
ov_target_link_libraries_as_system(${TARGET_NAME} ${LINK_TYPE} Threads::Threads)
434406
endif()
435407
endfunction(ov_set_threading_interface_for)

src/plugins/intel_gpu/src/graph/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ target_link_libraries(${TARGET_NAME} PRIVATE openvino_intel_gpu_kernels
5252
openvino::runtime)
5353

5454
if(ENABLE_ONEDNN_FOR_GPU)
55-
target_link_libraries(${TARGET_NAME} PUBLIC onednn_gpu_tgt)
55+
ov_target_link_libraries_as_system(${TARGET_NAME} PUBLIC onednn_gpu_tgt)
5656
endif()
5757

5858
if(COMMAND add_cpplint_target)

src/plugins/intel_gpu/src/runtime/CMakeLists.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ if(OV_COMPILER_IS_INTEL_LLVM)
5555
target_compile_definitions(${TARGET_NAME} PUBLIC OV_GPU_WITH_SYCL)
5656
endif()
5757

58+
if(ENABLE_ONEDNN_FOR_GPU)
59+
ov_target_link_libraries_as_system(${TARGET_NAME} PUBLIC onednn_gpu_tgt)
60+
endif()
61+
5862
ov_set_threading_interface_for(${TARGET_NAME})
5963

6064
target_link_libraries(${TARGET_NAME} PRIVATE
@@ -63,10 +67,6 @@ target_link_libraries(${TARGET_NAME} PRIVATE
6367
openvino::runtime::dev
6468
)
6569

66-
if(ENABLE_ONEDNN_FOR_GPU)
67-
target_link_libraries(${TARGET_NAME} PUBLIC onednn_gpu_tgt)
68-
endif()
69-
7070
set_target_properties(${TARGET_NAME} PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO})
7171

7272
if(WIN32)

vcpkg.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
33
"name": "openvino",
4-
"version": "2025.0.0",
4+
"version": "2025.1.0",
55
"maintainers": "OpenVINO Developers <openvino@intel.com>",
66
"summary": "This is a port for Open Visual Inference And Optimization toolkit for AI inference",
77
"description": [

0 commit comments

Comments
 (0)