Generated pkg-config file for Qt6 includes has incorrect file separator
SeeRich opened this issue · comments
Describe the bug
I initially encountered this issue when building GStreamer. However, I was able to reproduce it with minimal example.
I am building a static library that uses Qt6. I want my library to be consumed by upstream packages using pkg-config files. However, when I generate the pkg-config file, I get the following:
Libs: -L${libdir} -lfoo C:/Tools/Qt6.5.1/6.5.1/msvc2019_64/lib/Qt6Widgetsd.lib C:/Tools/Qt6.5.1/6.5.1/msvc2019_64/lib/Qt6Cored.lib C:/Tools/Qt6.5.1/6.5.1/msvc2019_64/lib/Qt6Guid.lib C:/Tools/Qt6.5.1/6.5.1/msvc2019_64/lib/Qt6Qmld.lib C:/Tools/Qt6.5.1/6.5.1/msvc2019_64/lib/Qt6Quickd.lib
Cflags: -I${includedir} -IC:/Tools/Qt6.5.1/6.5.1/msvc2019_64/include -IC:/Tools/Qt6.5.1/6.5.1/msvc2019_64/include\QtWidgets -DQT_WIDGETS_LIB -IC:/Tools/Qt6.5.1/6.5.1/msvc2019_64/include\QtCore -DQT_CORE_LIB -IC:/Tools/Qt6.5.1/6.5.1/msvc2019_64/include\QtGui -DQT_GUI_LIB -IC:/Tools/Qt6.5.1/6.5.1/msvc2019_64/include\QtQml -DQT_QML_LIB -IC:/Tools/Qt6.5.1/6.5.1/msvc2019_64/include\QtQuick -DQT_QUICK_LIB
Notice how the last component (include dirs in Cflags) is not using the same file separator (i.e. \
instead of /
). Also, the library paths seem to be unaffected?
I am building on Windows (using msvc). However, I know from manually modifying the include directories, I can get the pkg-config file to work (e.g. manually changing the \
to /
in the .pc file).
Investigation
From the implementation here: https://github.com/mesonbuild/meson/blob/master/mesonbuild/dependencies/qt.py it looks like os.path.join(...)
is used for the include path but other logic is used for the library paths.
I'm not sure if this should be handled by pkg-config generation or the Qt6 module import. I believe pkg-config is expecting only Unix file separators?
To Reproduce
Install dependencies:
choco install ninja --version=1.11.1
choco install meson --version=1.4.0
choco install pkgconfiglite --version=0.28
All the files below can be put in a directory and ran (build.bat):
meson.build
project('tutorial', 'cpp')
qt6_mod = import('qt6')
qt6_dep = dependency('qt6', modules : ['Widgets', 'Core', 'Gui', 'Qml', 'Quick'],
required: true)
inc = include_directories('.')
foo = static_library('foo', 'lib.cpp',
include_directories: [inc],
override_options : ['cpp_std=c++17'],
dependencies : [qt6_dep])
pkg = import('pkgconfig')
pkg.generate(foo)
executable('demo', 'main.cpp',
override_options : ['cpp_std=c++17'],
link_with : foo,
dependencies: [qt6_dep])
main.cpp
#include "lib.hpp"
int main(int argc, char *argv[])
{
hello(argc, argv);
}
lib.hpp
bool hello(int argc, char *argv[]);
lib.cpp
#include "lib.hpp"
#include <iostream>
#include <QApplication>
bool hello(int argc, char *argv[]) {
std::cout << "Hello, World!" << std::endl;
QApplication app(argc, argv);
return app.exec();
}
build.bat
@ECHO OFF
RMDIR /S /Q builddir
MKDIR builddir
meson setup --wipe builddir\
PUSHD builddir
meson compile -v
POPD
Expected behavior
The generated pkg-config files (foo.pc) should have all Unix file separators.
system parameters
- OS: Windows 11
- Compiler: MSVC (19.36.32535 x64)
meson --version
: 1.4.0ninja --version
: 1.11.1python --version
: 3.11.9