Skip to content

Commit 83b87ae

Browse files
author
Tor Didriksen
committed
Bug #32349239 WRONG VERSION REPORTED FROM MYSQLD WHEN BUILDING ON MACOS 11
Version information printed by MySQL executables includes the value of the cmake variable SYSTEM_TYPE, which is based on the cmake variable PLATFORM. On macOS the default value for PLATFORM is based on 'uname -r' with some arithmetic to map from unix version, to macOS version. This arithmetic did not work at all for macOS 11, and executables would report something like: "Ver 8.0.24 for osx10.16 on x86_64" This patch replaces the use of 'uname -r' with the results from 'sw_vers'. We also remove "osx" from the default PLATFORM name, and use "macos" instead. With this, version information will be: Ver 8.0.24 for macos11.1 on x86_64 or Ver 8.0.24 for macos10.15 on x86_64 Also set CMAKE_OSX_DEPLOYMENT_TARGET explicitly, unless it is defined on the cmake command line. Change-Id: I97984bdaa09d025422709fc15569e12f3ee2ff11
1 parent 825b08d commit 83b87ae

File tree

1 file changed

+34
-22
lines changed

1 file changed

+34
-22
lines changed

cmake/package_name.cmake

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2010, 2021, Oracle and/or its affiliates.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License, version 2.0,
@@ -69,30 +69,42 @@ MACRO(GET_PACKAGE_FILE_NAME Var)
6969
ENDIF()
7070
ENDIF()
7171
ELSEIF(APPLE)
72-
IF(CMAKE_OSX_DEPLOYMENT_TARGET)
73-
SET(DEFAULT_PLATFORM "osx${CMAKE_OSX_DEPLOYMENT_TARGET}")
74-
ELSE()
75-
SET(VER "${CMAKE_SYSTEM_VERSION}")
76-
STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" VER "${VER}")
77-
# Subtract 4 from Darwin version to get correct osx10.X
78-
MATH(EXPR VER "${VER} -4")
79-
SET(DEFAULT_PLATFORM "osx10.${VER}")
72+
# CMAKE_SYSTEM_PROCESSOR seems to based on 'uname -r'
73+
# CMAKE_SYSTEM_VERSION cannot be trusted for version information:
74+
75+
# CMAKE_SYSTEM_VERSION 19.2.0
76+
# sw_vers
77+
# ProductName: Mac OS X
78+
# ProductVersion: 10.15.2
79+
# BuildVersion: 19C57
80+
81+
# CMAKE_SYSTEM_VERSION 20.2.0
82+
# sw_vers
83+
# ProductName: macOS
84+
# ProductVersion: 11.1
85+
# BuildVersion: 20C69
86+
87+
EXECUTE_PROCESS(COMMAND sw_vers
88+
OUTPUT_VARIABLE SW_VERS_OUTPUT
89+
OUTPUT_STRIP_TRAILING_WHITESPACE
90+
)
91+
STRING(REPLACE "\n" ";" SW_VERS_OUTPUT_LIST "${SW_VERS_OUTPUT}")
92+
LIST(GET SW_VERS_OUTPUT_LIST 0 SW_VERS_PRODUCTNAME)
93+
LIST(GET SW_VERS_OUTPUT_LIST 1 SW_VERS_PRODUCTVERSION)
94+
95+
STRING(REGEX MATCH
96+
"ProductVersion:[\n\t ]*([0-9]+)\\.([0-9]+)" UNUSED ${SW_VERS_PRODUCTVERSION})
97+
IF(NOT CMAKE_MATCH_1 OR NOT CMAKE_MATCH_2)
98+
MESSAGE(FATAL_ERROR "Could not run sw_vers")
8099
ENDIF()
81100

82-
IF(CMAKE_OSX_ARCHITECTURES)
83-
LIST(LENGTH CMAKE_OSX_ARCHITECTURES LEN)
84-
IF(LEN GREATER 1)
85-
SET(DEFAULT_MACHINE "universal")
86-
ELSE()
87-
SET(DEFAULT_MACHINE "${CMAKE_OSX_ARCHITECTURES}")
88-
ENDIF()
89-
ELSE()
90-
IF(64BIT)
91-
SET(DEFAULT_MACHINE "x86_64")
92-
ENDIF()
93-
ENDIF()
101+
SET(DEFAULT_PLATFORM "macos${CMAKE_MATCH_1}.${CMAKE_MATCH_2}")
102+
103+
MESSAGE(STATUS "DEFAULT_PLATFORM ${DEFAULT_PLATFORM}")
94104

95-
IF(DEFAULT_MACHINE MATCHES "i386")
105+
IF(64BIT)
106+
SET(DEFAULT_MACHINE "x86_64")
107+
ELSE()
96108
SET(DEFAULT_MACHINE "x86")
97109
ENDIF()
98110
ENDIF()

0 commit comments

Comments
 (0)