FreeCAD

Форк
0
/
ChooseQtVersion.cmake 
88 строк · 3.8 Кб
1
# ADAPTED FOR FREECAD FROM VTK'S vtkQt.cmake
2
# ORIGINAL VTK COPYRIGHT NOTICE FOLLOWS (BSD 3-CLAUSE)
3
#
4
# /*=========================================================================
5
#
6
#   Program:   Visualization Toolkit
7
#   Module:    Copyright.txt
8
#
9
# Copyright (c) 1993-2015 Ken Martin, Will Schroeder, Bill Lorensen
10
# All rights reserved.
11
#
12
# Redistribution and use in source and binary forms, with or without
13
# modification, are permitted provided that the following conditions are met:
14
#
15
#  * Redistributions of source code must retain the above copyright notice,
16
#    this list of conditions and the following disclaimer.
17
#
18
#  * Redistributions in binary form must reproduce the above copyright notice,
19
#    this list of conditions and the following disclaimer in the documentation
20
#    and/or other materials provided with the distribution.
21
#
22
#  * Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names
23
#    of any contributors may be used to endorse or promote products derived
24
#    from this software without specific prior written permission.
25
#
26
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
27
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
30
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
34
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
#
37
# =========================================================================*/
38

39

40
# FREECAD_QT_VERSION is used to choose between Qt5 and Qt6.
41

42
# If it is set to Auto(default), FreeCAD finds and uses the
43
# version installed on the system. If both versions are
44
# found, Qt5 is preferred.
45

46
# The output variable is FREECAD_QT_MAJOR_VERSION, which will be either 5 or 6
47

48
macro(ChooseQtVersion)
49
  set(freecad_supported_qt_versions "Auto" 5 6)
50

51
  # The following `if` check can be removed once CMake 3.21 is required and
52
  # the policy CMP0126 is set to NEW.
53
  if (NOT DEFINED FREECAD_QT_VERSION)
54
    set(FREECAD_QT_VERSION "Auto" CACHE
55
      STRING "Expected Qt major version. Valid values are Auto, 5, 6.")
56
    set_property(CACHE FREECAD_QT_VERSION PROPERTY STRINGS "${freecad_supported_qt_versions}")
57
  endif()
58

59
  if(FREECAD_LIBPACK_USE)
60
    if (NOT Qt5_DIR OR Qt5_DIR STREQUAL "Qt5_DIR-NOTFOUND")
61
        message(STATUS "Using Qt5 directory from LibPack in ${FREECAD_LIBPACK_DIR}/lib/cmake/Qt5")
62
        set(Qt5_DIR ${FREECAD_LIBPACK_DIR}/lib/cmake/Qt5)
63
    endif()
64
  endif()
65

66
  if (NOT FREECAD_QT_VERSION STREQUAL "Auto")
67
    if (NOT FREECAD_QT_VERSION IN_LIST freecad_supported_qt_versions)
68
      message(FATAL_ERROR
69
        "Supported Qt versions are \"${freecad_supported_qt_versions}\". But "
70
        "FREECAD_QT_VERSION is set to ${FREECAD_QT_VERSION}.")
71
    endif ()
72
    set(_FREECAD_QT_VERSION "${FREECAD_QT_VERSION}")
73
  else ()
74
    find_package(Qt5 QUIET COMPONENTS Core)
75
    set(_FREECAD_QT_VERSION 5)
76
    if (NOT Qt5_FOUND)
77
      find_package(Qt6 QUIET COMPONENTS Core)
78
      if (NOT Qt6_FOUND)
79
        message(FATAL_ERROR
80
          "Could not find a valid Qt installation. Consider setting Qt5_DIR or Qt6_DIR (as needed).")
81
      endif ()
82
      set(_FREECAD_QT_VERSION 6)
83
    endif ()
84
  endif ()
85
  set(FREECAD_QT_MAJOR_VERSION "${_FREECAD_QT_VERSION}" CACHE INTERNAL
86
    "Major version number for the Qt installation used.")
87
  message(STATUS  "Compiling with Qt ${FREECAD_QT_MAJOR_VERSION}")
88
endmacro()

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.