External_qt4.cmake 4.97 KB
Newer Older
1
INCLUDE_ONCE_MACRO(QT4)
2

3
SETUP_SUPERBUILD(QT4)
4 5 6 7 8 9 10 11

#RK: are we ready for QT4 build on linux?.
#This comment here scares me away.
#Installing QT4 from packages also need sqlite otherwise there is issue

# if(UNIX AND NOT APPLE)
#   message(STATUS "  SuperBuild may fail to compile Qt4. If so, you should install it via package manager.")
# endif()
Rashad Kanavath's avatar
Rashad Kanavath committed
12

13 14 15
if(NOT DEFINED git_protocol)
  set(git_protocol "git")
endif()
Rashad Kanavath's avatar
Rashad Kanavath committed
16

17 18 19
#NOTE: make sure your superbuild install directory does not contain any
#Qt files from previous install of superbuild QT.
# declare dependencies
20
ADDTO_DEPENDENCIES_IF_NOT_SYSTEM(QT4 ZLIB PNG JPEG SQLITE FREETYPE)
Rashad Kanavath's avatar
Rashad Kanavath committed
21

22 23 24 25 26 27
#use system libs always for Qt4 as we build them from source or have already in system
set(QT4_SB_CONFIG)
#RK: building faling on mac. png include is in a macframework
if(USE_SYSTEM_PNG)
  set(QT4_SB_CONFIG "-I ${PNG_PNG_INCLUDE_DIR}")
endif()
28

29 30 31 32
if(UNIX)
  if(APPLE)
    set(QT4_SB_CONFIG "${QT4_SB_CONFIG} -no-framework")
  else() #Linux
33
    set(QT4_SB_CONFIG "${QT4_SB_CONFIG} -sm -xrender -xrandr -gtkstyle")
34
  endif()
35 36 37
  set(QT4_SB_CONFIG "${QT4_SB_CONFIG} -no-nis -no-javascript-jit -v")
elseif(MSVC)
  set(QT4_SB_CONFIG "${QT4_SB_CONFIG} -mp")
38
endif()
39

40 41 42 43 44
if(USE_SYSTEM_FREETYPE)
  set(FT_INCLUDE ${FREETYPE_INCLUDE_DIRS})
else()
  set(FT_INCLUDE ${_SB_FREETYPE_INCLUDE_DIRS})
endif()
Rashad Kanavath's avatar
Rashad Kanavath committed
45

46 47 48 49 50 51 52 53 54
if(FT_INCLUDE)
  file(TO_NATIVE_PATH ${FT_INCLUDE} FT_INCLUDE_NATIVE)
endif()

if(SB_INSTALL_PREFIX)
  file(TO_NATIVE_PATH ${SB_INSTALL_PREFIX} QT4_INSTALL_PREFIX_NATIVE)
  file(TO_NATIVE_PATH ${SB_INSTALL_PREFIX}/include QT4_INCLUDE_PREFIX_NATIVE)
  file(TO_NATIVE_PATH ${SB_INSTALL_PREFIX}/lib QT4_LIB_PREFIX_NATIVE)
endif()
55

56 57 58
if(WIN32)
  set(QT4_BIN_EXT ".exe")
  file(TO_NATIVE_PATH ${QT4_SB_SRC}/configure.exe QT4_CONFIGURE_SCRIPT)
59
  set(QT4_CONFIGURE_COMMAND ${CMAKE_BINARY_DIR}/configure_qt4.bat)
60
  set(QT4_CONFIGURE_COMMAND_IN ${CMAKE_SOURCE_DIR}/patches/QT4/configure_qt4.bat.in)
61
else()
62 63
  set(QT4_BIN_EXT "")
  file(TO_NATIVE_PATH ${QT4_SB_SRC}/configure QT4_CONFIGURE_SCRIPT)
64
  set(QT4_CONFIGURE_COMMAND ${CMAKE_BINARY_DIR}/configure_qt4.sh)
65
  set(QT4_CONFIGURE_COMMAND_IN ${CMAKE_SOURCE_DIR}/patches/QT4/configure_qt4.sh.in)
66
endif()
Rashad Kanavath's avatar
Rashad Kanavath committed
67

68
configure_file(${QT4_CONFIGURE_COMMAND_IN} ${QT4_CONFIGURE_COMMAND} @ONLY )
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87

#Remove left over or previous installation from install prefix.
#Existing files in install prefix was disturbing a second installation.
#even afer the QT4 directory is removed from build

