CMakeLists.txt 14.7 KB
Newer Older
1 2
SET(EXTPREFIX_qt  "${EXTPREFIX}")
if (WIN32)
3
    list(APPEND _QT_conf -skip qt3d -skip qtactiveqt -skip qtcanvas3d
4
        -skip qtconnectivity -skip qtdoc -skip qtgraphicaleffects
5
        -skip qtlocation -skip qtsensors -skip qtserialport -skip qtwayland
6
        -skip qtwebchannel -skip qtwebengine -skip qtwebsockets -skip qtwebview
7
        -skip qtxmlpatterns -no-sql-sqlite -nomake examples -nomake tools
8
        -no-compile-examples -no-dbus -no-iconv -no-qml-debug
9
        -no-libproxy -no-system-proxies -no-icu -no-mtdev
10 11
        -skip qtcharts -skip qtdatavis3d -skip qtgamepad -skip qtnetworkauth
        -skip qtpurchasing -skip qtremoteobjects -skip qtscxml -skip qtserialbus
12
        -skip qtspeech -skip qtvirtualkeyboard
13
        #
14 15 16
        -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -openssl-linked
        -I ${EXTPREFIX_qt}/include
        -L ${EXTPREFIX_qt}/lib
17
        #
18
        -opensource -confirm-license
19 20
        #
        -release -platform win32-g++ -prefix ${EXTPREFIX_qt}
21 22 23
        QMAKE_LFLAGS_APP+=${SECURITY_EXE_LINKER_FLAGS}
        QMAKE_LFLAGS_SHLIB+=${SECURITY_SHARED_LINKER_FLAGS}
        QMAKE_LFLAGS_SONAME+=${SECURITY_SHARED_LINKER_FLAGS}
24
    )
25 26 27 28
    if (QT_ENABLE_DEBUG_INFO)
        # Set the option to build Qt with debugging info enabled
        list(APPEND _QT_conf -force-debug-info)
    endif(QT_ENABLE_DEBUG_INFO)
29 30 31 32 33
    if (QT_ENABLE_DYNAMIC_OPENGL)
        list(APPEND _QT_conf -opengl dynamic -angle)
    else (QT_ENABLE_DYNAMIC_OPENGL)
        list(APPEND _QT_conf -opengl desktop -no-angle)
    endif (QT_ENABLE_DYNAMIC_OPENGL)
34

35 36
    if (NOT USE_QT_TABLET_WINDOWS)
        set(ext_qt_PATCH_COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0001-disable-wintab.patch
37 38
            COMMAND  ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/disable-winink.patch
            COMMAND  ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0002-Don-t-request-the-MIME-image-every-time-Windows-asks.patch
39 40
            COMMAND  ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0003-Hack-always-return-we-support-DIBV5.patch
            COMMAND  ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0004-Fix-debug-on-openGL-ES.patch
41
            COMMAND  ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0005-cumulative-patch-for-hdr.patch
42 43 44 45 46 47 48 49
            )
    else()
        set(ext_qt_PATCH_COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0002-Don-t-request-the-MIME-image-every-time-Windows-asks.patch
            COMMAND  ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0003-Hack-always-return-we-support-DIBV5.patch
            COMMAND  ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0004-Fix-debug-on-openGL-ES.patch
            COMMAND  ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0005-cumulative-patch-for-hdr.patch
            COMMAND  ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0020-Synthesize-Enter-LeaveEvent-for-accepted-QTabletEven.patch
            COMMAND  ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0022-Fix-generation-of-Leave-events-when-using-tablet-dev.patch
50
            COMMAND  ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0023-Implement-a-switch-for-tablet-API-on-Windows.patch
51
            COMMAND  ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0024-Fetch-stylus-button-remapping-from-WinTab-driver.patch
52
            COMMAND  ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0025-Disable-tablet-relative-mode-in-Qt.patch
53
            COMMAND  ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0026-Fetch-mapped-screen-size-from-the-Wintab-driver.patch
54
            COMMAND  ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0027-Switch-stylus-pointer-type-when-the-tablet-is-in-the.patch
55
#            COMMAND  ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0050-Fix-using-tablet-on-QML-widgets.patch
56
            COMMAND  ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0051-Add-workaround-for-handling-table-press-correctly-in.patch
57 58
            )
    endif()
