diff options
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/Qt5CoreMacros.cmake | 51 | ||||
-rw-r--r-- | src/corelib/global/qsystemdetection.h | 79 | ||||
-rw-r--r-- | src/corelib/kernel/kernel.pri | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qcore_mac_objc.mm | 41 | ||||
-rw-r--r-- | src/corelib/kernel/qcore_mac_p.h | 11 |
5 files changed, 112 insertions, 72 deletions
diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake index 1627de4002..819b48f973 100644 --- a/src/corelib/Qt5CoreMacros.cmake +++ b/src/corelib/Qt5CoreMacros.cmake @@ -294,3 +294,54 @@ function(QT5_ADD_RESOURCES outfiles ) endfunction() set(_Qt5_COMPONENT_PATH "${CMAKE_CURRENT_LIST_DIR}/..") + +if (NOT CMAKE_VERSION VERSION_LESS 2.8.9) + macro(qt5_use_modules _target _link_type) + if(NOT CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.11) + if(CMAKE_WARN_DEPRECATED) + set(messageType WARNING) + endif() + if(CMAKE_ERROR_DEPRECATED) + set(messageType FATAL_ERROR) + endif() + if(messageType) + message(${messageType} "The qt5_use_modules macro is obsolete. Use target_link_libraries with IMPORTED targets instead.") + endif() + endif() + + if (NOT TARGET ${_target}) + message(FATAL_ERROR "The first argument to qt5_use_modules must be an existing target.") + endif() + if ("${_link_type}" STREQUAL "LINK_PUBLIC" OR "${_link_type}" STREQUAL "LINK_PRIVATE" ) + set(_qt5_modules ${ARGN}) + set(_qt5_link_type ${_link_type}) + else() + set(_qt5_modules ${_link_type} ${ARGN}) + endif() + + if ("${_qt5_modules}" STREQUAL "") + message(FATAL_ERROR "qt5_use_modules requires at least one Qt module to use.") + endif() + + foreach(_module ${_qt5_modules}) + if (NOT Qt5${_module}_FOUND) + find_package(Qt5${_module} PATHS "${_Qt5_COMPONENT_PATH}" NO_DEFAULT_PATH) + if (NOT Qt5${_module}_FOUND) + message(FATAL_ERROR "Can not use \"${_module}\" module which has not yet been found.") + endif() + endif() + target_link_libraries(${_target} ${_qt5_link_type} ${Qt5${_module}_LIBRARIES}) + set_property(TARGET ${_target} APPEND PROPERTY INCLUDE_DIRECTORIES ${Qt5${_module}_INCLUDE_DIRS}) + set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS ${Qt5${_module}_COMPILE_DEFINITIONS}) + set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_RELEASE QT_NO_DEBUG) + set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_RELWITHDEBINFO QT_NO_DEBUG) + set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_MINSIZEREL QT_NO_DEBUG) + if (Qt5_POSITION_INDEPENDENT_CODE + AND (CMAKE_VERSION VERSION_LESS 2.8.12 + AND (NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU" + OR CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0))) + set_property(TARGET ${_target} PROPERTY POSITION_INDEPENDENT_CODE ${Qt5_POSITION_INDEPENDENT_CODE}) + endif() + endforeach() + endmacro() +endif() diff --git a/src/corelib/global/qsystemdetection.h b/src/corelib/global/qsystemdetection.h index ff0e03108b..cacb95b674 100644 --- a/src/corelib/global/qsystemdetection.h +++ b/src/corelib/global/qsystemdetection.h @@ -216,18 +216,6 @@ # // Numerical checks are preferred to named checks, but to be safe # // we define the missing version names in case Qt uses them. # -# if !defined(__MAC_10_7) -# define __MAC_10_7 1070 -# endif -# if !defined(__MAC_10_8) -# define __MAC_10_8 1080 -# endif -# if !defined(__MAC_10_9) -# define __MAC_10_9 1090 -# endif -# if !defined(__MAC_10_10) -# define __MAC_10_10 101000 -# endif # if !defined(__MAC_10_11) # define __MAC_10_11 101100 # endif @@ -237,17 +225,8 @@ # if !defined(__MAC_10_13) # define __MAC_10_13 101300 # endif -# if !defined(MAC_OS_X_VERSION_10_7) -# define MAC_OS_X_VERSION_10_7 1070 -# endif -# if !defined(MAC_OS_X_VERSION_10_8) -# define MAC_OS_X_VERSION_10_8 1080 -# endif -# if !defined(MAC_OS_X_VERSION_10_9) -# define MAC_OS_X_VERSION_10_9 1090 -# endif -# if !defined(MAC_OS_X_VERSION_10_10) -# define MAC_OS_X_VERSION_10_10 101000 +# if !defined(__MAC_10_14) +# define __MAC_10_14 101400 # endif # if !defined(MAC_OS_X_VERSION_10_11) # define MAC_OS_X_VERSION_10_11 101100 @@ -258,55 +237,10 @@ # if !defined(MAC_OS_X_VERSION_10_13) # define MAC_OS_X_VERSION_10_13 101300 # endif -# -# if !defined(__IPHONE_4_3) -# define __IPHONE_4_3 40300 -# endif -# if !defined(__IPHONE_5_0) -# define __IPHONE_5_0 50000 -# endif -# if !defined(__IPHONE_5_1) -# define __IPHONE_5_1 50100 -# endif -# if !defined(__IPHONE_6_0) -# define __IPHONE_6_0 60000 -# endif -# if !defined(__IPHONE_6_1) -# define __IPHONE_6_1 60100 -# endif -# if !defined(__IPHONE_7_0) -# define __IPHONE_7_0 70000 -# endif -# if !defined(__IPHONE_7_1) -# define __IPHONE_7_1 70100 -# endif -# if !defined(__IPHONE_8_0) -# define __IPHONE_8_0 80000 -# endif -# if !defined(__IPHONE_8_1) -# define __IPHONE_8_1 80100 -# endif -# if !defined(__IPHONE_8_2) -# define __IPHONE_8_2 80200 -# endif -# if !defined(__IPHONE_8_3) -# define __IPHONE_8_3 80300 -# endif -# if !defined(__IPHONE_8_4) -# define __IPHONE_8_4 80400 -# endif -# if !defined(__IPHONE_9_0) -# define __IPHONE_9_0 90000 -# endif -# if !defined(__IPHONE_9_1) -# define __IPHONE_9_1 90100 -# endif -# if !defined(__IPHONE_9_2) -# define __IPHONE_9_2 90200 -# endif -# if !defined(__IPHONE_9_3) -# define __IPHONE_9_3 90300 +# if !defined(MAC_OS_X_VERSION_10_14) +# define MAC_OS_X_VERSION_10_14 101400 # endif +# # if !defined(__IPHONE_10_0) # define __IPHONE_10_0 100000 # endif @@ -322,6 +256,9 @@ # if !defined(__IPHONE_11_0) # define __IPHONE_11_0 110000 # endif +# if !defined(__IPHONE_12_0) +# define __IPHONE_12_0 120000 +# endif #endif #ifdef __LSB_VERSION__ diff --git a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri index ca8bd30698..c528b16f9c 100644 --- a/src/corelib/kernel/kernel.pri +++ b/src/corelib/kernel/kernel.pri @@ -120,7 +120,7 @@ mac { LIBS_PRIVATE += -framework Foundation - osx: LIBS_PRIVATE += -framework CoreServices -framework AppKit + osx: LIBS_PRIVATE += -framework CoreServices -framework AppKit -framework Security ios|tvos { # We need UIKit for UIApplication in qeventdispatcher_cf.mm diff --git a/src/corelib/kernel/qcore_mac_objc.mm b/src/corelib/kernel/qcore_mac_objc.mm index c29c4dfc14..6b11e90a4e 100644 --- a/src/corelib/kernel/qcore_mac_objc.mm +++ b/src/corelib/kernel/qcore_mac_objc.mm @@ -44,6 +44,10 @@ #include <AppKit/NSText.h> #endif +#if defined(QT_PLATFORM_UIKIT) +#include <UIKit/UIKit.h> +#endif + #include <qdebug.h> QT_BEGIN_NAMESPACE @@ -189,6 +193,43 @@ AppleApplication *qt_apple_sharedApplication() } #endif +#if defined(Q_OS_MACOS) && !defined(QT_BOOTSTRAPPED) +bool qt_apple_isSandboxed() +{ + static bool isSandboxed = []() { + QCFType<SecStaticCodeRef> staticCode = nullptr; + NSURL *bundleUrl = [[NSBundle mainBundle] bundleURL]; + if (SecStaticCodeCreateWithPath((__bridge CFURLRef)bundleUrl, + kSecCSDefaultFlags, &staticCode) != errSecSuccess) + return false; + + QCFType<SecRequirementRef> sandboxRequirement; + if (SecRequirementCreateWithString(CFSTR("entitlement[\"com.apple.security.app-sandbox\"] exists"), + kSecCSDefaultFlags, &sandboxRequirement) != errSecSuccess) + return false; + + if (SecStaticCodeCheckValidityWithErrors(staticCode, + kSecCSBasicValidateOnly, sandboxRequirement, nullptr) != errSecSuccess) + return false; + + return true; + }(); + return isSandboxed; +} + +QT_END_NAMESPACE +@implementation NSObject (QtSandboxHelpers) +- (id)qt_valueForPrivateKey:(NSString *)key +{ + if (qt_apple_isSandboxed()) + return nil; + + return [self valueForKey:key]; +} +@end +QT_BEGIN_NAMESPACE +#endif + #ifdef Q_OS_MACOS /* Ensure that Objective-C objects auto-released in main(), directly or indirectly, diff --git a/src/corelib/kernel/qcore_mac_p.h b/src/corelib/kernel/qcore_mac_p.h index 9bd2e31bc9..af939abaac 100644 --- a/src/corelib/kernel/qcore_mac_p.h +++ b/src/corelib/kernel/qcore_mac_p.h @@ -160,6 +160,17 @@ QDebug operator<<(QDebug debug, const QMacAutoReleasePool *pool); Q_CORE_EXPORT void qt_apple_check_os_version(); Q_CORE_EXPORT bool qt_apple_isApplicationExtension(); +#if defined(Q_OS_MACOS) && !defined(QT_BOOTSTRAPPED) +Q_CORE_EXPORT bool qt_apple_isSandboxed(); +# ifdef __OBJC__ +QT_END_NAMESPACE +@interface NSObject (QtSandboxHelpers) +- (id)qt_valueForPrivateKey:(NSString *)key; +@end +QT_BEGIN_NAMESPACE +# endif +#endif + #if !defined(QT_BOOTSTRAPPED) && !defined(Q_OS_WATCHOS) QT_END_NAMESPACE # if defined(Q_OS_MACOS) |