Re: [xz-devel] [PATCH] CMake: Add missing include directory when building the shared library

2020-07-12 Thread Lasse Collin
On 2020-06-04 Markus Rickert wrote:
> This way also works, I just tested your patch on my system with
> VS2019. The DLL includes the following info, looks good to me:
> 
>   File description: liblzma data compression library
>   File version: 5.3.1.0
>   Product name: XZ Utils 
>   Product version: 5.3.1alpha

Looks good. I have finally committed it.

Thanks!

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



Re: [xz-devel] [PATCH] CMake: Add missing include directory when building the shared library

2020-06-04 Thread Markus Rickert

Great to see this being tested. Thanks!


Including CMake build files in the repository is very much appreciated 
for building on different platforms and especially on Windows. Thank you 
for that.



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.


This way also works, I just tested your patch on my system with VS2019. 
The DLL includes the following info, looks good to me:


 File description: liblzma data compression library
 File version: 5.3.1.0
 Product name: XZ Utils 
 Product version: 5.3.1alpha

Best regards,

Markus Rickert


smime.p7s
Description: S/MIME cryptographic signature


Re: [xz-devel] [PATCH] CMake: Add missing include directory when building the shared library

2020-06-04 Thread Lasse Collin
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 
-#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



[xz-devel] [PATCH] CMake: Add missing include directory when building the shared library

2020-06-02 Thread Markus Rickert
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



smime.p7s
Description: S/MIME cryptographic signature