On 2020-06-02 Markus Rickert wrote:
> When using CMake to build a shared library with Visual Studio 2019, I
> get an error that the file config.h could not be found:
> 
> cmake -G "Visual Studio 16 2019" -A x64 -DBUILD_SHARED_LIBS=ON ..\xz
> cmake --build . --config Release
> 
> xz\src\common\common_w32res.rc(9): fatal error RC1015: cannot open
> include file 'config.h'. [xz-build\liblzma.vcxproj]

Great to see this being tested. Thanks!

> The file common_w32res.rc has an include for config.h in line 9, but
> the corresponding include directory is missing in the build files.
> The patch fixes this by adding the windows/2019 directory to the list
> of include directories.

The CMakeLists.txt doesn't create config.h. All #defines are set as
compiler options. The config.h files under windows/vs* aren't meant to
be used with CMake. Instead, common_w32res.rc shouldn't read config.h
when it isn't present.

The following patch works with the GNU Autotools based build. Does it
work with CMake + VS2019? It requires that the #defines used for
building C files are passed to the resource compiler too. (If they
aren't, it should give an error.) After a successful build you can
right-click liblzma.dll -> Properties -> Details to see if the info
from the resource file is present.

diff --git a/src/common/common_w32res.rc b/src/common/common_w32res.rc
index a70de34..d05d22e 100644
--- a/src/common/common_w32res.rc
+++ b/src/common/common_w32res.rc
@@ -6,7 +6,9 @@
  */
 
 #include <winresrc.h>
-#include "config.h"
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
 #define LZMA_H_INTERNAL
 #define LZMA_H_INTERNAL_RC
 #include "lzma/version.h"

-- 
Lasse Collin  |  IRC: Larhzu @ IRCnet & Freenode

Reply via email to