Skip to content

Commit d1f9ab8

Browse files
CMake: reading definitions from COMPILE_DEFINITIONS property (openvinotoolkit#24324)
Compilation in Conan fails if compiler=clang and libstd=libstdc++ because conan defines _GLIBCXX_USE_CXX11_ABI=0 but openvino autodetects the value and overwrites it with _GLIBCXX_USE_CXX11_ABI=1. These changes make it honor the compile definitions generated by Conan. Co-authored-by: Ilya Lavrenov <ilya.lavrenov@intel.com>
1 parent e467066 commit d1f9ab8

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

cmake/developer_package/target_flags.cmake

+12-1
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,19 @@ function(ov_get_compiler_definition definition var)
122122
message(FATAL_ERROR "Internal error: 'ov_get_definition' must be used only on Linux")
123123
endif()
124124

125+
get_directory_property(_user_defines COMPILE_DEFINITIONS)
126+
foreach(_user_define IN LISTS _user_defines)
127+
# older cmake versions keep -D at the beginning, trim it
128+
string(REPLACE "-D" "" _user_define "${_user_define}")
129+
list(APPEND _ov_user_flags "-D${_user_define}")
130+
endforeach()
131+
string(REPLACE " " ";" _user_cxx_flags "${CMAKE_CXX_FLAGS}")
132+
foreach(_user_flag IN LISTS _user_cxx_flags)
133+
list(APPEND _ov_user_flags ${_user_flag})
134+
endforeach()
135+
125136
execute_process(COMMAND echo "#include <string>"
126-
COMMAND "${CMAKE_CXX_COMPILER}" -x c++ - -E -dM ${CMAKE_CXX_FLAGS}
137+
COMMAND "${CMAKE_CXX_COMPILER}" ${_ov_user_flags} -x c++ - -E -dM
127138
COMMAND grep -E "^#define ${definition} "
128139
OUTPUT_VARIABLE output_value
129140
ERROR_VARIABLE error_message

0 commit comments

Comments
 (0)