From 686d958c7605030925a3e316b273afb2e331a65a Mon Sep 17 00:00:00 2001 From: kgbook Date: Fri, 12 Jan 2024 19:47:53 +0800 Subject: [PATCH] [build] Fixed compile issues and warnings for iOS platform (#2852). Fixed cmake policy CMP0153 issue: exec_program is deprecated since version 3.0, CMake >= 3.28 prefer that this command never be called and the NEW behavior for this policy is to issue a FATAL_ERROR when the command is called. Fixed cmake policy CMP0054 issue, Only interpret if() arguments as variables or keywords when unquoted Update .gitignore: ignore files generated by clion and cmake. CMake VERSION_GREATER_EQUAL comparator is not supported on version less than 3.7. --- .gitignore | 4 ++++ CMakeLists.txt | 4 ++++ scripts/iOS.cmake | 7 +++++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 699d0e1b4..b4e22ff8d 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,7 @@ vcpkg/ # LSP compile_commands.json + +# ignore files generated by clion and cmake +.idea/ +cmake-build-debug/ diff --git a/CMakeLists.txt b/CMakeLists.txt index b62c3176c..82b0e3cff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,6 +24,10 @@ else() project(SRT VERSION ${SRT_VERSION} LANGUAGES C CXX) endif() +if (NOT ${CMAKE_VERSION} VERSION_LESS "3.28.1") + cmake_policy(SET CMP0054 NEW) +endif () + include(FindPkgConfig) # XXX See 'if (MINGW)' condition below, may need fixing. include(FindThreads) diff --git a/scripts/iOS.cmake b/scripts/iOS.cmake index d3ae0e82b..1f2a04b50 100644 --- a/scripts/iOS.cmake +++ b/scripts/iOS.cmake @@ -35,7 +35,8 @@ set (CMAKE_OSX_DEPLOYMENT_TARGET "" CACHE STRING "Force unset of the deployment # Determine the cmake host system version so we know where to find the iOS SDKs find_program (CMAKE_UNAME uname /bin /usr/bin /usr/local/bin) if (CMAKE_UNAME) - exec_program(uname ARGS -r OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_VERSION) + execute_process(COMMAND uname -r + OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_VERSION) string (REGEX REPLACE "^([0-9]+)\\.([0-9]+).*$" "\\1" DARWIN_MAJOR_VERSION "${CMAKE_HOST_SYSTEM_VERSION}") endif (CMAKE_UNAME) @@ -119,7 +120,9 @@ endif (${IOS_PLATFORM} STREQUAL OS) # Setup iOS developer location unless specified manually with CMAKE_IOS_DEVELOPER_ROOT if (NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT) - exec_program(/usr/bin/xcode-select ARGS -print-path OUTPUT_VARIABLE CMAKE_XCODE_DEVELOPER_DIR) + execute_process(COMMAND /usr/bin/xcode-select -print-path + OUTPUT_VARIABLE CMAKE_XCODE_DEVELOPER_DIR) + string(STRIP "${CMAKE_XCODE_DEVELOPER_DIR}" CMAKE_XCODE_DEVELOPER_DIR) # FIXED: remove new line character, otherwise it complain no iOS SDK's found in default search path set (CMAKE_IOS_DEVELOPER_ROOT "${CMAKE_XCODE_DEVELOPER_DIR}/Platforms/${IOS_PLATFORM_LOCATION}/Developer") endif (NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT) set (CMAKE_IOS_DEVELOPER_ROOT ${CMAKE_IOS_DEVELOPER_ROOT} CACHE PATH "Location of iOS Platform")