2 macro(lyx_add_path _list _prefix)
4 foreach(_current ${${_list}})
5 set(_tmp ${_tmp} ${_prefix}/${_current})
6 #message( ${_prefix}/${_current})
9 endmacro(lyx_add_path _out _prefix)
12 #create the implementation files from the ui files and add them to the list of sources
13 #usage: LYX_ADD_QT4_UI_FILES(foo_SRCS ${ui_files})
14 macro (LYX_ADD_QT4_UI_FILES _sources )
15 foreach (_current_FILE ${ARGN})
17 get_filename_component(_tmp_FILE ${_current_FILE} ABSOLUTE)
18 get_filename_component(_basename ${_tmp_FILE} NAME_WE)
19 set(_header ${CMAKE_CURRENT_BINARY_DIR}/ui/${_basename}.h)
21 # we need to run uic and replace some things in the generated file
22 # this is done by executing the cmake script kde4uic.cmake
23 add_custom_command(OUTPUT ${_header}
24 COMMAND ${CMAKE_COMMAND}
27 -DKDE_UIC_EXECUTABLE:FILEPATH=${QT_UIC_EXECUTABLE}
28 -DKDE_UIC_FILE:FILEPATH=${_tmp_FILE}
29 -DKDE_UIC_H_FILE:FILEPATH=${_header}
30 -DKDE_UIC_BASENAME:STRING=${_basename}
31 -P ${CMAKE_MODULE_PATH}/LyXuic.cmake
32 MAIN_DEPENDENCY ${_tmp_FILE}
34 set(${_sources} ${${_sources}} ${_header})
35 endforeach (_current_FILE)
36 endmacro (LYX_ADD_QT4_UI_FILES)
41 QT4_GET_MOC_INC_DIRS(_moc_INCS)
44 foreach (_current_FILE ${ARGN})
46 get_filename_component(_abs_FILE ${_current_FILE} ABSOLUTE)
47 # if "SKIP_AUTOMOC" is set to true, we will not handle this file here.
48 # here. this is required to make bouic work correctly:
49 # we need to add generated .cpp files to the sources (to compile them),
50 # but we cannot let automoc handle them, as the .cpp files don't exist yet when
51 # cmake is run for the very first time on them -> however the .cpp files might
52 # exist at a later run. at that time we need to skip them, so that we don't add two
53 # different rules for the same moc file
54 get_source_file_property(_skip ${_abs_FILE} SKIP_AUTOMOC)
56 if (EXISTS ${_abs_FILE} AND NOT _skip)
58 file(READ ${_abs_FILE} _contents)
60 get_filename_component(_abs_PATH ${_abs_FILE} PATH)
62 string(REGEX MATCHALL "#include +[^ ]+_moc\\.cpp[\">]" _match "${_contents}")
64 foreach (_current_MOC_INC ${_match})
65 string(REGEX MATCH "[^ <\"]+_moc\\.cpp" _current_MOC "${_current_MOC_INC}")
67 get_filename_component(_basename ${_current_MOC} NAME_WE)
69 string(LENGTH ${_basename} _length)
70 MATH(EXPR _mocless_length ${_length}-4)
71 STRING(SUBSTRING ${_basename} 0 ${_mocless_length} _mocless_name )
73 set(_header ${_abs_PATH}/${_mocless_name}.h)
75 #message(STATUS "moc : ${_header}")
79 #set(_header ${CMAKE_CURRENT_SOURCE_DIR}/${_basename}.h)
80 #set(_header ${_abs_PATH}/${_basename}.h)
81 set(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_current_MOC})
83 #set(_moc ${_abs_PATH}/${_current_MOC})
84 add_custom_command(OUTPUT ${_moc}
85 COMMAND ${QT_MOC_EXECUTABLE}
86 ARGS ${_moc_INCS} ${_header} -o ${_moc}
87 MAIN_DEPENDENCY ${_header}
89 macro_add_file_dependencies(${_abs_FILE} ${_moc})
91 endforeach (_current_MOC_INC)
93 #message(STATUS "moc not found : ${_abs_FILE} ")
96 endif (EXISTS ${_abs_FILE} AND NOT _skip)
97 endforeach (_current_FILE)
98 endmacro (LYX_AUTOMOC)