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]

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 config.h files in vs2013, vs2017, and vs2019 all seem to be identical,
so any folder will do.

With this modification, the shared library build is successful:

Creating library xz-build/Release/liblzma.lib and object 
xz-build/Release/liblzma.exp
liblzma.vcxproj -> xz-build\Release\liblzma.dll

---
 CMakeLists.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index d3aa627..b005f45 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -403,6 +403,7 @@ if(WIN32)
     if(BUILD_SHARED_LIBS)
         # Add the Windows resource file for liblzma.dll.
         target_sources(liblzma PRIVATE src/liblzma/liblzma_w32res.rc)
+        target_include_directories(liblzma PRIVATE windows/vs2019)
 
         # Export the public API symbols with __declspec(dllexport).
         target_compile_definitions(liblzma PRIVATE DLL_EXPORT)
-- 
2.26.2.windows.1

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to