59 60 61
    set(ext_qt_PATCH_COMMAND ${ext_qt_PATCH_COMMAND}
        COMMAND  ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/set-has-border-in-full-screen-default.patch
        COMMAND  ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/remove-fullscreen-border-hack.patch
62
        COMMAND  ${PATCH_COMMAND} -p1 -d qttools -i ${CMAKE_CURRENT_SOURCE_DIR}/windeployqt-force-allow-debug-info.patch
63 64 65 66 67
#        COMMAND  ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0031-Compute-logical-DPI-on-a-per-screen-basis.patch
#        COMMAND  ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0032-Update-Dpi-and-scale-factor-computation.patch
#        COMMAND  ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0033-Move-QT_FONT_DPI-to-cross-platform-code.patch
#        COMMAND  ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0034-Update-QT_SCREEN_SCALE_FACTORS.patch
#        COMMAND  ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0035-Deprecate-QT_AUTO_SCREEN_SCALE_FACTOR.patch
68
#        COMMAND  ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0036-Add-high-DPI-scale-factor-rounding-policy-C-API.patch                
69
    )
70 71 72 73

  ExternalProject_Add(
      ext_qt
      DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
Boudewijn Rempt's avatar
Boudewijn Rempt committed
74 75
      URL https://download.qt.io/archive/qt/5.12/5.12.3/single/qt-everywhere-src-5.12.3.tar.xz
      URL_MD5 38017e0ed88b9baba063bd723d9ca8b2
76 77

      PATCH_COMMAND ${ext_qt_PATCH_COMMAND}
78 79

      INSTALL_DIR ${EXTPREFIX_qt}
80
      CONFIGURE_COMMAND <SOURCE_DIR>/configure.bat ${_QT_conf}
81

82 83
      BUILD_COMMAND mingw32-make -j${SUBMAKE_JOBS}
      INSTALL_COMMAND mingw32-make -j${SUBMAKE_JOBS} install
84
      UPDATE_COMMAND ""
85 86 87
      # Use a short name to reduce the chance of exceeding path length limit
      SOURCE_DIR s
      BINARY_DIR b
88
      DEPENDS ext_patch ext_openssl
89 90 91 92 93
  )
elseif (NOT APPLE)
  ExternalProject_Add(
      ext_qt
      DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
Boudewijn Rempt's avatar
Boudewijn Rempt committed
94 95
      URL https://download.qt.io/archive/qt/5.12/5.12.3/single/qt-everywhere-src-5.12.3.tar.xz
      URL_MD5 38017e0ed88b9baba063bd723d9ca8b2
96

97 98
      PATCH_COMMAND  ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0010-Fix-tablet-jitter-on-X11.patch
            COMMAND  ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0011-Add-an-ID-for-recognition-of-UGEE-tablets.patch
99
            COMMAND  ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0012-Synthesize-Enter-LeaveEvent-for-accepted-QTabletEven.patch
100
            COMMAND  ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0013-Poison-Qt-s-headers-with-a-mark-about-presence-of-En.patch
101

102 103 104
      CMAKE_ARGS -DOPENSSL_LIBS='-L${EXTPREFIX_qt}/lib -lssl -lcrypto'

      CONFIGURE_COMMAND <SOURCE_DIR>/configure -prefix ${EXTPREFIX_qt} -opensource -confirm-license -openssl-linked -verbose -nomake examples -skip qt3d -skip qtactiveqt -skip qtcanvas3d -skip qtconnectivity -skip qtgraphicaleffects -skip qtlocation -skip qtwayland -skip qtwebchannel -skip qtwebengine -skip qtwebsockets -skip qtwebview -skip qtandroidextras -skip qtserialport -skip qtdatavis3d -skip qtvirtualkeyboard -skip qtspeech -skip qtsensors -skip qtgamepad -skip qtscxml -skip qtremoteobjects -skip qtxmlpatterns -skip qtnetworkauth  -skip qtcharts -skip qtdatavis3d -skip qtgamepad -skip qtpurchasing -skip qtscxml -skip qtserialbus -skip qtspeech -skip qtvirtualkeyboard -skip qtmultimedia
105 106
      INSTALL_DIR ${EXTPREFIX_qt}

107 108
      BUILD_COMMAND $(MAKE)
      INSTALL_COMMAND $(MAKE) install
109 110 111 112 113 114 115 116 117 118 119 120 121 122
      UPDATE_COMMAND ""
      BUILD_IN_SOURCE 1
  )
else( APPLE )

      # XCODE_VERSION is set by CMake when using the Xcode generator, otherwise we need
      # to detect it manually here.
      if (NOT XCODE_VERSION)
        execute_process(
          COMMAND xcodebuild -version
          OUTPUT_VARIABLE xcodebuild_version
          OUTPUT_STRIP_TRAILING_WHITESPACE
          ERROR_FILE /dev/null
        )
