]> git.ipfire.org Git - thirdparty/ccache.git/commit
Support building on MSVC (#632)
authorRafael Kitover <rkitover@gmail.com>
Thu, 27 Aug 2020 19:23:26 +0000 (19:23 +0000)
committerGitHub <noreply@github.com>
Thu, 27 Aug 2020 19:23:26 +0000 (21:23 +0200)
commit96e06e2bb7441fd839e1467cb8204c9149d9bbff
tree862cea71e4b5ad5d0876be78fc14659a216b6180
parent2bb90086cf43ce88c00bc87f36b7b3bc1f837277
Support building on MSVC (#632)

With these changes, the project builds with Visual Studio 2019, unit
tests pass and it works correctly with mingw gcc.

NOTE: The very latest version of Visual Studio 2019 is required, because
there was just a necessary fix for template arguments.

Tested building and running unit tests on Windows+MSVC, Windows+MinGW,
Linux and macOS.

- Enable `ZSTD_FROM_INTERNET` by default for MSVC when not using vcpkg
  or conan.

- Add include tests for some standard UNIX headers not available on
  MSVC.

- Add necessary MSVC compiler flags.

- In `Args::from_gcc_atfile()` iterate over the string via `c_str()`
  instead of `cbegin()`, the MSVC string character iterator does not
  include the ending null byte.

- Misc. minor cmake fix-ups.

- Add some headers that are not implicitly included from other headers
  like `<algorithm>`, `<ios>`, `<cstdint>` and `<cstdarg>` in some
  places, gcc does this but MSVC does not.

- Add `std::filesystem` version of `Util::traverse()` when dirent.h is
  not available, which is preferred for performance reasons.

- Add implementations of the following functions that are not available
  in MSVC in Win32Util.cpp: `gettimeofday()`, `localtime_r()`,
  `asprintf()`.

- Add Windows implementation of `getopt_long()` from
  https://www.codeproject.com/Articles/157001/Full-getopt-Port-for-Unicode-and-Multibyte-Microso
  to third_party/win32.

- Add some compatibility typedefs, constants and macros to the `_WIN32`
  section of system.hpp, as well as the prototypes for the functions
  added to Win32Util.cpp.

- Fix up unit tests expecting '/' separated paths to expect paths
  delimited by `DIR_DELIM_CH`.

- Invoke test/run with bash from cmake, necessary on msys2+mingw64, many
  fail, there is more work to do here.

- Set the warning level to `/W4` and silence all the uninteresting
  warning types. Compiles with no warnings now.

- Switch to using standard C++ attributes `[[nodiscard]]` and
  `[[maybe_unused]]` and define macros for gcc for their equivalents.

- `#define DOCTEST_CONFIG_USE_STD_HEADERS` for MSVC only, because it
  requires explicitly including `<ostream>`.

- Add vim files to .gitignore.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
28 files changed:
.gitignore
CMakeLists.txt
LGPL-3.0.txt [new file with mode: 0644]
LICENSE.adoc
cmake/GenerateConfigurationFile.cmake
cmake/StandardSettings.cmake
cmake/StandardWarnings.cmake
cmake/config.h.in
misc/format-files
src/Args.cpp
src/CMakeLists.txt
src/Lockfile.cpp
src/ProgressBar.cpp
src/Result.cpp
src/Util.cpp
src/Util.hpp
src/Win32Util.cpp
src/ZstdCompressor.cpp
src/ccache.cpp
src/system.hpp
src/third_party/CMakeLists.txt
src/third_party/win32/getopt.c [new file with mode: 0644]
src/third_party/win32/getopt.h [new file with mode: 0644]
test/CMakeLists.txt
unittest/TestUtil.hpp
unittest/test_Stat.cpp
unittest/test_Util.cpp
unittest/test_argprocessing.cpp