Fix Compilation of libgpg-error 1.12 with MSVC2015

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

Information
Michael Drueing
craft
Reviewers
kdewin

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 https://quickgit.kde.org/?p=emerge.git&a=blobdiff&h=931c4009cf09c63c5fb0ad478a2a54931f4e4d2a&hp=1c9262272c85c3b9bee2e52493707ba577dcc4c0&hb=10a33f9e0e5a8020a073d8e38f2316b343b8366a&f=portage%2Fwin32libs%2Fgpg-error%2Flibgpg-error-cmake-1.12.diff 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

Loading...