diff options
author | Rafael Kitover <rkitover@gmail.com> | 2020-08-27 19:23:26 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-27 21:23:26 +0200 |
commit | 96e06e2bb7441fd839e1467cb8204c9149d9bbff (patch) | |
tree | 862cea71e4b5ad5d0876be78fc14659a216b6180 /cmake/config.h.in | |
parent | 2bb90086cf43ce88c00bc87f36b7b3bc1f837277 (diff) | |
download | ccache-96e06e2bb7441fd839e1467cb8204c9149d9bbff.tar.gz |
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>
Diffstat (limited to 'cmake/config.h.in')
-rw-r--r-- | cmake/config.h.in | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/cmake/config.h.in b/cmake/config.h.in index 34935e05..30393c84 100644 --- a/cmake/config.h.in +++ b/cmake/config.h.in @@ -52,6 +52,8 @@ # pragma clang diagnostic pop #endif +#define SIZEOF_INT @SIZEOF_INT@ + #cmakedefine MTR_ENABLED /* Define to 1 if you have the `asctime_r' function. */ @@ -126,9 +128,30 @@ /* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */ #cmakedefine HAVE_SYS_WAIT_H +/* Define to 1 if you have the <sys/file.h> header file. */ +#cmakedefine HAVE_SYS_FILE_H + /* Define to 1 if you have the <termios.h> header file. */ #cmakedefine HAVE_TERMIOS_H +/* Define to 1 if you have the <dirent.h> header file. */ +#cmakedefine HAVE_DIRENT_H + +/* Define to 1 if you have the <strings.h> header file. */ +#cmakedefine HAVE_STRINGS_H + +/* Define to 1 if you have the <unistd.h> header file. */ +#cmakedefine HAVE_UNISTD_H + +/* Define to 1 if you have the <utime.h> header file. */ +#cmakedefine HAVE_UTIME_H + +/* Define to 1 if you have the <sys/utime.h> header file. */ +#cmakedefine HAVE_SYS_UTIME_H + +/* Define to 1 if you have the <varargs.h> header file. */ +#cmakedefine HAVE_VARARGS_H + /* Define to 1 if you have the `unsetenv' function. */ #cmakedefine HAVE_UNSETENV |