File: qt-configuration.cmake

package info (click to toggle)
qt-color-widgets 2.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 916 kB
  • sloc: cpp: 6,923; sh: 236; makefile: 13
file content (58 lines) | stat: -rw-r--r-- 1,874 bytes parent folder | download
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
function (select_qt
    QT_SUPPORTED_VERSIONS i_qt_supported_versions
    QT_DEFAULT_VERSION i_default_qt_version)
  set (QT_VERSION ${i_default_qt_version} CACHE STRING
    "Qt version to build against")

  set_property (
    CACHE QT_VERSION
    PROPERTY STRINGS ${i_qt_supported_versions})
endfunction (select_qt)


macro (find_qt
    QT_SUPPORTED_VERSIONS i_qt_supported_versions
    REQUIRED_COMPONENTS i_required_components
    OPTIONAL_COMPONENTS i_optional_components)
  # Auto generate moc files
  if (4 EQUAL QT_VERSION)
    find_package (Qt4 4.8 REQUIRED
      COMPONENTS
      ${i_required_components}
      OPTIONAL_COMPONENTS
      ${i_optional_components})
  elseif (5 EQUAL QT_VERSION)
    find_package (Qt5 5.9 REQUIRED
      COMPONENTS
      ${i_required_components}
      OPTIONAL_COMPONENTS
      ${i_optional_components})
  else (5 EQUAL QT_VERSION)
    message (FATAL_ERROR "Unsupported version of Qt: ${QT_VERSION}")
  endif (4 EQUAL QT_VERSION)
endmacro (find_qt)


function (use_qt
    TARGET_NAME i_target_name
    QT_SUPPORTED_VERSIONS i_qt_supported_versions
    REQUIRED_COMPONENTS i_required_components
    OPTIONAL_COMPONENTS i_optional_components)
  if (4 EQUAL QT_VERSION)
    foreach (COMPONENT IN LISTS i_required_components, i_optional_components)
      target_link_libraries (${i_target_name}
        PRIVATE
        Qt4::${COMPONENT}
        )
    endforeach (COMPONENT IN LISTS i_required_components, i_optional_components)
  elseif (5 EQUAL QT_VERSION)
    foreach (COMPONENT IN LISTS i_required_components)
      target_link_libraries (${i_target_name}
        PRIVATE
        Qt5::${COMPONENT}
        )
    endforeach (COMPONENT IN LISTS i_required_components, i_optional_components)
  else (5 EQUAL QT_VERSION)
    message (FATAL_ERROR "Unsupported version of Qt: ${QT_VERSION}")
  endif (4 EQUAL QT_VERSION)
endfunction (use_qt)