123
        string(REGEX MATCH "Xcode ([0-9]+([.][0-9]+)*)" version_match ${xcodebuild_version})
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
        if (version_match)
          message(STATUS "${EXTPREFIX_qt}:Identified Xcode Version: ${CMAKE_MATCH_1}")
          set(XCODE_VERSION ${CMAKE_MATCH_1})
        else()
          # If detecting Xcode version failed, set a crazy high version so we default
          # to the newest.
          set(XCODE_VERSION 99)
          message(WARNING "${EXTPREFIX_qt}:Failed to detect the version of an installed copy of Xcode, falling back to highest supported version. Set XCODE_VERSION to override.")
        endif(version_match)
      endif(NOT XCODE_VERSION)

      # -------------------------------------------------------------------------------
      # Verify the Xcode installation on Mac OS like Qt5.7 does/will
      # If not stop now, the system isn't configured correctly for Qt.
      # No reason to even proceed.
      # -------------------------------------------------------------------------------
      set(XCSELECT_OUTPUT)
      find_program(XCSELECT_PROGRAM "xcode-select")
      if(XCSELECT_PROGRAM)
        message(STATUS "${EXTPREFIX_qt}:Found XCSELECT_PROGRAM as ${XCSELECT_PROGRAM}")
        set(XCSELECT_COMMAND ${XCSELECT_PROGRAM}
          "--print-path")
        execute_process(
          COMMAND ${XCSELECT_COMMAND}
          RESULT_VARIABLE XCSELECT_COMMAND_RESULT
          OUTPUT_VARIABLE XCSELECT_COMMAND_OUTPUT
          ERROR_FILE /dev/null
        )
        if(NOT XCSELECT_COMMAND_RESULT)
          # returned 0, we're ok.
          string(REGEX REPLACE
            "[ \t]*[\r\n]+[ \t]*" ";"
            XCSELECT_COMMAND_OUTPUT ${XCSELECT_COMMAND_OUTPUT})
        else()
          string(REPLACE ";" " " XCSELECT_COMMAND_STR "${XCSELECT_COMMAND}")
          # message(STATUS "${XCSELECT_COMMAND_STR}")
          message(FATAL_ERROR "${EXTPREFIX_qt}:${XCSELECT_PROGRAM} test failed with status ${XCSELECT_COMMAND_RESULT}")
        endif()
      else()
        message(FATAL_ERROR "${EXTPREFIX_qt}:${XCSELECT_PROGRAM} not found. No Xcode is selected. Use xcode-select -switch to choose an Xcode version")
      endif()

      # Belts and suspenders
      # Beyond all the Xcode and Qt version checking, the proof of the pudding
      # lies in the success/failure of this command: xcrun --find xcrun.
      # On failure a patch is necessary, otherwise we're ok
      # So hard check xcrun now...
      set(XCRUN_OUTPUT)
      find_program(XCRUN_PROGRAM "xcrun")
      if(XCRUN_PROGRAM)
        message(STATUS "${EXTPREFIX_qt}:Found XCRUN_PROGRAM as ${XCRUN_PROGRAM}")
        set(XCRUN_COMMAND ${XCRUN_PROGRAM}
          "--find xcrun")
        execute_process(
          COMMAND ${XCRUN_COMMAND}
          RESULT_VARIABLE XCRUN_COMMAND_RESULT
          OUTPUT_VARIABLE XCRUN_COMMAND_OUTPUT
          ERROR_FILE /dev/null
        )
        if(NOT XCRUN_COMMAND_RESULT)
          # returned 0, we're ok.
          string(REGEX REPLACE
            "[ \t]*[\r\n]+[ \t]*" ";"
            XCRUN_COMMAND_OUTPUT ${XCRUN_COMMAND_OUTPUT})
        else()
          string(REPLACE ";" " " XCRUN_COMMAND_STR "${XCRUN_COMMAND}")
          # message(STATUS "${XCRUN_COMMAND_STR}")
          message(STATUS "${EXTPREFIX_qt}:xcrun test failed with status ${XCRUN_COMMAND_RESULT}")
        endif()
      else()
        message(STATUS "${EXTPREFIX_qt}:xcrun not found -- ${XCRUN_PROGRAM}")
      endif()
      #
      # Now configure ext_qt accordingly
      #
