Skip to content

Commit

Permalink
Fixed compilation with clang and libc++ (#25813)
Browse files Browse the repository at this point in the history
### Details:
 - *item1*
 - *...*

### Tickets:
 - Closes #25420
  • Loading branch information
ilya-lavrenov authored Jul 31, 2024
1 parent b26c533 commit d2ab797
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ endif()
if(NOT OV_LIBC_VERSION VERSION_EQUAL 0.0)
message (STATUS "LIBC_VERSION .......................... " ${OV_LIBC_VERSION})
endif()
if(DEFINED OPENVINO_STDLIB)
message (STATUS "STDLIB ................................ " ${OPENVINO_STDLIB})
endif()

# remove file with exported targets to force its regeneration
file(REMOVE "${CMAKE_BINARY_DIR}/OpenVINOTargets.cmake")
Expand Down
23 changes: 20 additions & 3 deletions cmake/developer_package/target_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,23 @@ get_property(OV_GENERATOR_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG

function(ov_detect_libc_type)
include(CheckCXXSourceCompiles)
check_cxx_source_compiles("
# include <string>
# ifndef _GLIBCXX_USE_CXX11_ABI
# error \"GlibCXX ABI is not defined\"
# endif
int main() {
return 0;
}"
OPENVINO_STDLIB_GNU)

if(OPENVINO_STDLIB_GNU)
set(OPENVINO_STDLIB "GNU" PARENT_SCOPE)
else()
set(OPENVINO_STDLIB "CPP" PARENT_SCOPE)
endif()

check_cxx_source_compiles("
# ifndef _GNU_SOURCE
# define _GNU_SOURCE
Expand All @@ -140,9 +157,9 @@ function(ov_detect_libc_type)
int main() {
return 0;
}"
OPENVINO_MUSL_LIBC)
OPENVINO_GLIBC_MUSL)

if(OPENVINO_MUSL_LIBC)
if(OPENVINO_GLIBC_MUSL)
set(OPENVINO_MUSL_LIBC ON PARENT_SCOPE)
else()
set(OPENVINO_GNU_LIBC ON PARENT_SCOPE)
Expand Down Expand Up @@ -213,7 +230,7 @@ ov_libc_version()
# Detects default value for _GLIBCXX_USE_CXX11_ABI for current compiler
#
macro(ov_get_glibcxx_use_cxx11_abi)
if(LINUX)
if(LINUX AND OPENVINO_STDLIB STREQUAL "GNU")
ov_get_compiler_definition("_GLIBCXX_USE_CXX11_ABI" OV_GLIBCXX_USE_CXX11_ABI)
endif()
endmacro()
Expand Down

0 comments on commit d2ab797

Please sign in to comment.