diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-04-06 18:45:19 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-04-07 23:22:33 +0200 |
commit | 0bfbe10ff20f271cff0c0af6ca1fb1894bb48d60 (patch) | |
tree | 56f57fa952cf133e3a91aa318625515058f65fca /cmake | |
parent | 5c9ab44ff6e3c2cda7738cfba5ab32f4be174ef2 (diff) |
CMake: Implement proper exclusion of tools including installing
The previous approach didn't work for prefix builds. While a target
might be excluded from building via EXCLUDE_FROM_ALL property, when
calling make install it would still try to install the target and
thus fail.
It's not possible to modify an install() command in a post-processing
step, so we switch the semantics around.
pro2cmake will now write a
qt_exclude_tool_directories_from_default_target() call before adding
subdirectories. This will set an internal variable with a list
of the given subdirectories, which is checked by qt_add_executable.
If the current source dir matches one of the given subdirectories,
the EXCLUDE_FROM_ALL property is set both for the target and the
qt_install() command.
This should fix the failing Android prefix builds of qttools.
Amends 622894f96e93d62147a28a6f37b7ee6a90d74042
Change-Id: Ia19323a2ef72a3fb9cb752ad2d4f2742269d11c4
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/QtBuild.cmake | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index 91c5e40b33..96b8458e54 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -2647,12 +2647,32 @@ function(qt_add_executable name) qt_internal_set_no_exceptions_flags("${name}") endif() + # Check if target needs to be excluded from all target. Also affects qt_install. + # Set by qt_exclude_tool_directories_from_default_target. + set(exclude_from_all FALSE) + if(__qt_exclude_tool_directories) + foreach(absolute_dir ${__qt_exclude_tool_directories}) + string(FIND "${CMAKE_CURRENT_SOURCE_DIR}" "${absolute_dir}" dir_starting_pos) + if(dir_starting_pos EQUAL 0) + set(exclude_from_all TRUE) + set_target_properties("${name}" PROPERTIES EXCLUDE_FROM_ALL TRUE) + break() + endif() + endforeach() + endif() if(NOT arg_NO_INSTALL) + set(additional_install_args "") + if(exclude_from_all) + list(APPEND additional_install_args EXCLUDE_FROM_ALL COMPONENT "ExcludedExecutables") + endif() + qt_install(TARGETS "${name}" + ${additional_install_args} # Needs to be before the DESTINATIONS. RUNTIME DESTINATION "${arg_INSTALL_DIRECTORY}" LIBRARY DESTINATION "${arg_INSTALL_DIRECTORY}" - BUNDLE DESTINATION "${arg_INSTALL_DIRECTORY}") + BUNDLE DESTINATION "${arg_INSTALL_DIRECTORY}" + ) endif() endfunction() @@ -4111,25 +4131,16 @@ function(qt_enable_msvc_cplusplus_define target visibility) 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. +# If QT_NO_MAKE_TOOLS is true, then targets within the given directories will be excluded from the +# default 'all' target, as well as from install phase. +# The private variable is checked by qt_add_executable. 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() + set(__qt_exclude_tool_directories "${absolute_path_directories}" PARENT_SCOPE) endif() endfunction() |