Building Qt6 manually from source
-
I have a project that I am using cmake to build. I only need QtBase for my project and want to build only it. I'd rather have the source in my tree. Whenever I use add_subdirectory with the QtBase directory, the build always fails with a qt6config.cmake not found. When I point cmake to the folder in the build directory where it will be when the build starts, I get qt6targets.cmake not found. How would I build qt6base alone within my source tree?
-
@daedelus1996 you need to run configure at least once, then, maaaaybe it will work. But I doubt it, Qt code is not written with such use case in mind.
-
@daedelus1996 , Qt by default expects to be installed before used. I don't think just using add_subdirectory() will work, at least if you want to use any of the CMake convenience like find_package(Qt6 ...) in your code.
Maybe using something like CMake's ExternalProject, vcpkg or Conan is an alternative for you?
-
CMake's ExternalProject_Add works with the bare minimum CMakeLists.txt shown below:
cmake_minimum_required(VERSION ...) project(...) include(ExternalProject) ExternalProject_Add(QtBase SOURCE_DIR ${CMAKE_SOURCE_DIR}/...)
-