~ubuntu-branches/ubuntu/trusty/picviz/trusty

« back to all changes in this revision

Viewing changes to cmake/qt.cmake

  • Committer: Bazaar Package Importer
  • Author(s): Pierre Chifflier
  • Date: 2009-03-30 10:42:08 UTC
  • Revision ID: james.westby@ubuntu.com-20090330104208-j095obwkp574t1lm
Tags: upstream-0.5
ImportĀ upstreamĀ versionĀ 0.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
MACRO(QT4_AUTOMOC2 moc_SRCS)
 
3
  QT4_GET_MOC_INC_DIRS(_moc_INCS)
 
4
 
 
5
  SET(_matching_FILES )
 
6
  FOREACH (_current_FILE ${ARGN})
 
7
 
 
8
     GET_FILENAME_COMPONENT(_abs_FILE ${_current_FILE} ABSOLUTE)
 
9
     # if "SKIP_AUTOMOC" is set to true, we will not handle this file here.
 
10
     # here. this is required to make bouic work correctly:
 
11
     # we need to add generated .cpp files to the sources (to compile them),
 
12
     # but we cannot let automoc handle them, as the .cpp files don't exist yet when
 
13
     # cmake is run for the very first time on them -> however the .cpp files might
 
14
     # exist at a later run. at that time we need to skip them, so that we don't add two
 
15
     # different rules for the same moc file
 
16
     GET_SOURCE_FILE_PROPERTY(_skip ${_abs_FILE} SKIP_AUTOMOC)
 
17
 
 
18
     IF ( NOT _skip AND EXISTS ${_abs_FILE} )
 
19
 
 
20
        FILE(READ ${_abs_FILE} _contents)
 
21
 
 
22
        GET_FILENAME_COMPONENT(_abs_PATH ${_abs_FILE} PATH)
 
23
 
 
24
        STRING(REGEX MATCHALL "Q_OBJECT" _match "${_contents}")
 
25
        IF(_match)
 
26
            GET_FILENAME_COMPONENT(_basename ${_current_FILE} NAME_WE)
 
27
            SET(_header ${_abs_PATH}/${_basename}.h)
 
28
            SET(_moc    ${CMAKE_CURRENT_BINARY_DIR}/moc_${_basename}.cpp)
 
29
 
 
30
            ADD_CUSTOM_COMMAND(OUTPUT ${_moc}
 
31
                COMMAND ${QT_MOC_EXECUTABLE}
 
32
                ARGS ${_moc_INCS} ${_header} -o ${_moc}
 
33
                DEPENDS ${_header}
 
34
            )
 
35
 
 
36
            ADD_FILE_DEPENDENCIES(${_abs_FILE} ${_moc})
 
37
            SET(${moc_SRCS} ${${moc_SRCS}} ${_moc})
 
38
 
 
39
        ENDIF(_match)
 
40
     ENDIF ( NOT _skip AND EXISTS ${_abs_FILE} )
 
41
  ENDFOREACH (_current_FILE)
 
42
ENDMACRO(QT4_AUTOMOC2)
 
43
 
 
44
MACRO(QT4_AUTOUIC)
 
45
 
 
46
  SET(_matching_FILES )
 
47
  FOREACH (_current_FILE ${ARGN})
 
48
 
 
49
     GET_FILENAME_COMPONENT(_abs_FILE ${_current_FILE} ABSOLUTE)
 
50
 
 
51
     IF ( EXISTS ${_abs_FILE} )
 
52
 
 
53
        FILE(READ ${_abs_FILE} _contents)
 
54
 
 
55
        GET_FILENAME_COMPONENT(_abs_PATH ${_abs_FILE} PATH)
 
56
 
 
57
        GET_FILENAME_COMPONENT(_basename ${_current_FILE} NAME_WE)
 
58
        SET(_outfile ${CMAKE_CURRENT_SOURCE_DIR}/ui_${_basename}.h)
 
59
        SET(_header ${_basename}.h)
 
60
        SET(_source ${_basename}.cpp)
 
61
 
 
62
        ADD_CUSTOM_COMMAND(OUTPUT ${_outfile}
 
63
            COMMAND ${QT_UIC_EXECUTABLE}
 
64
            ARGS -o ${_outfile} ${_abs_FILE}
 
65
            MAIN_DEPENDENCY ${_abs_FILE})
 
66
 
 
67
        ADD_FILE_DEPENDENCIES(${_source} ${_outfile})
 
68
 
 
69
     ENDIF ( EXISTS ${_abs_FILE} )
 
70
  ENDFOREACH (_current_FILE)
 
71
ENDMACRO(QT4_AUTOUIC)
 
72