CMakeLists.txt 14.9 KB
Newer Older
1 2
SET(EXTPREFIX_qt  "${EXTPREFIX}")
if (WIN32)
Alvin Wong's avatar
Alvin Wong committed
3
    list(APPEND _QT_conf -skip qt3d -skip qtactiveqt -skip qtcanvas3d
Dmitry Kazakov's avatar
Dmitry Kazakov committed
4
        -skip qtconnectivity -skip qtdoc -skip qtgraphicaleffects
Alvin Wong's avatar
Alvin Wong committed
5
        -skip qtlocation -skip qtsensors -skip qtserialport -skip qtwayland
6
        -skip qtwebchannel -skip qtwebengine -skip qtwebsockets -skip qtwebview
Alvin Wong's avatar
Alvin Wong committed
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
Alvin Wong's avatar
Alvin Wong committed
10 11
        -skip qtcharts -skip qtdatavis3d -skip qtgamepad -skip qtnetworkauth
        -skip qtpurchasing -skip qtremoteobjects -skip qtscxml -skip qtserialbus
12
        -skip qtspeech -skip qtvirtualkeyboard
Alvin Wong's avatar
Alvin Wong committed
13
        #
14 15 16
        -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -openssl-linked
        -I ${EXTPREFIX_qt}/include
        -L ${EXTPREFIX_qt}/lib
Alvin Wong's avatar
Alvin Wong committed
17
        #
18
        -opensource -confirm-license
Alvin Wong's avatar
Alvin Wong committed
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}
Alvin Wong's avatar
Alvin Wong committed
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}/0028-Fix-updating-tablet-pressure-resolution-on-every-pro.patch 
56
            COMMAND  ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0050-Fix-using-tablet-on-QML-widgets.patch
57
            COMMAND  ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0051-Add-workaround-for-handling-table-press-correctly-in.patch
58 59
            )
    endif()
60 61 62
    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
63
        COMMAND  ${PATCH_COMMAND} -p1 -d qttools -i ${CMAKE_CURRENT_SOURCE_DIR}/windeployqt-force-allow-debug-info.patch
64
        COMMAND  ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0030-Windows-QPA-Make-the-expected-screen-be-in-sync-with.patch
65 66 67 68 69 70
        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
        COMMAND  ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0036-Add-high-DPI-scale-factor-rounding-policy-C-API.patch
71
    )
72 73 74 75

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

      PATCH_COMMAND ${ext_qt_PATCH_COMMAND}
80 81

      INSTALL_DIR ${EXTPREFIX_qt}
Alvin Wong's avatar
Alvin Wong committed
82
      CONFIGURE_COMMAND <SOURCE_DIR>/configure.bat ${_QT_conf}
83

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

99 100
      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
101
            COMMAND  ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0012-Synthesize-Enter-LeaveEvent-for-accepted-QTabletEven.patch
102
            COMMAND  ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0013-Poison-Qt-s-headers-with-a-mark-about-presence-of-En.patch
103

104 105 106
      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
107 108
      INSTALL_DIR ${EXTPREFIX_qt}

109 110
      BUILD_COMMAND $(MAKE)
      INSTALL_COMMAND $(MAKE) install
111 112 113 114 115 116 117 118 119 120 121 122 123 124
      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
        )
125
        string(REGEX MATCH "Xcode ([0-9]+([.][0-9]+)*)" version_match ${xcodebuild_version})
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 199 200
        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
      #
201 202 203 204
      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
205
        set(ext_qt_PATCH_COMMAND ${PATCH_COMMAND}} -p1 -b -d <SOURCE_DIR>/qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/mac_standardpaths_qtbug-61159.diff
206
                COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0012-Synthesize-Enter-LeaveEvent-for-accepted-QTabletEven.patch
207 208
                COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0013-Poison-Qt-s-headers-with-a-mark-about-presence-of-En.patch

209 210 211 212 213 214 215
                #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...
216
        set(ext_qt_PATCH_COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0012-Synthesize-Enter-LeaveEvent-for-accepted-QTabletEven.patch
217
            )
218
      endif()
219 220 221 222 223 224 225

      # 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...
226
          MATH( EXPR NUM_CORES "${NUM_CORES} - 2" )
227 228 229 230 231 232 233
        endif()
        set(PARALLEL_MAKE "make;-j${NUM_CORES}")
        message(STATUS "${EXTPREFIX_qt}:Parallelized make: ${PARALLEL_MAKE}")
      else()
        set(PARALLEL_MAKE "make")
      endif()

234

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

        LOG_DOWNLOAD        ON
        LOG_UPDATE          ON
        LOG_CONFIGURE       ON
        LOG_BUILD           ON
        LOG_TEST            ON
        LOG_INSTALL         ON
Boudewijn Rempt's avatar
Boudewijn Rempt committed
245
        BUILD_IN_SOURCE     ON
246

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

250 251
        CMAKE_ARGS -DOPENSSL_LIBS='-L${EXTPREFIX_qt}/lib -lssl -lcrypto'

252
        INSTALL_DIR ${EXTPREFIX_qt}
253
        CONFIGURE_COMMAND <SOURCE_DIR>/configure
Dmitry Kazakov's avatar
Dmitry Kazakov committed
254
        -skip qt3d -skip qtactiveqt -skip qtcanvas3d -skip qtconnectivity -skip qtdoc -skip qtgraphicaleffects -skip qtlocation -skip qtsensors -skip qtserialport -skip qtwayland
255 256 257 258
            -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}
259
        BUILD_COMMAND ${PARALLEL_MAKE}
260 261 262
        INSTALL_COMMAND make install
        UPDATE_COMMAND ""
        BUILD_IN_SOURCE 1
263
      )
Boudewijn Rempt's avatar
Boudewijn Rempt committed
264
endif()