~renatofilho/messaging-app/fix-1489330

« back to all changes in this revision

Viewing changes to cmake/modules/qt5.cmake

  • Committer: Renato Araujo Oliveira Filho
  • Date: 2015-11-06 11:47:14 UTC
  • mfrom: (458.1.6 messaging-app)
  • Revision ID: renato.filho@canonical.com-20151106114714-1w31i0d58zzsel37
Trunk merged.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# shamelessly copied over from oxide’s build system
 
2
# to enable ARM cross compilation
 
3
 
 
4
if(CMAKE_CROSSCOMPILING)
 
5
  # QT_MOC_EXECUTABLE is set by Qt5CoreConfigExtras, but it sets it to
 
6
  # the target executable rather than the host executable, which is no
 
7
  # use for cross-compiling. For cross-compiling, we have a guess and
 
8
  # override it ourselves
 
9
  if(NOT TARGET Qt5::moc)
 
10
    find_program(
 
11
        QT_MOC_EXECUTABLE moc
 
12
        PATHS /usr/lib/qt5/bin /usr/lib/${HOST_ARCHITECTURE}/qt5/bin
 
13
        NO_DEFAULT_PATH)
 
14
    if(QT_MOC_EXECUTABLE STREQUAL "QT_MOC_EXECUTABLE-NOTFOUND")
 
15
      message(FATAL_ERROR "Can't find a moc executable for the host arch")
 
16
    endif()
 
17
    add_executable(Qt5::moc IMPORTED)
 
18
    set_target_properties(Qt5::moc PROPERTIES
 
19
        IMPORTED_LOCATION "${QT_MOC_EXECUTABLE}")
 
20
  endif()
 
21
 
 
22
  # Dummy targets - not used anywhere, but this stops Qt5CoreConfigExtras.cmake
 
23
  # from creating them and checking if the binary exists, which is broken when
 
24
  # cross-building because it checks for the target system binary. We need the
 
25
  # host system binaries installed, because they are in the same package as the
 
26
  # moc in Ubuntu (qtbase5-dev-tools), which is not currently multi-arch
 
27
  if(NOT TARGET Qt5::qmake)
 
28
    add_executable(Qt5::qmake IMPORTED)
 
29
  endif()
 
30
  if(NOT TARGET Qt5::rcc)
 
31
    add_executable(Qt5::rcc IMPORTED)
 
32
  endif()
 
33
  if(NOT TARGET Qt5::uic)
 
34
    add_executable(Qt5::uic IMPORTED)
 
35
  endif()
 
36
  if(NOT TARGET Qt5::DBus)
 
37
    add_executable(Qt5::DBus IMPORTED)
 
38
  endif()
 
39
else()
 
40
  # This should be enough to initialize QT_MOC_EXECUTABLE
 
41
  find_package(Qt5Core)
 
42
endif()