Fix Compilation of libgpg-error 1.12 with MSVC2015

Review Request #125573 - Created Oct. 9, 2015 and updated

Michael Drueing

When emerging libgpg-error with the patch file as is (libgpg-error-cmake-1.12.diff), the build fails because the generated file _mkerrorcodes.h comes up empty. The problem is that CMakeLists.txt invokes the C preprocessor by calling COMMAND ${ERR_COMPILER} -E -P ${BIN_DIR}/_mkerrcodes.h ... and this won't work for MSVC: The -E switch is "preprocess to stdout" (correct) but it is immediately overridden by the "-P" switch which is "preprocess to file". And indeed, after emerge errors out, there is a file _mkerrorcodes.i with the preprocessed output.

There is another diff file, libgpg-error-cmake.diff, which is obviously only used for older versions of libgpg-error, which has the correct call to the compiler (only -E), and if the 1.12 diff file is changed accordingly, libgpg-error compiles.

I wanted to pass this through the reviewboard though because I don't know if that will break e.g. the mingw build on Windows...

Compiles fine with the patch whereas it fails to compile without.
Since the patch was obviously correct for at least one older version of libgpg-error (as evidenced by the fact that the other diff file includes the exact same patch) I'm pretty confident that this fix is okay here as well

Hannah von Reth

Ok so the commit did break msvc and we need an if statement.
Could you please provide a solution with a -P for mingw and a -E for msvc?

  1. I hit the same issue yesterday here. Using MSVC 2015