Project

General

Profile

Support Request #2237 » Qt5GuiConfig.cmake

hidden, 2018-04-16 14:30

 
1

    
2
if (CMAKE_VERSION VERSION_LESS 2.8.3)
3
    message(FATAL_ERROR "Qt 5 requires at least CMake version 2.8.3")
4
endif()
5

    
6
get_filename_component(_qt5Gui_install_prefix "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
7

    
8
# For backwards compatibility only. Use Qt5Gui_VERSION instead.
9
set(Qt5Gui_VERSION_STRING ..)
10

    
11
set(Qt5Gui_LIBRARIES Qt5::Gui)
12

    
13
macro(_qt5_Gui_check_file_exists file)
14
    if(NOT EXISTS "${file}" )
15
        message(FATAL_ERROR "The imported target \"Qt5::Gui\" references the file
16
   \"${file}\"
17
but this file does not exist.  Possible reasons include:
18
* The file was deleted, renamed, or moved to another location.
19
* An install or uninstall procedure did not complete successfully.
20
* The installation package was faulty and contained
21
   \"${CMAKE_CURRENT_LIST_FILE}\"
22
but not all the files it references.
23
")
24
    endif()
25
endmacro()
26

    
27
macro(_populate_Gui_target_properties Configuration LIB_LOCATION IMPLIB_LOCATION)
28
    set_property(TARGET Qt5::Gui APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration})
29

    
30
    set(imported_location "${_qt5Gui_install_prefix}/bin/${LIB_LOCATION}")
31
    _qt5_Gui_check_file_exists(${imported_location})
32
    set_target_properties(Qt5::Gui PROPERTIES
33
        "INTERFACE_LINK_LIBRARIES" "${_Qt5Gui_LIB_DEPENDENCIES}"
34
        "IMPORTED_LOCATION_${Configuration}" ${imported_location}
35
        # For backward compatibility with CMake < 2.8.12
36
        "IMPORTED_LINK_INTERFACE_LIBRARIES_${Configuration}" "${_Qt5Gui_LIB_DEPENDENCIES}"
37
    )
38

    
39
    set(imported_implib "${_qt5Gui_install_prefix}/lib/${IMPLIB_LOCATION}")
40
    _qt5_Gui_check_file_exists(${imported_implib})
41
    if(NOT "${IMPLIB_LOCATION}" STREQUAL "")
42
        set_target_properties(Qt5::Gui PROPERTIES
43
        "IMPORTED_IMPLIB_${Configuration}" ${imported_implib}
44
        )
45
    endif()
46
endmacro()
47

    
48
if (NOT TARGET Qt5::Gui)
49

    
50
    set(_Qt5Gui_OWN_INCLUDE_DIRS "${_qt5Gui_install_prefix}/include/" "${_qt5Gui_install_prefix}/include/QtGui")
51
    set(Qt5Gui_PRIVATE_INCLUDE_DIRS
52
        "${_qt5Gui_install_prefix}/include/QtGui/5.9.0"
53
        "${_qt5Gui_install_prefix}/include/QtGui/5.9.0/QtGui"
54
    )
55

    
56
    foreach(_dir ${_Qt5Gui_OWN_INCLUDE_DIRS})
57
        _qt5_Gui_check_file_exists(${_dir})
58
    endforeach()
59

    
60
    # Only check existence of private includes if the Private component is
61
    # specified.
62
    list(FIND Qt5Gui_FIND_COMPONENTS Private _check_private)
63
    if (NOT _check_private STREQUAL -1)
64
        foreach(_dir ${Qt5Gui_PRIVATE_INCLUDE_DIRS})
65
            _qt5_Gui_check_file_exists(${_dir})
66
        endforeach()
67
    endif()
68

    
69
    set(Qt5Gui_INCLUDE_DIRS ${_Qt5Gui_OWN_INCLUDE_DIRS})
70

    
71
    set(Qt5Gui_DEFINITIONS -DQT_GUI_LIB)
72
    set(Qt5Gui_COMPILE_DEFINITIONS QT_GUI_LIB)
73
    set(_Qt5Gui_MODULE_DEPENDENCIES "Core")
74

    
75

    
76
    set(Qt5Gui_OWN_PRIVATE_INCLUDE_DIRS ${Qt5Gui_PRIVATE_INCLUDE_DIRS})
77

    
78
    set(_Qt5Gui_FIND_DEPENDENCIES_REQUIRED)
79
    if (Qt5Gui_FIND_REQUIRED)
80
        set(_Qt5Gui_FIND_DEPENDENCIES_REQUIRED REQUIRED)
81
    endif()
82
    set(_Qt5Gui_FIND_DEPENDENCIES_QUIET)
83
    if (Qt5Gui_FIND_QUIETLY)
84
        set(_Qt5Gui_DEPENDENCIES_FIND_QUIET QUIET)
85
    endif()
86
    set(_Qt5Gui_FIND_VERSION_EXACT)
87
    if (Qt5Gui_FIND_VERSION_EXACT)
88
        set(_Qt5Gui_FIND_VERSION_EXACT EXACT)
89
    endif()
90

    
91
    set(Qt5Gui_EXECUTABLE_COMPILE_FLAGS "")
92

    
93
    foreach(_module_dep ${_Qt5Gui_MODULE_DEPENDENCIES})
94
        if (NOT Qt5${_module_dep}_FOUND)
95
            find_package(Qt5${_module_dep}
96
                5.9.0 ${_Qt5Gui_FIND_VERSION_EXACT}
97
                ${_Qt5Gui_DEPENDENCIES_FIND_QUIET}
98
                ${_Qt5Gui_FIND_DEPENDENCIES_REQUIRED}
99
                PATHS "${CMAKE_CURRENT_LIST_DIR}/.." NO_DEFAULT_PATH
100
            )
101
        endif()
102

    
103
        if (NOT Qt5${_module_dep}_FOUND)
104
            set(Qt5Gui_FOUND False)
105
            return()
106
        endif()
107

    
108
        list(APPEND Qt5Gui_INCLUDE_DIRS "${Qt5${_module_dep}_INCLUDE_DIRS}")
109
        list(APPEND Qt5Gui_PRIVATE_INCLUDE_DIRS "${Qt5${_module_dep}_PRIVATE_INCLUDE_DIRS}")
110
        list(APPEND Qt5Gui_DEFINITIONS ${Qt5${_module_dep}_DEFINITIONS})
111
        list(APPEND Qt5Gui_COMPILE_DEFINITIONS ${Qt5${_module_dep}_COMPILE_DEFINITIONS})
112
        list(APPEND Qt5Gui_EXECUTABLE_COMPILE_FLAGS ${Qt5${_module_dep}_EXECUTABLE_COMPILE_FLAGS})
113
    endforeach()
114
    list(REMOVE_DUPLICATES Qt5Gui_INCLUDE_DIRS)
115
    list(REMOVE_DUPLICATES Qt5Gui_PRIVATE_INCLUDE_DIRS)
116
    list(REMOVE_DUPLICATES Qt5Gui_DEFINITIONS)
117
    list(REMOVE_DUPLICATES Qt5Gui_COMPILE_DEFINITIONS)
118
    list(REMOVE_DUPLICATES Qt5Gui_EXECUTABLE_COMPILE_FLAGS)
119

    
120
    set(_Qt5Gui_LIB_DEPENDENCIES "Qt5::Core")
121

    
122

    
123
    add_library(Qt5::Gui SHARED IMPORTED)
124

    
125
    set_property(TARGET Qt5::Gui PROPERTY
126
      INTERFACE_INCLUDE_DIRECTORIES ${_Qt5Gui_OWN_INCLUDE_DIRS})
127
    set_property(TARGET Qt5::Gui PROPERTY
128
      INTERFACE_COMPILE_DEFINITIONS QT_GUI_LIB)
129

    
130
    set(_Qt5Gui_PRIVATE_DIRS_EXIST TRUE)
131
    foreach (_Qt5Gui_PRIVATE_DIR ${Qt5Gui_OWN_PRIVATE_INCLUDE_DIRS})
132
        if (NOT EXISTS ${_Qt5Gui_PRIVATE_DIR})
133
            set(_Qt5Gui_PRIVATE_DIRS_EXIST FALSE)
134
        endif()
135
    endforeach()
136

    
137
    if (_Qt5Gui_PRIVATE_DIRS_EXIST
138
        AND NOT CMAKE_VERSION VERSION_LESS 3.0.0 )
139
        add_library(Qt5::GuiPrivate INTERFACE IMPORTED)
140
        set_property(TARGET Qt5::GuiPrivate PROPERTY
141
            INTERFACE_INCLUDE_DIRECTORIES ${Qt5Gui_OWN_PRIVATE_INCLUDE_DIRS}
142
        )
143
        set(_Qt5Gui_PRIVATEDEPS)
144
        foreach(dep ${_Qt5Gui_LIB_DEPENDENCIES})
145
            if (TARGET ${dep}Private)
146
                list(APPEND _Qt5Gui_PRIVATEDEPS ${dep}Private)
147
            endif()
148
        endforeach()
149
        set_property(TARGET Qt5::GuiPrivate PROPERTY
150
            INTERFACE_LINK_LIBRARIES Qt5::Gui ${_Qt5Gui_PRIVATEDEPS}
151
        )
152
    endif()
153

    
154
    _populate_Gui_target_properties(RELEASE "Qt5Gui.dll" "Qt5Gui.lib" )
155
    
156
    _populate_Gui_target_properties(RELWITHDEBINFO "Qt5Gui.dll" "Qt5Gui.lib" )
157

    
158
    _populate_Gui_target_properties(DEBUG "Qt5Guid.dll" "Qt5Guid.lib" )
159

    
160

    
161

    
162
    file(GLOB pluginTargets "${CMAKE_CURRENT_LIST_DIR}/Qt5Gui_*Plugin.cmake")
163

    
164
    macro(_populate_Gui_plugin_properties Plugin Configuration PLUGIN_LOCATION)
165
        set_property(TARGET Qt5::${Plugin} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration})
166

    
167
        set(imported_location "${_qt5Gui_install_prefix}/plugins/${PLUGIN_LOCATION}")
168
        _qt5_Gui_check_file_exists(${imported_location})
169
        set_target_properties(Qt5::${Plugin} PROPERTIES
170
            "IMPORTED_LOCATION_${Configuration}" ${imported_location}
171
        )
172
    endmacro()
173

    
174
    if (pluginTargets)
175
        foreach(pluginTarget ${pluginTargets})
176
            include(${pluginTarget})
177
        endforeach()
178
    endif()
179

    
180

    
181
    include("${CMAKE_CURRENT_LIST_DIR}/Qt5GuiConfigExtras.cmake")
182

    
183

    
184
_qt5_Gui_check_file_exists("${CMAKE_CURRENT_LIST_DIR}/Qt5GuiConfigVersion.cmake")
185

    
186
endif()
(2-2/4)