External_qt5.cmake 4.65 KB
Newer Older
1
#
Julien Michel's avatar
Julien Michel committed
2
# Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
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
#
# This file is part of Orfeo Toolbox
#
#     https://www.orfeo-toolbox.org/
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

INCLUDE_ONCE_MACRO(QT5)

SETUP_SUPERBUILD(QT5)

#NOTE: make sure your superbuild install directory does not contain any
#Qt files from previous install of superbuild QT.
# declare dependencies
28
ADDTO_DEPENDENCIES_IF_NOT_SYSTEM(QT5 ZLIB PNG JPEG FREETYPE)
29

30
#use system libs always for Qt5 as we build them from source or have already in system
31

32 33 34 35 36 37
if(SB_INSTALL_PREFIX)
  file(TO_NATIVE_PATH ${SB_INSTALL_PREFIX} QT5_INSTALL_PREFIX_NATIVE)
  file(TO_NATIVE_PATH ${SB_INSTALL_PREFIX}/include QT5_INCLUDE_PREFIX_NATIVE)
  file(TO_NATIVE_PATH ${SB_INSTALL_PREFIX}/lib QT5_LIB_PREFIX_NATIVE)
  file(TO_NATIVE_PATH ${SB_INSTALL_PREFIX}/include/freetype2 QT5_INCLUDE_FREETYPE_NATIVE)
endif()
38

39 40
file(TO_NATIVE_PATH ${QT5_SB_SRC} QT5_SB_SRC_NATIVE)

41 42 43 44 45 46
if(WIN32)
  set(QT5_SB_OPENGL_CONFIG "-opengl desktop")
else()
  set(QT5_SB_OPENGL_CONFIG "")
endif()

47
#Common options for all cases
48 49
# -skip qtbase
# -skip qttools  (need linguist)
50
# -skip qttranslations
51
set(QT5_SB_CONFIG
52 53
  "-prefix ${QT5_INSTALL_PREFIX_NATIVE} -L ${QT5_LIB_PREFIX_NATIVE} \
  -I ${QT5_INCLUDE_PREFIX_NATIVE} -I ${QT5_INCLUDE_FREETYPE_NATIVE} \
54
  -opensource -confirm-license -release -shared \
55
  -nomake examples -make tools -no-openssl \
56
  ${QT5_SB_OPENGL_CONFIG} \
57 58 59
  -skip qtgamepad  \
  -skip qt3d  \
  -skip qtactiveqt  \
60
  -skip qtandroidextras \
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
  -skip qtcanvas3d  \
  -skip qtcharts  \
  -skip qtconnectivity  \
  -skip qtdatavis3d  \
  -skip qtdeclarative  \
  -skip qtdoc  \
  -skip qtgamepad  \
  -skip qtgraphicaleffects  \
  -skip qtimageformats  \
  -skip qtlocation  \
  -skip qtmacextras  \
  -skip qtmultimedia  \
  -skip qtnetworkauth \
  -skip qtpurchasing  \
  -skip qtquickcontrols  \
  -skip qtquickcontrols2  \
  -skip qtremoteobjects  \
  -skip qtscript  \
  -skip qtsensors  \
  -skip qtserialbus  \
  -skip qtserialport  \
82
  -skip qtspeech \
83 84 85 86 87 88 89 90 91 92 93
  -skip qtsvg  \
  -skip qtvirtualkeyboard  \
  -skip qtwayland  \
  -skip qtwebchannel  \
  -skip qtwebengine  \
  -skip qtwebglplugin  \
  -skip qtwebsockets  \
  -skip qtwebview  \
  -skip qtwinextras  \
  -skip qtx11extras  \
  -skip qtxmlpatterns \
94
  -system-libpng -system-libjpeg -system-zlib -system-freetype -qt-harfbuzz")
95

96 97 98
if(UNIX)
  if(APPLE)
    set(QT5_SB_CONFIG "${QT5_SB_CONFIG} -no-framework")
99 100
  else()
      #Linux
101
      set(QT5_SB_CONFIG "${QT5_SB_CONFIG} -no-glib -no-fontconfig")
102 103
  endif()
  #common for all unix
104
  set(QT5_SB_CONFIG "${QT5_SB_CONFIG} -no-dbus -no-icu -v")
105 106 107
elseif(MSVC)
  set(QT5_SB_CONFIG "${QT5_SB_CONFIG} -mp")
endif()
108

109 110 111 112 113 114 115 116 117 118 119
if(WIN32)
  set(QT5_BIN_EXT ".exe")
  file(TO_NATIVE_PATH ${QT5_SB_SRC}/configure.bat QT5_CONFIGURE_SCRIPT)
  set(QT5_CONFIGURE_COMMAND ${CMAKE_BINARY_DIR}/configure_qt5.bat)
  set(QT5_CONFIGURE_COMMAND_IN ${CMAKE_SOURCE_DIR}/patches/QT5/configure_qt5.bat.in)
else()
  set(QT5_BIN_EXT "")
  file(TO_NATIVE_PATH ${QT5_SB_SRC}/configure QT5_CONFIGURE_SCRIPT)
  set(QT5_CONFIGURE_COMMAND ${CMAKE_BINARY_DIR}/configure_qt5.sh)
  set(QT5_CONFIGURE_COMMAND_IN ${CMAKE_SOURCE_DIR}/patches/QT5/configure_qt5.sh.in)
endif()
120

121 122 123
if(EXISTS "${QT5_CONFIGURE_COMMAND}")
  execute_process(COMMAND ${CMAKE_COMMAND} -E remove -f "${QT5_CONFIGURE_COMMAND}")
endif()
124

125
configure_file( ${QT5_CONFIGURE_COMMAND_IN} ${QT5_CONFIGURE_COMMAND} @ONLY )
126

127 128
ExternalProject_Add(QT5
  PREFIX QT5
129 130
  URL "http://download.qt.io/official_releases/qt/5.10/5.10.1/single/qt-everywhere-src-5.10.1.tar.xz"
  URL_MD5 7e167b9617e7bd64012daaacb85477af
131 132 133 134 135 136 137 138 139 140
  BINARY_DIR ${QT5_SB_BUILD_DIR}
  INSTALL_DIR ${SB_INSTALL_PREFIX}
  DOWNLOAD_DIR ${DOWNLOAD_LOCATION}
  CONFIGURE_COMMAND ${QT5_CONFIGURE_COMMAND}
  DEPENDS ${QT5_DEPENDENCIES}
  LOG_DOWNLOAD 1
  LOG_CONFIGURE 1
  LOG_BUILD 1
  LOG_INSTALL 1
  )
141 142 143 144

SUPERBUILD_PATCH_SOURCE(QT5)

set(_SB_QT_QMAKE_EXECUTABLE ${SB_INSTALL_PREFIX}/bin/qmake)
145 146 147

if(UNIX AND NOT APPLE)
  ExternalProject_Add_Step(QT5 adding_font
148 149 150 151 152
  COMMAND ${CMAKE_COMMAND}
  -D BUILD_DIR=${QT5_SB_BUILD_DIR}
  -D INSTALL_DIR=${SB_INSTALL_PREFIX}
  -D DOWNLOAD_LOCATION=${DOWNLOAD_LOCATION}
  -P ${CMAKE_SOURCE_DIR}/CMake/External_font.cmake
153 154 155
  DEPENDEES install
  WORKING_DIRECTORY ${SB_INSTALL_PREFIX} )
endif()