cmake: fix add_apple_compiler_options() calls and OBJCXX handling

This commit is contained in:
Alexander Alekhin 2021-02-13 00:35:18 +00:00
parent fba70f7991
commit d2d6eba16a
4 changed files with 11 additions and 5 deletions

View File

@ -564,7 +564,11 @@ macro(ocv_check_flag_support lang flag varname base_options)
elseif("_${lang}_" MATCHES "_C_")
set(_lang C)
elseif("_${lang}_" MATCHES "_OBJCXX_")
set(_lang OBJCXX)
if(DEFINED CMAKE_OBJCXX_COMPILER) # CMake 3.16+ and enable_language(OBJCXX) call are required
set(_lang OBJCXX)
else()
set(_lang CXX)
endif()
else()
set(_lang ${lang})
endif()
@ -573,7 +577,9 @@ macro(ocv_check_flag_support lang flag varname base_options)
string(REGEX REPLACE "^(/|-)" "HAVE_${_lang}_" ${varname} "${${varname}}")
string(REGEX REPLACE " -|-|=| |\\.|," "_" ${varname} "${${varname}}")
ocv_check_compiler_flag("${_lang}" "${base_options} ${flag}" ${${varname}} ${ARGN})
if(DEFINED CMAKE_${_lang}_COMPILER)
ocv_check_compiler_flag("${_lang}" "${base_options} ${flag}" ${${varname}} ${ARGN})
endif()
endmacro()
macro(ocv_check_runtime_flag flag result)

View File

@ -151,7 +151,7 @@ ocv_create_module(${HIGHGUI_LIBRARIES})
macro(ocv_highgui_configure_target)
if(APPLE)
add_apple_compiler_options(the_module)
add_apple_compiler_options(${the_module})
endif()
if(MSVC)

View File

@ -131,7 +131,7 @@ ocv_create_module(${GRFMT_LIBS} ${IMGCODECS_LIBRARIES})
macro(ocv_imgcodecs_configure_target)
if(APPLE)
add_apple_compiler_options(the_module)
add_apple_compiler_options(${the_module})
endif()
if(MSVC)

View File

@ -253,7 +253,7 @@ ocv_create_module(${VIDEOIO_LIBRARIES})
macro(ocv_videoio_configure_target)
if(APPLE)
add_apple_compiler_options(the_module)
add_apple_compiler_options(${the_module})
endif()
if(MSVC)