199 200 201 202
      if ((XCRUN_COMMAND_RESULT) AND (NOT (XCODE_VERSION VERSION_LESS 8.0.0)))
        # Fix Xcode xcrun related issue.
        # NOTE: This should be fixed by Qt 5.7.1 see here: http://code.qt.io/cgit/qt/qtbase.git/commit/?h=dev&id=77a71c32c9d19b87f79b208929e71282e8d8b5d9
        # NOTE: but no one's holding their breath.
Boudewijn Rempt's avatar
Boudewijn Rempt committed
203
        set(ext_qt_PATCH_COMMAND ${PATCH_COMMAND}} -p1 -b -d <SOURCE_DIR>/qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/mac_standardpaths_qtbug-61159.diff
204
                COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0012-Synthesize-Enter-LeaveEvent-for-accepted-QTabletEven.patch
205 206
                COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0013-Poison-Qt-s-headers-with-a-mark-about-presence-of-En.patch

207 208 209 210 211 212 213
                #COMMAND ${PATCH_COMMAND} -p1 -b -d <SOURCE_DIR>/qtbase/mkspecs/features/mac -i ${CMAKE_CURRENT_SOURCE_DIR}/mac-default.patch
            )
        message(STATUS "${EXTPREFIX_qt}:Additional patches injected.")
      else()
        # No extra patches will be applied
        # NOTE: defaults for some untested scenarios like xcrun fails and xcode_version < 8.
        # NOTE: that is uncharted territory and (hopefully) a very unlikely scenario...
214
        set(ext_qt_PATCH_COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0012-Synthesize-Enter-LeaveEvent-for-accepted-QTabletEven.patch
215
            )
216
      endif()
217 218 219 220 221 222 223

      # Qt is big - try and parallelize if at all possible
      include(ProcessorCount)
      ProcessorCount(NUM_CORES)
      if(NOT NUM_CORES EQUAL 0)
        if (NUM_CORES GREATER 2)
          # be nice...
224
          MATH( EXPR NUM_CORES "${NUM_CORES} - 2" )
225 226 227 228 229 230 231
        endif()
        set(PARALLEL_MAKE "make;-j${NUM_CORES}")
        message(STATUS "${EXTPREFIX_qt}:Parallelized make: ${PARALLEL_MAKE}")
      else()
        set(PARALLEL_MAKE "make")
      endif()

232

233 234
      ExternalProject_Add(
        ext_qt
235
        DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
236 237 238 239 240 241 242

        LOG_DOWNLOAD        ON
        LOG_UPDATE          ON
        LOG_CONFIGURE       ON
        LOG_BUILD           ON
        LOG_TEST            ON
        LOG_INSTALL         ON
243
        BUILD_IN_SOURCE     ON
244

Boudewijn Rempt's avatar
Boudewijn Rempt committed
245 246
       URL https://download.qt.io/archive/qt/5.12/5.12.3/single/qt-everywhere-src-5.12.3.tar.xz
       URL_MD5 38017e0ed88b9baba063bd723d9ca8b2
247

248 249
        CMAKE_ARGS -DOPENSSL_LIBS='-L${EXTPREFIX_qt}/lib -lssl -lcrypto'

250
        INSTALL_DIR ${EXTPREFIX_qt}
251
        CONFIGURE_COMMAND <SOURCE_DIR>/configure
252
        -skip qt3d -skip qtactiveqt -skip qtcanvas3d -skip qtconnectivity -skip qtdoc -skip qtgraphicaleffects -skip qtlocation -skip qtsensors -skip qtserialport -skip qtwayland
253 254 255 256
            -skip qtwebchannel -skip qtwebsockets -skip qtwebview -skip qtwebengine -skip qtxmlpatterns -no-sql-sqlite -skip qtcharts -skip qtdatavis3d  -skip qtgamepad -skip qtnetworkauth
            -skip qtpurchasing -skip qtremoteobjects -skip qtscxml -skip qtserialbus -skip qtspeech -skip qtvirtualkeyboard -nomake examples -nomake tools -no-compile-examples
            -no-dbus -no-iconv -no-qml-debug -no-libproxy -no-system-proxies -no-icu -no-mtdev -system-zlib -qt-pcre
            -opensource -confirm-license  -openssl-linked -prefix ${EXTPREFIX_qt}
257
        BUILD_COMMAND ${PARALLEL_MAKE}
258 259 260
        INSTALL_COMMAND make install
        UPDATE_COMMAND ""
        BUILD_IN_SOURCE 1
261
      )
Boudewijn Rempt's avatar
Boudewijn Rempt committed
262
endif()