I'm trying to build simple Qt console app with using of new cc_import rule, bazel 0.10.1 on Windows 10.
Firstly, I tried to build it with cc_library rule.
My WORKSPACE, BUILD and main.cpp files are:
new_local_repository(
name = "qt",
path = "C:/Qt/5.9.2/msvc2017_64",
build_file_content = """
cc_library(
name = "QtCore",
srcs = ["lib/Qt5Core.lib"],
includes = ["include/"],
visibility = ["//visibility:public"],
)
"""
)
cc_binary(
name = "hello-qt-console",
srcs = [
"main.cpp",
],
deps = [
"@qt//:QtCore"
]
)
#include <QtCore/QCoreApplication>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
return a.exec();
}
It compiles fine, but does not copy the "C:\Qt\5.9.2\msvc2017_64\bin\Qt5Core.dll" to the output dir.
So I wanted to try new cc_import rule, but I cannot make this work.
Now my WORKSPACE file is:
new_local_repository(
name = "qt",
path = "C:/Qt/5.9.2/msvc2017_64",
build_file_content = """
cc_import(
name = "QtCore",
hdrs = glob(["include/QtCore/*"]),
interface_library = "lib/Qt5Core.lib",
shared_library = "bin/Qt5Core.dll",
visibility = ["//visibility:public"]
)
"""
)
But I'm getting such errors for all header files without extensions in "C:\Qt\5.9.2\msvc2017_64\include\QtCore" folder:
ERROR: D:/labs/bazel/helloqtconsole/output/external/qt/BUILD.bazel:4:12: in hdrs attribute of cc_import rule @qt//:QtCore: file '@qt//:include/QtCore/QException' is misplaced here (expected .h, .hh, .hpp, .ipp, .hxx or .inc)
ERROR: D:/labs/bazel/helloqtconsole/output/external/qt/BUILD.bazel:4:12: in hdrs attribute of cc_import rule @qt//:QtCore: '@qt//:include/QtCore/QException' does not produce any cc_import hdrs files (expected .h, .hh, .hpp, .ipp, .hxx or .inc)
There are header files with ".h" extension in "C:\Qt\5.9.2\msvc2017_64\include\QtCore" folder so I tried to changes my WORKSPACE and main.cpp files like this:
new_local_repository(
name = "qt",
path = "C:/Qt/5.9.2/msvc2017_64",
build_file_content = """
cc_import(
name = "QtCore",
hdrs = glob(["include/QtCore/*.h"]),
interface_library = "lib/Qt5Core.lib",
shared_library = "bin/Qt5Core.dll",
visibility = ["//visibility:public"]
)
"""
)
#include <QtCore/qcoreapplication.h>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
return a.exec();
}
After this I'm getting this error:
ERROR: D:/labs/bazel/helloqtconsole/BUILD:1:1: C++ compilation of rule '//:hello-qt-console' failed (Exit 2)
main.cpp(1): fatal error C1083: Cannot open include file: 'QtCore/qcoreapplication.h': No such file or directory
In my last attempt I tried to change path for "qcoreapplication.h" file in my main.cpp file like this:
#include <include/QtCore/qcoreapplication.h>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
return a.exec();
}
And now I'm getting this:
ERROR: D:/labs/bazel/helloqtconsole/BUILD:1:1: C++ compilation of rule '//:hello-qt-console' failed (Exit 2)
D:\labs\bazel\helloqtconsole\output\execroot\__main__\external\qt\include/QtCore/qcoreapplication.h(43): fatal error C1083: Cannot open include file: 'QtCore/qglobal.h': No such file or directory .
I think that something wrong with my paths, but I don't want to change anything in Qt's header files.
Could someone help me with constructing right WORKSPACE file with cc_import rule and without changes to Qt library?
Thanks.
--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/b10afe5f-afb3-447b-a86f-e51ac896ed0e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/4a4f6846-04ca-454a-813a-53b308e9d05b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.