Skip to content
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

Add better Qt5 detection #4067

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
Draft

Add better Qt5 detection #4067

wants to merge 11 commits into from

Conversation

tresf
Copy link
Member

@tresf tresf commented Dec 23, 2017

Making a cmake project with Qt5 dependencies can vary in difficulty depending on how Qt5 was obtained.

For example:

  • On Linux, Qt5 is usually offered from a package manager, such as apt or dnf, but it's also quite common to install Qt5 manually into /opt/.
  • On Mac, Qt5 is usually fulfilled by homebrew or macports however it is also fairly common to install from the QtCreator desktop installer.
  • On Windows, Qt5 is usually installed directly from the QtCreator desktop installer, but may also be obtained from msys2.
    • Windows makes this even harder because QtCreator comes bundled with various C++ compatible versions including mingw, MSVC 2015 32-bit, MSVC 2015 64-bit, etc. You need to know your exact compiler version and manually add that each time you build a project using cmake.

What this PR aims to do is allow cmake .. to find Qt5 without a hassle on the most common build environments. This means the average developer should never need to type brew --prefix qt5 or export CMAKE_PREFIX_PATH=/path/to/qt5 again, although that "normal" technique will still remain to be supported.

Usage

INCLUDE(FindQt5All)
FIND_PACKAGE(Qt5Core REQUIRED)

Progress

OS Source Module Working
Linux from package manager FindQt5Linux.cmake
Linux from 3rd-party ppa FindQt5Linux.cmake
Linux from qt.io FindQt5Linux.cmake
Windows from QtCreator + MSVC FindQt5Windows.cmake
Windows from QtCreator + mingw FindQt5Windows.cmake
macOS from QtCreator FindQt5Apple.cmake
macOS from homebrew FindQt5Apple.cmake
macOS from macports FindQt5Apple.cmake

Additional Modules

Some detection techniques include parsing of command output (e.g. EXECUTE_PROCESS(...)), so an additional module has been added EnglishLocale.cmake.

Usage:

INCLUDE(EnglishLocale)
USE_ENGLISH_LOCALE()  # SET COMMANDS TO USE ENGLISH STANDARD OUTPUT
EXECUTE_PROCESS(...)
USE_DEFAULT_LOCALE()  # RESET COMMAND ENVIRONMENT BACK TO NATIVE LOCALE

This PR is a work in progress and should be merged once the most common platforms have been completed.

@tresf tresf added this to the 1.3.0 milestone Dec 23, 2017
@tresf tresf self-assigned this Dec 23, 2017
@PhysSong
Copy link
Member

@tresf What's the status of this PR?

@tresf
Copy link
Member Author

tresf commented Oct 23, 2019

@tresf What's the status of this PR?

Stalled. 😄

Seriously though:

  1. There are unrelated changes in here, like the SDL and FFTW include dirs and the AppVeyor stuff. They can probably be removed.
  2. Someone that actually develops on Windows using master should help with the various Qt detection environments. Does vcpkg handle Qt detection? How do people do it?
  3. macOS really needs this PR as it's stupid to keep typing export CMAKE_PREFIX_PATH=$(brew --prefix qt5) every time I build.
  4. Linux, I have no idea and it's probably a good candidate for the back burner considering Linux often just uses the repo version of Qt (versus Win/Mac which download it manually most of the time).

I don't have the time to dedicate to this right now, but the code is good, even if as a reference point for someone else to run with hit.

@LmmsBot
Copy link

LmmsBot commented Jul 30, 2022

🤖 Hey, I'm @LmmsBot from github.com/lmms/bot and I made downloads for this pull request, click me to make them magically appear! 🎩

Linux

Windows

macOS

🤖
{"platform_name_to_artifacts": {"Linux": [{"artifact": {"title": {"title": "(AppImage)", "platform_name": "Linux"}, "link": {"link": "https://output.circle-artifacts.com/output/job/a6b6904b-21fa-41ef-9531-b93d53fd7553/artifacts/0/lmms-1.3.0-alpha.1.225+g9caf35e64-linux-x86_64.AppImage"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/17853?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}], "Windows": [{"artifact": {"title": {"title": "32-bit", "platform_name": "Windows"}, "link": {"link": "https://output.circle-artifacts.com/output/job/2b65ef87-bb1e-4b0b-a4df-bb6e01616a55/artifacts/0/lmms-1.3.0-alpha.1.225+g9caf35e64-mingw-win32.exe"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/17852?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}, {"artifact": {"title": {"title": "64-bit", "platform_name": "Windows"}, "link": {"link": "https://output.circle-artifacts.com/output/job/e07bd744-6539-4de2-ab75-497d4e00f022/artifacts/0/lmms-1.3.0-alpha.1.225+g9caf35e64-mingw-win64.exe"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/17855?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}, {"artifact": {"title": {"title": "32-bit", "platform_name": "Windows"}, "link": {"link": "https://ci.appveyor.com/api/buildjobs/3vxmr46kc8ctjmbk/artifacts/build/lmms-1.3.0-alpha-msvc2017-win32.exe"}}, "build_link": "https://ci.appveyor.com/project/Lukas-W/lmms/builds/44323790"}, {"artifact": {"title": {"title": "64-bit", "platform_name": "Windows"}, "link": {"link": "https://ci.appveyor.com/api/buildjobs/9yevxhlnb8vmwib0/artifacts/build/lmms-1.3.0-alpha-msvc2017-win64.exe"}}, "build_link": "https://ci.appveyor.com/project/Lukas-W/lmms/builds/44323790"}], "macOS": [{"artifact": {"title": {"title": "", "platform_name": "macOS"}, "link": {"link": "https://output.circle-artifacts.com/output/job/16d19b1c-6cac-4d7f-9488-7f7f9dc132a4/artifacts/0/lmms-1.3.0-alpha.1.225+g9caf35e64-mac10.14.dmg"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/17851?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}]}, "commit_sha": "25cb65ac5188df2da27127705b68d1736621f539"}

@Rossmaxx
Copy link
Contributor

@tresf is there anything of use here anymore?

@Rossmaxx
Copy link
Contributor

Windows makes this even harder because QtCreator comes bundled with various C++ compatible versions including mingw, MSVC 2015 32-bit, MSVC 2015 64-bit, etc. You need to know your exact compiler version and manually add that each time you build a project using cmake.

This is now even harder, MSVC 2022 is not available for qt5 and we use MSVC 2019 qt for compiling on 2022. So we need another attempt here. I can help with windows stuff.

@tresf
Copy link
Member Author

tresf commented May 22, 2024

@tresf is there anything of use here anymore?

If the question is whether or not this will be merged, the answer is "probably not".
If the question is whether or not we'll use this code, we probably will.

I came back to this last week and decided that it's due for a refactor, especially for Qt6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants