diff options
| author | nicole mazzuca <mazzucan@outlook.com> | 2020-04-14 22:08:50 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-14 22:08:50 -0700 |
| commit | 22623e35016cae6061e0d9e502577077b3c33fd9 (patch) | |
| tree | 0a8cc4e43fd871bacb3010e9ff06b21dba4e800d /toolsrc/src/vcpkg-test/system.cpp | |
| parent | 1e19af09e53e5f306ed89c2033817a21e5ee0bcf (diff) | |
| download | vcpkg-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 'toolsrc/src/vcpkg-test/system.cpp')
| -rw-r--r-- | toolsrc/src/vcpkg-test/system.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/toolsrc/src/vcpkg-test/system.cpp b/toolsrc/src/vcpkg-test/system.cpp index 41e27fe6d..70424f0b5 100644 --- a/toolsrc/src/vcpkg-test/system.cpp +++ b/toolsrc/src/vcpkg-test/system.cpp @@ -1,6 +1,5 @@ #include <catch2/catch.hpp> -#include <Windows.h> #include <string> #include <vcpkg/base/optional.h> #include <vcpkg/base/stringview.h> @@ -8,6 +7,14 @@ #include <vcpkg/base/strings.h> #include <vcpkg/base/system.h> +#if defined(_WIN32) +#define _NOMINMAX +#define WIN32_LEAN_AND_MEAN +#include <windows.h> +#else +#include <stdlib.h> +#endif + using vcpkg::Optional; using vcpkg::StringView; using vcpkg::ZStringView; @@ -39,16 +46,17 @@ namespace check_exit(VCPKG_LINE_INFO, exit_code != 0); #else // ^^^ defined(_WIN32) / !defined(_WIN32) vvv std::string tmp; - tmp.reserve(varname.size() + value.size() + 1); tmp.append(varname.data(), varname.size()); tmp.push_back('='); - if (value) + if (auto v = value.get()) { - const auto& unpacked = value.value_or_exit(VCPKG_LINE_INFO); - tmp.append(unpacked); + tmp.append(*v); } - const int exit_code = putenv(tmp.c_str()); + // putenv expects the string to never go out of scope + char* env_string = new char[tmp.size() + 1]; // overflow checked by tmp's null allocation + memcpy(env_string, tmp.data(), tmp.size()); + const int exit_code = putenv(env_string); check_exit(VCPKG_LINE_INFO, exit_code == 0); #endif // defined(_WIN32) } |
