summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-03-26 17:42:48 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-04-02 09:39:36 +0200
commit622894f96e93d62147a28a6f37b7ee6a90d74042 (patch)
treecb6250f435fcab8624312521b16cc768bfe7638b /cmake
parent560e8547b322b067348f57690462332b5943b394 (diff)
CMake: Allow excluding tools and apps from the default 'all' target
Qt uses the qtNomakeTools() function to mark a directory which will not be built as part of the default target. This is especially important when cross-compiling (to iOS for example) because the build process might fail. The condition for not building these "GUI tool sub-directory projects" is the absence of the "tools" value in qmake's QT_BUILD_PARTS variable. Introduce a QT_NO_MAKE_TOOLS CMake variable. If the value is true, it's equivalent to "tools" not being present in QT_BUILD_PARTS. Introduce qt_exclude_tool_directories_from_default_target(). It's the qmake counter part to qtNomakeTools(). Teach pro2cmake to generate it where appropriate. Change-Id: If2e5958d91847ab139af0e452608510286e73fa0 Reviewed-by: Leander Beernaert <leander.beernaert@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtBuild.cmake23
-rw-r--r--cmake/QtSetup.cmake6
2 files changed, 29 insertions, 0 deletions
diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake
index 6c5abb6bc4..26bee09564 100644
--- a/cmake/QtBuild.cmake
+++ b/cmake/QtBuild.cmake
@@ -4124,6 +4124,29 @@ function(qt_enable_msvc_cplusplus_define target visibility)
endif()
endfunction()
+# Equivalent of qmake's qtNomakeTools(directory1 directory2).
+# If QT_NO_MAKE_TOOLS is true, then the given directories will be excluded from the
+# default 'all' target.
+function(qt_exclude_tool_directories_from_default_target)
+ if(QT_NO_MAKE_TOOLS)
+ set(absolute_path_directories "")
+ foreach(directory ${ARGV})
+ list(APPEND absolute_path_directories "${CMAKE_CURRENT_SOURCE_DIR}/${directory}")
+ endforeach()
+
+ # Properties can only be set on processed directories (some might not be processed due to
+ # disabled features). So we need to exclude only processed directories.
+ get_directory_property(subdirectories SUBDIRECTORIES)
+
+ # Poor man's set intersection.
+ foreach(directory ${absolute_path_directories})
+ if(directory IN_LIST subdirectories)
+ set_property(DIRECTORY "${directory}" PROPERTY EXCLUDE_FROM_ALL TRUE)
+ endif()
+ endforeach()
+ endif()
+endfunction()
+
# Compatibility macros that should be removed once all their usages are removed.
function(extend_target)
qt_extend_target(${ARGV})
diff --git a/cmake/QtSetup.cmake b/cmake/QtSetup.cmake
index 3b43f44bdd..9e50787e72 100644
--- a/cmake/QtSetup.cmake
+++ b/cmake/QtSetup.cmake
@@ -122,6 +122,12 @@ if(QT_BUILD_STANDALONE_TESTS)
endif()
option(QT_NO_MAKE_TESTS "Should tests be built as part of the default 'all' target." OFF)
+# When cross-building, we don't build tools by default. Sometimes this also covers Qt apps as well.
+# Like in qttools/assistant/assistant.pro, load(qt_app), which is guarded by a qtNomakeTools() call.
+
+option(QT_NO_MAKE_TOOLS "Should tools be built as part of the default 'all' target."
+ "${CMAKE_CROSSCOMPILING}")
+
include(CTest)
enable_testing()