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>
This commit is contained in:
parent
5c9ab44ff6
commit
0bfbe10ff2
@ -2647,12 +2647,32 @@ function(qt_add_executable name)
|
|||||||
qt_internal_set_no_exceptions_flags("${name}")
|
qt_internal_set_no_exceptions_flags("${name}")
|
||||||
endif()
|
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)
|
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}"
|
qt_install(TARGETS "${name}"
|
||||||
|
${additional_install_args} # Needs to be before the DESTINATIONS.
|
||||||
RUNTIME DESTINATION "${arg_INSTALL_DIRECTORY}"
|
RUNTIME DESTINATION "${arg_INSTALL_DIRECTORY}"
|
||||||
LIBRARY DESTINATION "${arg_INSTALL_DIRECTORY}"
|
LIBRARY DESTINATION "${arg_INSTALL_DIRECTORY}"
|
||||||
BUNDLE DESTINATION "${arg_INSTALL_DIRECTORY}")
|
BUNDLE DESTINATION "${arg_INSTALL_DIRECTORY}"
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
@ -4111,25 +4131,16 @@ function(qt_enable_msvc_cplusplus_define target visibility)
|
|||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
# Equivalent of qmake's qtNomakeTools(directory1 directory2).
|
# Equivalent of qmake's qtNomakeTools(directory1 directory2).
|
||||||
# If QT_NO_MAKE_TOOLS is true, then the given directories will be excluded from the
|
# If QT_NO_MAKE_TOOLS is true, then targets within the given directories will be excluded from the
|
||||||
# default 'all' target.
|
# 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)
|
function(qt_exclude_tool_directories_from_default_target)
|
||||||
if(QT_NO_MAKE_TOOLS)
|
if(QT_NO_MAKE_TOOLS)
|
||||||
set(absolute_path_directories "")
|
set(absolute_path_directories "")
|
||||||
foreach(directory ${ARGV})
|
foreach(directory ${ARGV})
|
||||||
list(APPEND absolute_path_directories "${CMAKE_CURRENT_SOURCE_DIR}/${directory}")
|
list(APPEND absolute_path_directories "${CMAKE_CURRENT_SOURCE_DIR}/${directory}")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
set(__qt_exclude_tool_directories "${absolute_path_directories}" PARENT_SCOPE)
|
||||||
# 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()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
@ -1800,8 +1800,8 @@ def handle_subdir(
|
|||||||
handle_subdir_helper(
|
handle_subdir_helper(
|
||||||
scope, cm_fh, indent=indent, current_conditions=current_conditions, is_example=is_example
|
scope, cm_fh, indent=indent, current_conditions=current_conditions, is_example=is_example
|
||||||
)
|
)
|
||||||
group_and_print_sub_dirs(scope, indent=indent)
|
|
||||||
|
|
||||||
|
# Make sure to exclude targets within subdirectories first.
|
||||||
qt_no_make_tools = scope.get("_QT_NO_MAKE_TOOLS")
|
qt_no_make_tools = scope.get("_QT_NO_MAKE_TOOLS")
|
||||||
if qt_no_make_tools:
|
if qt_no_make_tools:
|
||||||
ind = spaces(indent + 1)
|
ind = spaces(indent + 1)
|
||||||
@ -1812,6 +1812,9 @@ def handle_subdir(
|
|||||||
f"\nqt_exclude_tool_directories_from_default_target(\n{directories_string})\n\n"
|
f"\nqt_exclude_tool_directories_from_default_target(\n{directories_string})\n\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Then write the subdirectories.
|
||||||
|
group_and_print_sub_dirs(scope, indent=indent)
|
||||||
|
|
||||||
|
|
||||||
def sort_sources(sources: List[str]) -> List[str]:
|
def sort_sources(sources: List[str]) -> List[str]:
|
||||||
to_sort = {} # type: Dict[str, List[str]]
|
to_sort = {} # type: Dict[str, List[str]]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user