add_custom_target(QT4-uninstall
  COMMAND ${CMAKE_COMMAND} -E remove_directory "${SB_INSTALL_PREFIX}/include/QtCore"
  COMMAND ${CMAKE_COMMAND} -E remove_directory "${SB_INSTALL_PREFIX}/include/QtDBus"
  COMMAND ${CMAKE_COMMAND} -E remove_directory "${SB_INSTALL_PREFIX}/include/QtGui"
  COMMAND ${CMAKE_COMMAND} -E remove_directory "${SB_INSTALL_PREFIX}/include/QtNetwork"
  COMMAND ${CMAKE_COMMAND} -E remove_directory "${SB_INSTALL_PREFIX}/include/QtOpenGL"
  COMMAND ${CMAKE_COMMAND} -E remove_directory "${SB_INSTALL_PREFIX}/include/QtSql"
  COMMAND ${CMAKE_COMMAND} -E remove_directory "${SB_INSTALL_PREFIX}/include/QtSvg"
  COMMAND ${CMAKE_COMMAND} -E remove_directory "${SB_INSTALL_PREFIX}/include/QtTest"
  COMMAND ${CMAKE_COMMAND} -E remove_directory "${SB_INSTALL_PREFIX}/include/QtXml"
  COMMAND ${CMAKE_COMMAND} -E remove_directory "${SB_INSTALL_PREFIX}/mkspecs"
  COMMAND ${CMAKE_COMMAND} -E remove_directory "${SB_INSTALL_PREFIX}/plugins"
  COMMAND ${CMAKE_COMMAND} -E remove_directory "${SB_INSTALL_PREFIX}/translations"
  COMMAND ${CMAKE_COMMAND} -E remove -f "${SB_INSTALL_PREFIX}/lib/libQt*"
88 89 90 91 92 93
  COMMAND ${CMAKE_COMMAND} -E remove -f "${SB_INSTALL_PREFIX}/bin/qmake${QT4_BIN_EXT}"
  COMMAND ${CMAKE_COMMAND} -E remove -f "${SB_INSTALL_PREFIX}/bin/lrelease${QT4_BIN_EXT}"
  COMMAND ${CMAKE_COMMAND} -E remove -f "${SB_INSTALL_PREFIX}/bin/moc${QT4_BIN_EXT}"
  COMMAND ${CMAKE_COMMAND} -E remove -f "${SB_INSTALL_PREFIX}/bin/rcc${QT4_BIN_EXT}"
  COMMAND ${CMAKE_COMMAND} -E remove -f "${SB_INSTALL_PREFIX}/bin/uic${QT4_BIN_EXT}"
  COMMAND ${CMAKE_COMMAND} -E remove -f "${SB_INSTALL_PREFIX}/bin/libQt*"
94 95 96 97 98 99
  WORKING_DIRECTORY "${SB_INSTALL_PREFIX}"
  )

#adding it to dependencies will remove the files when configure QWT
#list(APPEND QT4_DEPENDENCIES QT4-uninstall)

100 101 102 103 104 105 106
  ExternalProject_Add(QT4
    PREFIX QT4
    URL "http://download.qt.io/official_releases/qt/4.8/4.8.7/qt-everywhere-opensource-src-4.8.7.tar.gz"
    URL_MD5 d990ee66bf7ab0c785589776f35ba6ad
    BINARY_DIR ${QT4_SB_SRC}
    INSTALL_DIR ${SB_INSTALL_PREFIX}
    DOWNLOAD_DIR ${DOWNLOAD_LOCATION}
107 108 109
    CONFIGURE_COMMAND ${QT4_CONFIGURE_COMMAND}
    DEPENDS ${QT4_DEPENDENCIES}
    )
110

111 112

 if(MSVC)
113 114 115 116 117 118 119 120 121 122
   #Q: why this copy here?.
   #RK: Because QT4 sucks with qmake -query.
   ExternalProject_Add_Step(QT4 patches
     COMMAND ${CMAKE_COMMAND} -E copy_directory
     ${QT4_SB_SRC}/mkspecs ${SB_INSTALL_PREFIX}/mkspecs
     COMMAND ${CMAKE_COMMAND} -E copy
     ${CMAKE_SOURCE_DIR}/patches/QT4/qjpeghandler.pri
     ${QT4_SB_SRC}/src/gui/image/
     DEPENDEES patch update
     DEPENDERS configure )
123
endif()
Rashad Kanavath's avatar
Rashad Kanavath committed
124

125
SUPERBUILD_PATCH_SOURCE(QT4)
126

127
set(_SB_QT_QMAKE_EXECUTABLE ${SB_INSTALL_PREFIX}/bin/qmake)