summaryrefslogtreecommitdiffstats
path: root/cmake/QtSetup.cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2019-05-08 14:45:41 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2019-05-15 11:31:31 +0000
commit02a015375a639a4d27d19bbf435f20b725696768 (patch)
tree6efe36f0290cbe7d5eb4c44f847974c1bd44f645 /cmake/QtSetup.cmake
parent6396d46f554e6eab2ba7f212bd7447961cd4c286 (diff)
Implement developer / non-prefix builds
A non-prefix build is a build where you don't have to run make install. To do a non-prefix build, pass -DFEATURE_developer_build=ON when invoking CMake on qtbase. Note that this of course also enables developer build features (private tests, etc). When doing a non-prefix build, the CMAKE_INSTALL_PREFIX cache variable will point to the qtbase build directory. Tests can be run without installing Qt (QPA plugins are picked up from the build dir). This patch stops installation of any files by forcing the make "install" target be a no-op. When invoking cmake on the qtsvg module (or any other module), the CMAKE_INSTALL_PREFIX variable should be set to the qtbase build directory. The developer-build feature is propagated via the QtCore Config file, so that when building other modules, you don't have to specify it on the command line again. As a result of the change, all libraries, plugins, tools, include dirs, CMake Config files, CMake Targets files, Macro files, etc, will be placed in the qtbase build directory, mimicking the file layout of an installed Qt file layout. Only examples and tests are kept in the separate module build directories, which is equivalent to how qmake does it. The following global variables contain paths for the appropriate prefix or non prefix builds: QT_BUILD_DIR, QT_INSTALL_DIR, QT_CONFIG_BUILD_DIR, QT_CONFIG_INSTALL_DIR. These should be used by developers when deciding where files should be placed. All usages of install() are replaced by qt_install(), which has some additional logic on how to handle associationg of CMake targets to export names. When installing files, some consideration should be taken if qt_copy_or_install() needs to be used instead of qt_install(), which takes care of copying files from the source dir to the build dir when doing non-prefix builds. Tested with qtbase and qtsvg, developer builds, non-developer builds and static developer builds on Windows, Linux and macOS. Task-number: QTBUG-75581 Change-Id: I0ed27fb6467662dd24fb23aee6b95dd2c9c4061f Reviewed-by: Kevin Funk <kevin.funk@kdab.com> Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Diffstat (limited to 'cmake/QtSetup.cmake')
-rw-r--r--cmake/QtSetup.cmake17
1 files changed, 17 insertions, 0 deletions
diff --git a/cmake/QtSetup.cmake b/cmake/QtSetup.cmake
index 7285c0c516..187f1bf740 100644
--- a/cmake/QtSetup.cmake
+++ b/cmake/QtSetup.cmake
@@ -34,6 +34,20 @@ set(CMAKE_C_VISIBILITY_PRESET hidden)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
+if(FEATURE_developer_build)
+ set(QT_WILL_INSTALL OFF)
+ # Handle non-prefix builds by setting the cmake install prefix to the project binary dir.
+ if(PROJECT_NAME STREQUAL "QtBase")
+ set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR} CACHE PATH
+ "Install path prefix, prepended onto install directories." FORCE)
+ else()
+ # No-op. While building another module, the CMAKE_INSTALL_PREFIX should be set on the
+ # command line to point to the qtbase build dir.
+ endif()
+else()
+ set(QT_WILL_INSTALL ON)
+endif()
+
## Enable testing:
include(CTest)
enable_testing()
@@ -53,6 +67,9 @@ include(QtCompilerOptimization)
## Compiler flags:
include(QtCompilerFlags)
+## Set up developer build:
+qt_set_up_developer_build()
+
## Find host tools (if non native):
set(QT_HOST_PATH "" CACHE PATH "Installed Qt host directory path, used for cross compiling.")