blob: 10dd5bfbb16fc11cb49a6e6a0cfa3addc03d503a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
function(qt_internal_write_depends_file target)
set(module Qt${target})
set(outfile "${PROJECT_BINARY_DIR}/include/${module}/${module}Depends")
message("Generate ${outfile}...")
set(contents "/* This file was generated by cmake with the info from ${module} target. */\n")
string(APPEND contents "#ifdef __cplusplus /* create empty PCH in C mode */\n")
foreach (m ${ARGN})
string(APPEND contents "# include <Qt${m}/Qt${m}>\n")
endforeach()
string(APPEND contents "#endif\n")
file(GENERATE OUTPUT "${outfile}" CONTENT "${contents}")
endfunction()
function(qt_internal_create_depends_files)
message("Generating depends files for ${QT_KNOWN_MODULES}...")
foreach (target ${QT_KNOWN_MODULES})
get_target_property(depends "${target}" LINK_LIBRARIES)
get_target_property(public_depends "${target}" INTERFACE_LINK_LIBRARIES)
set(qtdeps "")
set(third_party_deps "")
set(third_party_deps_seen "")
foreach (dep ${depends})
# Normalize module by stripping leading "Qt::" and trailing "Private"
if (dep MATCHES "Qt::(.*)")
set(dep "${CMAKE_MATCH_1}")
endif()
if (dep MATCHES "(.*)Private")
set(dep "${CMAKE_MATCH_1}")
endif()
list(FIND QT_KNOWN_MODULES "${dep}" _pos)
if (_pos GREATER -1)
list(APPEND qtdeps "${dep}")
endif()
endforeach()
# If we are doing a non-static Qt build, we only want to propagate public dependencies.
# If we are doing a static Qt build, we need to propagate all dependencies.
set(depends_var "public_depends")
if(NOT QT_BUILD_SHARED_LIBS)
set(depends_var "depends")
endif()
foreach(dep ${${depends_var}})
# Gather third party packages that should be found when using the Qt module.
if(TARGET ${dep})
list(FIND third_party_deps_seen ${dep} dep_seen)
get_target_property(package_name ${dep} INTERFACE_QT_PACKAGE_NAME)
if(dep_seen EQUAL -1 AND package_name)
list(APPEND third_party_deps_seen ${dep})
get_target_property(package_version ${dep} INTERFACE_QT_PACKAGE_VERSION)
if(NOT package_version)
set(package_version "")
endif()
get_target_property(package_components ${dep} INTERFACE_QT_PACKAGE_COMPONENTS)
if(NOT package_components)
set(package_components "")
endif()
list(APPEND third_party_deps
"${package_name}\;${package_version}\;${package_components}")
endif()
endif()
endforeach()
if (DEFINED qtdeps)
list(REMOVE_DUPLICATES qtdeps)
endif()
get_target_property(hasModuleHeaders "${target}" MODULE_HAS_HEADERS)
if (${hasModuleHeaders})
qt_internal_write_depends_file("${target}" ${qtdeps})
endif()
if(third_party_deps)
# Configure and install dependencies file.
configure_file(
"${QT_CMAKE_DIR}/QtModuleDependencies.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/${INSTALL_CMAKE_NAMESPACE}${target}Dependencies.cmake"
@ONLY
)
set(config_install_dir "${INSTALL_LIBDIR}/cmake/${INSTALL_CMAKE_NAMESPACE}${target}")
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/${INSTALL_CMAKE_NAMESPACE}${target}Dependencies.cmake"
DESTINATION "${config_install_dir}"
COMPONENT Devel
)
endif()
endforeach()
endfunction()
qt_internal_create_depends_files()
|