Skip to content

Commit 6c159b7

Browse files
authored
[vcpkg] Hopefully fix build on macOS 10.13/10.14 (#11205)
1 parent 09b769b commit 6c159b7

File tree

1 file changed

+67
-52
lines changed

1 file changed

+67
-52
lines changed

toolsrc/cmake/utilities.cmake

Lines changed: 67 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,35 @@ function(vcpkg_detect_compiler)
33
if(NOT DEFINED CACHE{VCPKG_COMPILER})
44
if(CMAKE_COMPILER_IS_GNUXX OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
55
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)
6-
message(FATAL_ERROR
7-
"The g++ version picked up is too old; please install a newer compiler such as g++-7.
8-
On Ubuntu try the following:
9-
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
10-
sudo apt-get update -y
11-
sudo apt-get install g++-7 -y
12-
On CentOS try the following:
13-
sudo yum install centos-release-scl
14-
sudo yum install devtoolset-7
15-
scl enable devtoolset-7 bash")
6+
message(FATAL_ERROR [[
7+
The g++ version picked up is too old; please install a newer compiler such as g++-7.
8+
On Ubuntu try the following:
9+
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
10+
sudo apt-get update -y
11+
sudo apt-get install g++-7 -y
12+
On CentOS try the following:
13+
sudo yum install centos-release-scl
14+
sudo yum install devtoolset-7
15+
scl enable devtoolset-7 bash
16+
]])
1617
endif()
1718

1819
set(COMPILER "gcc")
1920
elseif(CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
20-
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "11.0.0" AND NOT VCPKG_ALLOW_APPLE_CLANG)
21-
message(FATAL_ERROR
22-
"Building the vcpkg tool requires support for the C++ Filesystem TS.
23-
Apple clang versions 10.01 and below do not have support for it.
24-
Please install gcc6 or newer from homebrew (brew install gcc).
25-
If you would like to try anyway, pass --allowAppleClang to bootstrap.sh.")
21+
#[[
22+
Note: CMAKE_SYSTEM_VERSION uses darwin versions
23+
- Darwin 19.0.0 = macOS 10.15, iOS 13
24+
- Darwin 18.0.0 = macOS 10.14, iOS 12
25+
- Darwin 17.0.0 = macOS 10.13, iOS 11
26+
- Darwin 16.0.0 = macOS 10.12, iOS 10
27+
]]
28+
if(CMAKE_SYSTEM_VERSION VERSION_LESS "19.0.0" AND NOT VCPKG_ALLOW_APPLE_CLANG)
29+
message(FATAL_ERROR [[
30+
Building the vcpkg tool requires support for the C++ Filesystem TS.
31+
macOS versions below 10.15 do not have support for it with Apple Clang.
32+
Please install gcc6 or newer from homebrew (brew install gcc).
33+
If you would like to try anyway, pass --allowAppleClang to bootstrap.sh.
34+
]])
2635
endif()
2736
set(COMPILER "clang")
2837
elseif(CMAKE_CXX_COMPILER_ID MATCHES "[Cc]lang")
@@ -48,26 +57,29 @@ function(vcpkg_detect_standard_library)
4857

4958
# note: since <ciso646> is the smallest header, generally it's used to get the standard library version
5059
set(CMAKE_REQUIRED_QUIET ON)
51-
check_cxx_source_compiles(
52-
"#include <ciso646>
53-
#if !defined(__GLIBCXX__)
54-
#error \"not libstdc++\"
55-
#endif
56-
int main() {}"
60+
check_cxx_source_compiles([[
61+
#include <ciso646>
62+
#if !defined(__GLIBCXX__)
63+
#error "not libstdc++"
64+
#endif
65+
int main() {}
66+
]]
5767
_VCPKG_STANDARD_LIBRARY_LIBSTDCXX)
58-
check_cxx_source_compiles(
59-
"#include <ciso646>
60-
#if !defined(_LIBCPP_VERSION)
61-
#error \"not libc++\"
62-
#endif
63-
int main() {}"
68+
check_cxx_source_compiles([[
69+
#include <ciso646>
70+
#if !defined(_LIBCPP_VERSION)
71+
#error "not libc++"
72+
#endif
73+
int main() {}
74+
]]
6475
_VCPKG_STANDARD_LIBRARY_LIBCXX)
65-
check_cxx_source_compiles(
66-
"#include <ciso646>
67-
#if !defined(_MSVC_STL_VERSION)
68-
#error \"not MSVC stl\"
69-
#endif
70-
int main() {}"
76+
check_cxx_source_compiles([[
77+
#include <ciso646>
78+
#if !defined(_MSVC_STL_VERSION)
79+
#error "not MSVC stl"
80+
#endif
81+
int main() {}
82+
]]
7183
_VCPKG_STANDARD_LIBRARY_MSVC_STL)
7284
if(_VCPKG_STANDARD_LIBRARY_LIBSTDCXX)
7385
set(STANDARD_LIBRARY "libstdc++")
@@ -98,32 +110,35 @@ function(vcpkg_detect_std_filesystem)
98110

99111
set(CMAKE_REQUIRED_QUIET ON)
100112
if(VCPKG_STANDARD_LIBRARY STREQUAL "libstdc++")
101-
check_cxx_source_compiles(
102-
"#include <ciso646>
103-
#if defined(_GLIBCXX_RELEASE) && _GLIBCXX_RELEASE >= 9
104-
#error \"libstdc++ after version 9 does not require -lstdc++fs\"
105-
#endif
106-
int main() {}"
113+
check_cxx_source_compiles([[
114+
#include <ciso646>
115+
#if defined(_GLIBCXX_RELEASE) && _GLIBCXX_RELEASE >= 9
116+
#error "libstdc++ after version 9 does not require -lstdc++fs"
117+
#endif
118+
int main() {}
119+
]]
107120
_VCPKG_REQUIRE_LINK_CXXFS)
108121

109-
check_cxx_source_compiles(
110-
"#include <ciso646>
111-
#if !defined(_GLIBCXX_RELEASE) || _GLIBCXX_RELEASE < 8
112-
#error \"libstdc++ before version 8 does not support <filesystem>\"
113-
#endif
114-
int main() {}"
122+
check_cxx_source_compiles([[
123+
#include <ciso646>
124+
#if !defined(_GLIBCXX_RELEASE) || _GLIBCXX_RELEASE < 8
125+
#error "libstdc++ before version 8 does not support <filesystem>"
126+
#endif
127+
int main() {}
128+
]]
115129
_VCPKG_USE_STD_FILESYSTEM)
116130
elseif(VCPKG_STANDARD_LIBRARY STREQUAL "libc++")
117131
if(CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
118132
# AppleClang never requires (or allows) -lc++fs, even with libc++ version 8.0.0
119133
set(_VCPKG_REQUIRE_LINK_CXXFS OFF)
120134
else()
121-
check_cxx_source_compiles(
122-
"#include <ciso646>
123-
#if _LIBCPP_VERSION >= 9000
124-
#error \"libc++ after version 9 does not require -lc++fs\"
125-
#endif
126-
int main() {}"
135+
check_cxx_source_compiles([[
136+
#include <ciso646>
137+
#if _LIBCPP_VERSION >= 9000
138+
#error "libc++ after version 9 does not require -lc++fs"
139+
#endif
140+
int main() {}
141+
]]
127142
_VCPKG_REQUIRE_LINK_CXXFS)
128143
endif()
129144

0 commit comments

Comments
 (0)