cmake: move dependencies accumulation in QtPostProcess.cmake
This is needed because dependencies added after add_qt_module with extend_target are currently not taken into account. Task-number: QTBUG-75538 Change-Id: I2c72207fb88b2480e41a2c8550978fb194275617 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
914b367c7f
commit
753d35cd56
@ -422,6 +422,22 @@ function(extend_target target)
|
|||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
# Find dependencies to internal libraries
|
||||||
|
get_target_property(target_deps "${target}" _qt_target_deps)
|
||||||
|
if(NOT target_deps)
|
||||||
|
set(target_deps "")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
foreach(lib ${arg_LIBRARIES})
|
||||||
|
if (TARGET "${lib}")
|
||||||
|
get_target_property(_is_exported "${lib}" INTERFACE_QT_EXPORTED_LIBRARY)
|
||||||
|
if("${_is_exported}")
|
||||||
|
list(APPEND target_deps "${lib}\;${PROJECT_VERSION}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
# Set-up the target
|
||||||
target_sources("${target}" PRIVATE ${arg_SOURCES} ${dbus_sources})
|
target_sources("${target}" PRIVATE ${arg_SOURCES} ${dbus_sources})
|
||||||
if (arg_COMPILE_FLAGS)
|
if (arg_COMPILE_FLAGS)
|
||||||
set_source_files_properties(${arg_SOURCES} PROPERTIES COMPILE_FLAGS "${arg_COMPILE_FLAGS}")
|
set_source_files_properties(${arg_SOURCES} PROPERTIES COMPILE_FLAGS "${arg_COMPILE_FLAGS}")
|
||||||
@ -431,7 +447,11 @@ function(extend_target target)
|
|||||||
target_link_libraries("${target}" PUBLIC ${arg_PUBLIC_LIBRARIES} PRIVATE ${arg_LIBRARIES})
|
target_link_libraries("${target}" PUBLIC ${arg_PUBLIC_LIBRARIES} PRIVATE ${arg_LIBRARIES})
|
||||||
target_compile_options("${target}" PUBLIC ${arg_PUBLIC_COMPILE_OPTIONS} PRIVATE ${arg_COMPILE_OPTIONS})
|
target_compile_options("${target}" PUBLIC ${arg_PUBLIC_COMPILE_OPTIONS} PRIVATE ${arg_COMPILE_OPTIONS})
|
||||||
target_link_options("${target}" PUBLIC ${arg_PUBLIC_LINK_OPTIONS} PRIVATE ${arg_LINK_OPTIONS})
|
target_link_options("${target}" PUBLIC ${arg_PUBLIC_LINK_OPTIONS} PRIVATE ${arg_LINK_OPTIONS})
|
||||||
set_target_properties("${target}" PROPERTIES AUTOMOC_MOC_OPTIONS "${arg_MOC_OPTIONS}")
|
|
||||||
|
set_target_properties("${target}" PROPERTIES
|
||||||
|
AUTOMOC_MOC_OPTIONS "${arg_MOC_OPTIONS}"
|
||||||
|
_qt_target_deps "${target_deps}"
|
||||||
|
)
|
||||||
else()
|
else()
|
||||||
if(QT_CMAKE_DEBUG_EXTEND_TARGET)
|
if(QT_CMAKE_DEBUG_EXTEND_TARGET)
|
||||||
message("extend_target(${target} CONDITION ${arg_CONDITION} ...): Skipped")
|
message("extend_target(${target} CONDITION ${arg_CONDITION} ...): Skipped")
|
||||||
@ -698,7 +718,13 @@ function(add_qt_module target)
|
|||||||
$<INSTALL_INTERFACE:include/${module}/${PROJECT_VERSION}/${module}>
|
$<INSTALL_INTERFACE:include/${module}/${PROJECT_VERSION}/${module}>
|
||||||
)
|
)
|
||||||
|
|
||||||
set(target_deps)
|
get_target_property(target_deps "${target}" _qt_target_deps)
|
||||||
|
if(NOT target_deps)
|
||||||
|
set(target_deps "")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# TODO: should this also be in extend_target ? From the looks of it I would say that
|
||||||
|
# it is not necessary but I'm not sure
|
||||||
foreach(lib IN LISTS arg_PUBLIC_LIBRARIES qt_libs_private)
|
foreach(lib IN LISTS arg_PUBLIC_LIBRARIES qt_libs_private)
|
||||||
if ("${lib}" MATCHES "^Qt::(.*)")
|
if ("${lib}" MATCHES "^Qt::(.*)")
|
||||||
set(lib "${CMAKE_MATCH_1}")
|
set(lib "${CMAKE_MATCH_1}")
|
||||||
@ -712,14 +738,7 @@ function(add_qt_module target)
|
|||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
foreach(lib ${arg_LIBRARIES})
|
set_target_properties("${target}" PROPERTIES _qt_target_deps "${target_deps}")
|
||||||
if (TARGET "${lib}")
|
|
||||||
get_target_property(_is_exported "${lib}" INTERFACE_QT_EXPORTED_LIBRARY)
|
|
||||||
if("${_is_exported}")
|
|
||||||
list(APPEND target_deps "${lib}\;${PROJECT_VERSION}")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
configure_package_config_file(
|
configure_package_config_file(
|
||||||
"${QT_CMAKE_DIR}/QtModuleConfig.cmake.in"
|
"${QT_CMAKE_DIR}/QtModuleConfig.cmake.in"
|
||||||
|
@ -10,24 +10,6 @@ if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Dependenci
|
|||||||
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Dependencies.cmake")
|
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Dependencies.cmake")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# note: target_deps example: "Qt5Core\;5.12.0;Qt5Gui\;5.12.0"
|
|
||||||
set(_target_deps "@target_deps@")
|
|
||||||
foreach(_target_dep ${_target_deps})
|
|
||||||
list(GET _target_dep 0 pkg)
|
|
||||||
list(GET _target_dep 1 version)
|
|
||||||
|
|
||||||
if (NOT ${pkg}_FOUND)
|
|
||||||
find_dependency(${pkg} ${version}
|
|
||||||
PATHS "${CMAKE_CURRENT_LIST_DIR}/.." NO_DEFAULT_PATH
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (NOT ${pkg}_FOUND)
|
|
||||||
set(@INSTALL_CMAKE_NAMESPACE@@target@_FOUND FALSE)
|
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Targets.cmake")
|
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Targets.cmake")
|
||||||
|
|
||||||
foreach(extra_cmake_include @extra_cmake_includes@)
|
foreach(extra_cmake_include @extra_cmake_includes@)
|
||||||
|
@ -49,3 +49,22 @@ foreach(_target_dep ${_tool_deps})
|
|||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
# note: target_deps example: "Qt5Core\;5.12.0;Qt5Gui\;5.12.0"
|
||||||
|
set(_target_deps "@target_deps@")
|
||||||
|
foreach(_target_dep ${_target_deps})
|
||||||
|
list(GET _target_dep 0 pkg)
|
||||||
|
list(GET _target_dep 1 version)
|
||||||
|
|
||||||
|
if (NOT ${pkg}_FOUND)
|
||||||
|
find_dependency(${pkg} ${version}
|
||||||
|
PATHS "${CMAKE_CURRENT_LIST_DIR}/.." NO_DEFAULT_PATH
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (NOT ${pkg}_FOUND)
|
||||||
|
set(@INSTALL_CMAKE_NAMESPACE@@target@_FOUND FALSE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,11 +17,15 @@ function(qt_internal_create_depends_files)
|
|||||||
foreach (target ${QT_KNOWN_MODULES})
|
foreach (target ${QT_KNOWN_MODULES})
|
||||||
get_target_property(depends "${target}" LINK_LIBRARIES)
|
get_target_property(depends "${target}" LINK_LIBRARIES)
|
||||||
get_target_property(public_depends "${target}" INTERFACE_LINK_LIBRARIES)
|
get_target_property(public_depends "${target}" INTERFACE_LINK_LIBRARIES)
|
||||||
|
get_target_property(target_deps "${target}" _qt_target_deps)
|
||||||
|
set(target_deps_seen "")
|
||||||
|
|
||||||
set(qtdeps "")
|
set(qtdeps "")
|
||||||
set(third_party_deps "")
|
set(third_party_deps "")
|
||||||
set(third_party_deps_seen "")
|
set(third_party_deps_seen "")
|
||||||
set(tool_deps "")
|
set(tool_deps "")
|
||||||
set(tool_deps_seen "")
|
set(tool_deps_seen "")
|
||||||
|
|
||||||
foreach (dep ${depends})
|
foreach (dep ${depends})
|
||||||
# Normalize module by stripping leading "Qt::" and trailing "Private"
|
# Normalize module by stripping leading "Qt::" and trailing "Private"
|
||||||
if (dep MATCHES "Qt::(.*)")
|
if (dep MATCHES "Qt::(.*)")
|
||||||
@ -82,6 +86,24 @@ function(qt_internal_create_depends_files)
|
|||||||
"${INSTALL_CMAKE_NAMESPACE}${target}Tools\;${PROJECT_VERSION}")
|
"${INSTALL_CMAKE_NAMESPACE}${target}Tools\;${PROJECT_VERSION}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Dirty hack because https://gitlab.kitware.com/cmake/cmake/issues/19200
|
||||||
|
foreach(dep ${target_deps})
|
||||||
|
if(dep)
|
||||||
|
list(FIND target_deps_seen "${dep}" dep_seen)
|
||||||
|
if(dep_seen EQUAL -1)
|
||||||
|
list(LENGTH dep len)
|
||||||
|
if(NOT (len EQUAL 2))
|
||||||
|
message(FATAL_ERROR "List '${dep}' should look like QtFoo;version")
|
||||||
|
endif()
|
||||||
|
list(GET dep 0 dep_name)
|
||||||
|
list(GET dep 1 dep_ver)
|
||||||
|
|
||||||
|
list(APPEND target_deps_seen "${dep_name}\;${dep_ver}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
set(target_deps "${target_deps_seen}")
|
||||||
|
|
||||||
if (DEFINED qtdeps)
|
if (DEFINED qtdeps)
|
||||||
list(REMOVE_DUPLICATES qtdeps)
|
list(REMOVE_DUPLICATES qtdeps)
|
||||||
endif()
|
endif()
|
||||||
@ -92,7 +114,7 @@ function(qt_internal_create_depends_files)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
if(third_party_deps OR main_module_tool_deps)
|
if(third_party_deps OR main_module_tool_deps OR target_deps)
|
||||||
# Configure and install ModuleDependencies file.
|
# Configure and install ModuleDependencies file.
|
||||||
configure_file(
|
configure_file(
|
||||||
"${QT_CMAKE_DIR}/QtModuleDependencies.cmake.in"
|
"${QT_CMAKE_DIR}/QtModuleDependencies.cmake.in"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user