libjxl : do not export "-lm" private dependency under Windows.
- Dominant language
- CMake
- Stars
- 27.5k
- Forks
- 7.7k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 321
Description
### Is your feature request related to a problem? Please describe.
Hi,
The usage of the libjxl under Windows is broken at linking time due to wrong pkgconfig settings exported by the library: -lm
This is the KF6::kimageformat compilation trace on my computer:
```
Automatic MOC for target kimg_jxl
Building Custom Rule E:/b/dk_cmake/ext_kf6/ext_kimageformats-prefix/src/ext_kimageformats/src/imageformats/CMakeLists.txt
jxl.cpp
mocs_compilation_RelWithDebInfo.cpp
Generating Code...
LINK : warning LNK4044: unrecognized option '/Wl,-Bsymbolic-functions'; ignored [E:\b\dk_cmake\ext_kf6\ext_kimageformats-prefix\src\ext_kimageformats-build\src\imageformats\kimg_jxl.vcxproj] [E:\b\dk_cmake\ext_kf6\ext_kimageformats.vcxproj]
LINK : fatal error LNK1104: cannot open file 'm.lib' [E:\b\dk_cmake\ext_kf6\ext_kimageformats-prefix\src\ext_kimageformats-build\src\imageformats\kimg_jxl.vcxproj] [E:\b\dk_cmake\ext_kf6\ext_kimageformats.vcxproj]
```
NOTE: another WM with KF5 compilation give exactly the same problem.
"-lm" is only for Linux for the Math library, not for Windows.
### Proposed solution
I patched all libjxl pkgconfig files (debug and non debug targets) and now all link fine. For ex, the "libjxl.pc" installed by VCPKG for the non-debug is this one:
```
prefix=${pcfiledir}/../..
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/../include
Name: libjxl
Description: Loads and saves JPEG XL files
Version: 0.11.1
Requires.private: libhwy libbrotlienc libbrotlidec libjxl_cms
Libs: "-L${libdir}" -ljxl
Libs.private: -lm
Cflags: "-I${includedir}"
Cflags.private: -DJXL_STATIC_DEFINE
```
I removed the line : Libs.private: -lm
And i do it also for all other libjxl non-debug pkgconfig files : "libjxl_cms.pc" and "libjxl_threads.pc"
Finally all debug pkgconfig files are also patched in the same way. In total 6 files patched.
My best
Gilles Caulier
### Describe alternatives you've considered
_No response_
### Additional context
2 VirtualBox VM running under Linux KUbuntu 24.04 with Windows 10 64 bits all updates installed and Visual Studio 2022 version 17.12.4
Contributor guide
Assessment
This issue has not been assessed yet.