Skip to content

Commit

Permalink
CMAKE: fixed GPU plugin build within vcpkg infra (#28825)
Browse files Browse the repository at this point in the history
### Details:
 - Ported #28816
  • Loading branch information
ilya-lavrenov authored Feb 5, 2025
1 parent 690b1be commit d51bcdb
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 36 deletions.
34 changes: 34 additions & 0 deletions cmake/developer_package/compile_flags/os_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -645,3 +645,37 @@ function(ov_try_use_gold_linker)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=gold" PARENT_SCOPE)
endif()
endfunction()

#
# ov_target_link_libraries_as_system(<TARGET NAME> <PUBLIC | PRIVATE | INTERFACE> <target1 target2 ...>)
#
function(ov_target_link_libraries_as_system TARGET_NAME LINK_TYPE)
message("Link to ${TARGET_NAME} using ${LINK_TYPE} the following ${ARGN}")
target_link_libraries(${TARGET_NAME} ${LINK_TYPE} ${ARGN})

# include directories as SYSTEM
foreach(library IN LISTS ARGN)
if(TARGET ${library})
get_target_property(include_directories ${library} INTERFACE_INCLUDE_DIRECTORIES)
if(include_directories)
foreach(include_directory IN LISTS include_directories)
# cannot include /usr/include headers as SYSTEM
if(NOT "${include_directory}" MATCHES ".*/usr/include.*$")
# Note, some include dirs can be wrapper with $<BUILD_INTERFACE:dir1 dir2 ...> and we need to clean it
string(REGEX REPLACE "^\\$<BUILD_INTERFACE:" "" include_directory "${include_directory}")
string(REGEX REPLACE ">$" "" include_directory "${include_directory}")
target_include_directories(${TARGET_NAME} SYSTEM ${LINK_TYPE} $<BUILD_INTERFACE:${include_directory}>)
else()
set(_system_library ON)
endif()
endforeach()
endif()
endif()
endforeach()

if(_system_library)
# if we deal with system library (e.i. having /usr/include as header paths)
# we cannot use SYSTEM key word for such library
set_target_properties(${TARGET_NAME} PROPERTIES NO_SYSTEM_FROM_IMPORTED ON)
endif()
endfunction()
34 changes: 3 additions & 31 deletions src/cmake/ov_parallel.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ macro(ov_find_package_openmp)

# falling back to system OpenMP then
if(NOT TARGET IntelOpenMP::OpenMP_CXX)
_ov_target_link_libraries(${TARGET_NAME} ${LINK_TYPE} OpenMP::OpenMP_CXX)
ov_target_link_libraries_as_system(${TARGET_NAME} ${LINK_TYPE} OpenMP::OpenMP_CXX)
endif()
endif()
endmacro()
Expand Down Expand Up @@ -360,34 +360,6 @@ function(ov_set_threading_interface_for TARGET_NAME)
message(WARNING "Unknown target type")
endif()

function(_ov_target_link_libraries TARGET_NAME LINK_TYPE)
target_link_libraries(${TARGET_NAME} ${LINK_TYPE} ${ARGN})

# include directories as SYSTEM
foreach(library IN LISTS ARGN)
if(TARGET ${library})
get_target_property(include_directories ${library} INTERFACE_INCLUDE_DIRECTORIES)
if(include_directories)
foreach(include_directory IN LISTS include_directories)
# cannot include /usr/include headers as SYSTEM
if(NOT "${include_directory}" MATCHES ".*/usr/include.*$")
target_include_directories(${TARGET_NAME} SYSTEM
${LINK_TYPE} $<BUILD_INTERFACE:${include_directory}>)
else()
set(_system_library ON)
endif()
endforeach()
endif()
endif()
endforeach()

if(_system_library)
# if we deal with system library (e.i. having /usr/include as header paths)
# we cannot use SYSTEM key word for such library
set_target_properties(${TARGET_NAME} PROPERTIES NO_SYSTEM_FROM_IMPORTED ON)
endif()
endfunction()

set(_ov_thread_define "OV_THREAD_SEQ")

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

# perform linkage with target
_ov_target_link_libraries(${TARGET_NAME} ${LINK_TYPE} ${_ov_threading_lib})
ov_target_link_libraries_as_system(${TARGET_NAME} ${LINK_TYPE} ${_ov_threading_lib})
endif()

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

if(NOT THREADING STREQUAL "SEQ")
find_package(Threads REQUIRED)
_ov_target_link_libraries(${TARGET_NAME} ${LINK_TYPE} Threads::Threads)
ov_target_link_libraries_as_system(${TARGET_NAME} ${LINK_TYPE} Threads::Threads)
endif()
endfunction(ov_set_threading_interface_for)
2 changes: 1 addition & 1 deletion src/plugins/intel_gpu/src/graph/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ target_link_libraries(${TARGET_NAME} PRIVATE openvino_intel_gpu_kernels
openvino::runtime)

if(ENABLE_ONEDNN_FOR_GPU)
target_link_libraries(${TARGET_NAME} PUBLIC onednn_gpu_tgt)
ov_target_link_libraries_as_system(${TARGET_NAME} PUBLIC onednn_gpu_tgt)
endif()

if(COMMAND add_cpplint_target)
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/intel_gpu/src/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ if(OV_COMPILER_IS_INTEL_LLVM)
target_compile_definitions(${TARGET_NAME} PUBLIC OV_GPU_WITH_SYCL)
endif()

if(ENABLE_ONEDNN_FOR_GPU)
ov_target_link_libraries_as_system(${TARGET_NAME} PUBLIC onednn_gpu_tgt)
endif()

ov_set_threading_interface_for(${TARGET_NAME})

target_link_libraries(${TARGET_NAME} PRIVATE
Expand All @@ -63,10 +67,6 @@ target_link_libraries(${TARGET_NAME} PRIVATE
openvino::runtime::dev
)

if(ENABLE_ONEDNN_FOR_GPU)
target_link_libraries(${TARGET_NAME} PUBLIC onednn_gpu_tgt)
endif()

set_target_properties(${TARGET_NAME} PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO})

if(WIN32)
Expand Down

0 comments on commit d51bcdb

Please sign in to comment.