-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use CMake to build plugin + fetch dependencies automatically #34
Conversation
This change ports the QMake build to CMake - a recommended way to build plugins according to the Qt Documentation: https://doc.qt.io/qtcreator-extending/first-plugin.html#cmake-project This also adds a number of useful features, for example, an ability to fetch neovim-qt and qtcreator automatically. Neovim-qt is downloaded and built with the Message Pack using FetchContent CMake feature. In case of QtCreator only the precompiled binaries are downloaded to save time.
4f19da6
to
7ca5307
Compare
Thanks! I'm getting errors like these in macOS:
Do you know anything about it? |
I've got similar errors when building against Qt Creator of later versions because of changed APIs. Perhaps CMake is linking to incorrect version of Qt Creator libs (the ones installed in the system, not the fetched ones). I took a look at the contetns of archive that is downloaded for macOS and it's quite different layout from Windows and Linux archives ( It seems like for macOS we need to set |
I'm a bit confused, are you using an older version of QtCreator compiled with Qt 5 to be able to compile and use this plugin? Because now I remember this plugin is not compatible with Qt Creator built with Qt 6, right? If that's the case I need to install an older version of Qt Creator, do you know what's the latest version using Qt 5? |
You don't have to install Qt Creator with this patch - it is downloaded for you with the specific hardcoded version. In this case it's 4.15.2 (It is old, but requires small amount of fixes in plugin source code). After it is downloaded, the plugin is built against it. After successful but you can launch an instance of it with the enabled plugin to test it. But in your case (on macOS) something went wrong and now the plugin build system tries to use some other Qt Creator, not the automatically downloaded one, hence the errors above. |
I see, that should be it then. I'm getting this error (even with your latest commit):
I was setting |
You should not need to add it. Could you try a clean build with the commit I just added? |
FetchContent_Declare(
qtcreator
URL "${QTC_URL}"
URL_HASH MD5=${QTC_MD5}
) This is extracting
is extracting
Either |
I fixed the directory structure bug, so you are welcome to test it. |
Thanks! diff --git a/cmake/FetchQtCreator.cmake b/cmake/FetchQtCreator.cmake
index 7a6ffae..9939cf7 100644
--- a/cmake/FetchQtCreator.cmake
+++ b/cmake/FetchQtCreator.cmake
@@ -51,7 +51,11 @@ if(NOT qtcreator_POPULATED)
# Add dev files into the same directory
file(DOWNLOAD "${QTC_DEV_URL}" "${qtcreator_SOURCE_DIR}/qtc_dev.7z" EXPECTED_MD5 ${QTC_DEV_MD5})
file(ARCHIVE_EXTRACT INPUT "${qtcreator_SOURCE_DIR}/qtc_dev.7z" DESTINATION "${qtcreator_BINARY_DIR}")
+endif()
- # Let the CMake Find scripts find Qt Creator files
+# Let the CMake Find scripts find Qt Creator files
+if(APPLE) # macOS
+ list(APPEND CMAKE_PREFIX_PATH "${qtcreator_BINARY_DIR}/Qt Creator.app/Contents/Resources/lib/cmake/QtCreator")
+else()
list(APPEND CMAKE_PREFIX_PATH "${qtcreator_BINARY_DIR}")
endif() so that cmake finds Qt Creator. And I'm getting this error:
|
No we don't need Qt6 for now. Indeed we can remove the Qt6 from dependencies. As for crash: this is strange. Did you try to run it with the debugger? |
I applied a Qt version patch and tried to fix the find_package for macOS by removing the space in the bundle name. I'm still not sure if it will work, since CMake docs do not list the path you added explicitly in their locations for search in macOS. Could you test if it works? If not, maybe the subdirectories of a bundle could be added to CMAKE_PREFIX_PATH. |
Unfortunately it didn't work, still getting this error:
It works by adding the subdirectories of the bundle to |
Latest commit is good. I try to find some time to see why it is crashing in macOS. |
The problem was a misconfiguration on my machine living from old versions. |
Summary
This change ports the QMake build to CMake - a recommended way to build plugins according to the Qt Documentation:
https://doc.qt.io/qtcreator-extending/first-plugin.html#cmake-project
This also adds a number of useful features, for example, an ability to fetch neovim-qt and qtcreator automatically.
Neovim-qt is downloaded and built with the Message Pack using FetchContent CMake feature. In case of QtCreator only the precompiled binaries are downloaded to save time.
Test Plan
%{buildDir}\_deps\qtcreator-src\bin\qtcreator.exe
-pluginpath %{buildDir}\lib\qtcreator\plugins
Configurations tested:
CC #32