aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authornicole mazzuca <mazzucan@outlook.com>2020-04-14 22:08:50 -0700
committerGitHub <noreply@github.com>2020-04-14 22:08:50 -0700
commit22623e35016cae6061e0d9e502577077b3c33fd9 (patch)
tree0a8cc4e43fd871bacb3010e9ff06b21dba4e800d /scripts
parent1e19af09e53e5f306ed89c2033817a21e5ee0bcf (diff)
downloadvcpkg-22623e35016cae6061e0d9e502577077b3c33fd9.tar.gz
vcpkg-22623e35016cae6061e0d9e502577077b3c33fd9.zip
[vcpkg] Clean up CMake build system (#10834)
There are quite a few changes to the CMake build system packaged up into one set here: * Added `toolsrc/cmake/utilities.cmake`, which contains the following: * `vcpkg_detect_compiler` -- get the name of the C++ compiler, as one of {gcc, clang, msvc} * `vcpkg_detect_standard_library` -- get the name of the standard library we're linking to, as one of {libstdc++, libc++, msvc-stl} * `vcpkg_detect_std_filesystem` -- figure out how to link and call into C++17's filesystem; whether one needs to link to `stdc++fs` or `c++fs`, and whether to use `<filesystem>` or `<experimental/filesystem>`. * Added a `VCPKG_WARNINGS_AS_ERRORS`, split off from `VCPKG_DEVELOPMENT_WARNINGS`, which allows one to use the development warnings without passing -Werror * Rename `DEFINE_DISABLE_METRICS` to `VCPKG_DISABLE_METRICS` -- the former will now print a deprecation message and set the latter. * Now, print a deprecation message on `WERROR`; it doesn't do anything since the behavior it requested is now the default. * Pass `-std=c++17` if the compiler allows it, instead of `-std=c++1z` * Do some code movement * Pass `USE_STD_FILESYSTEM` if possible, instead of only on minGW * Renamed to `VCPKG_USE_STD_FILESYSTEM` Additionally, we now pass `/W4` in Debug mode on x86 in the Visual Studio build system; this brings it in line with the CMake build system, and the x64 Visual Studio build system. And finally, we make some minor code changes to support compiling in VCPKG_DEVELOPMENT_WARNINGS mode.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/bootstrap.sh33
1 files changed, 8 insertions, 25 deletions
diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh
index bf8de7897..7959c4465 100644
--- a/scripts/bootstrap.sh
+++ b/scripts/bootstrap.sh
@@ -199,11 +199,10 @@ fetchTool()
selectCXX()
{
- __output=$1
-
if [ "x$CXX" = "x" ]; then
- CXX=g++
- if which g++-9 >/dev/null 2>&1; then
+ if which g++ >/dev/null 2>&1; then
+ CXX=g++
+ elif which g++-9 >/dev/null 2>&1; then
CXX=g++-9
elif which g++-8 >/dev/null 2>&1; then
CXX=g++-8
@@ -212,24 +211,8 @@ selectCXX()
elif which g++-6 >/dev/null 2>&1; then
CXX=g++-6
fi
+ # If we can't find g++, allow CMake to do the look-up
fi
-
- gccversion="$("$CXX" -v 2>&1)"
- gccversion="$(extractStringBetweenDelimiters "$gccversion" "gcc version " ".")"
- if [ "$gccversion" -lt "6" ]; then
- echo "CXX ($CXX) is too old; please install a newer compiler such as g++-7."
- echo "On Ubuntu try the following:"
- echo " sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y"
- echo " sudo apt-get update -y"
- echo " sudo apt-get install g++-7 -y"
- echo "On CentOS try the following:"
- echo " sudo yum install centos-release-scl"
- echo " sudo yum install devtoolset-7"
- echo " scl enable devtoolset-7 bash"
- return 1
- fi
-
- eval $__output="'$CXX'"
}
# Preparation
@@ -246,10 +229,10 @@ if [ "$os" = "osx" ]; then
if [ "$vcpkgAllowAppleClang" = "true" ] ; then
CXX=clang++
else
- selectCXX CXX || exit 1
+ selectCXX
fi
else
- selectCXX CXX || exit 1
+ selectCXX
fi
# Do the build
@@ -257,8 +240,8 @@ buildDir="$vcpkgRootDir/toolsrc/build.rel"
rm -rf "$buildDir"
mkdir -p "$buildDir"
-(cd "$buildDir" && CXX=$CXX "$cmakeExe" .. -DCMAKE_BUILD_TYPE=Release -G "Ninja" "-DCMAKE_MAKE_PROGRAM=$ninjaExe" "-DBUILD_TESTING=OFF" "-DVCPKG_DEVELOPMENT_WARNINGS=Off" "-DDEFINE_DISABLE_METRICS=$vcpkgDisableMetrics" "-DVCPKG_ALLOW_APPLE_CLANG=$vcpkgAllowAppleClang") || exit 1
-(cd "$buildDir" && "$cmakeExe" --build .) || exit 1
+("$cmakeExe" -B "$buildDir" -S toolsrc -DCMAKE_BUILD_TYPE=Release -G "Ninja" "-DCMAKE_MAKE_PROGRAM=$ninjaExe" "-DBUILD_TESTING=OFF" "-DVCPKG_DEVELOPMENT_WARNINGS=OFF" "-DVCPKG_WARNINGS_AS_ERRORS=OFF" "-DVCPKG_DISABLE_METRICS=$vcpkgDisableMetrics" "-DVCPKG_ALLOW_APPLE_CLANG=$vcpkgAllowAppleClang") || exit 1
+("$cmakeExe" --build "$buildDir") || exit 1
rm -rf "$vcpkgRootDir/vcpkg"
cp "$buildDir/vcpkg" "$vcpkgRootDir/"