blob: 0b37f54d7b53aae3507abc4fce1c924cb6ae42e3 (
plain)
1
2
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# do the automoc handling
# Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
include(${KDE4_AUTOMOC_FILE})
macro(PARSE_ONE_FILE _filename _moc_mark_FILE)
if ("${_filename}" IS_NEWER_THAN "${_moc_mark_FILE}")
file(WRITE "${_moc_mark_FILE}" "#file is autogenerated, do not edit\n")
file(READ "${_filename}" _contents)
get_filename_component(_abs_PATH "${_filename}" PATH)
message(STATUS "Automoc: Parsing ${_filename}")
set(_mocs_PER_FILE)
string(REGEX MATCHALL "#include +([\"<]moc_[^ ]+\\.cpp|[^ ]+\\.moc)[\">]" _match "${_contents}")
if (_match)
foreach (_current_MOC_INC ${_match})
string(REGEX MATCH "[^ <\"]+\\.moc" _current_MOC "${_current_MOC_INC}")
if(_current_MOC)
get_filename_component(_basename ${_current_MOC} NAME_WE)
else(_current_MOC)
string(REGEX MATCH "moc_[^ <\"]+\\.cpp" _current_MOC "${_current_MOC_INC}")
get_filename_component(_basename ${_current_MOC} NAME_WE)
string(REPLACE "moc_" "" _basename "${_basename}")
endif(_current_MOC)
set(_header ${_abs_PATH}/${_basename}.h)
set(_moc ${KDE4_CURRENT_BINARY_DIR}/${_current_MOC})
if (NOT EXISTS ${_header})
message(FATAL_ERROR "In the file \"${_filename}\" the moc file \"${_current_MOC}\" is included, but \"${_header}\" doesn't exist.")
endif (NOT EXISTS ${_header})
list(APPEND _mocs_PER_FILE ${_basename})
file(APPEND ${_moc_mark_FILE} "set( ${_basename}_MOC ${_moc})\n")
file(APPEND ${_moc_mark_FILE} "set( ${_basename}_HEADER ${_header})\n")
endforeach (_current_MOC_INC)
endif (_match)
file(APPEND ${_moc_mark_FILE} "set(mocs ${_mocs_PER_FILE})\n")
endif ("${_filename}" IS_NEWER_THAN "${_moc_mark_FILE}")
endmacro(PARSE_ONE_FILE)
foreach( _current_FILE ${MOC_FILES})
# message(STATUS "Automoc: Checking ${_current_FILE}...")
get_filename_component(_basename ${_current_FILE} NAME)
set(_moc_mark_FILE ${CMAKE_CURRENT_BINARY_DIR}/${_basename}_automoc.mark)
if(EXISTS ${_moc_mark_FILE})
set(_force_MOC FALSE)
else(EXISTS ${_moc_mark_FILE})
set(_force_MOC TRUE)
endif(EXISTS ${_moc_mark_FILE})
parse_one_file(${_current_FILE} ${_moc_mark_FILE})
include(${_moc_mark_FILE})
foreach(_current_MOC ${mocs})
if ("${${_current_MOC}_HEADER}" IS_NEWER_THAN "${${_current_MOC}_MOC}" OR _force_MOC)
message(STATUS "Automoc: Generating ${${_current_MOC}_MOC} from ${${_current_MOC}_HEADER}")
execute_process(COMMAND ${QT_MOC_EXECUTABLE} ${QT_MOC_INCS} ${${_current_MOC}_HEADER} -o ${${_current_MOC}_MOC})
endif ("${${_current_MOC}_HEADER}" IS_NEWER_THAN "${${_current_MOC}_MOC}" OR _force_MOC)
endforeach(_current_MOC)
endforeach( _current_FILE)
|