From 686a0f34562587f2da41e2792b086af33a0a5d0c Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Sat, 5 Feb 2022 18:28:24 +0300 Subject: [PATCH] cmake: include CheckOBJCSourceCompiles for cmake >= 3.16 c.f. bugs #5011 and #3912 --- cmake/macros.cmake | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/cmake/macros.cmake b/cmake/macros.cmake index 84cb4c6dc..914c30f62 100644 --- a/cmake/macros.cmake +++ b/cmake/macros.cmake @@ -92,12 +92,16 @@ macro(LISTTOSTRREV _LIST _OUTPUT) endforeach() endmacro() -macro(CHECK_OBJC_SOURCE_COMPILES SOURCE VAR) - set(PREV_REQUIRED_DEFS "${CMAKE_REQUIRED_DEFINITIONS}") - set(CMAKE_REQUIRED_DEFINITIONS "-x objective-c ${PREV_REQUIRED_DEFS}") - CHECK_C_SOURCE_COMPILES(${SOURCE} ${VAR}) - set(CMAKE_REQUIRED_DEFINITIONS "${PREV_REQUIRED_DEFS}") -endmacro() +if(${CMAKE_VERSION} VERSION_LESS "3.16.0") + macro(CHECK_OBJC_SOURCE_COMPILES SOURCE VAR) + set(PREV_REQUIRED_DEFS "${CMAKE_REQUIRED_DEFINITIONS}") + set(CMAKE_REQUIRED_DEFINITIONS "-x objective-c ${PREV_REQUIRED_DEFS}") + CHECK_C_SOURCE_COMPILES(${SOURCE} ${VAR}) + set(CMAKE_REQUIRED_DEFINITIONS "${PREV_REQUIRED_DEFS}") + endmacro() +else() + include(CheckOBJCSourceCompiles) +endif() if(CMAKE_VERSION VERSION_LESS 3.13.0) macro(target_link_directories _TARGET _SCOPE)