2
MACRO(QT4_AUTOMOC2 moc_SRCS)
3
QT4_GET_MOC_INC_DIRS(_moc_INCS)
6
FOREACH (_current_FILE ${ARGN})
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)
18
IF ( NOT _skip AND EXISTS ${_abs_FILE} )
20
FILE(READ ${_abs_FILE} _contents)
22
GET_FILENAME_COMPONENT(_abs_PATH ${_abs_FILE} PATH)
24
STRING(REGEX MATCHALL "Q_OBJECT" _match "${_contents}")
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)
30
ADD_CUSTOM_COMMAND(OUTPUT ${_moc}
31
COMMAND ${QT_MOC_EXECUTABLE}
32
ARGS ${_moc_INCS} ${_header} -o ${_moc}
36
ADD_FILE_DEPENDENCIES(${_abs_FILE} ${_moc})
37
SET(${moc_SRCS} ${${moc_SRCS}} ${_moc})
40
ENDIF ( NOT _skip AND EXISTS ${_abs_FILE} )
41
ENDFOREACH (_current_FILE)
42
ENDMACRO(QT4_AUTOMOC2)
47
FOREACH (_current_FILE ${ARGN})
49
GET_FILENAME_COMPONENT(_abs_FILE ${_current_FILE} ABSOLUTE)
51
IF ( EXISTS ${_abs_FILE} )
53
FILE(READ ${_abs_FILE} _contents)
55
GET_FILENAME_COMPONENT(_abs_PATH ${_abs_FILE} PATH)
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)
62
ADD_CUSTOM_COMMAND(OUTPUT ${_outfile}
63
COMMAND ${QT_UIC_EXECUTABLE}
64
ARGS -o ${_outfile} ${_abs_FILE}
65
MAIN_DEPENDENCY ${_abs_FILE})
67
ADD_FILE_DEPENDENCIES(${_source} ${_outfile})
69
ENDIF ( EXISTS ${_abs_FILE} )
70
ENDFOREACH (_current_FILE)