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_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_UI_FILES)
41 if(QT4_GET_MOC_INC_DIRS)
42 QT4_GET_MOC_INC_DIRS(_moc_INCS)
43 endif(QT4_GET_MOC_INC_DIRS)
46 foreach (_current_FILE ${ARGN})
48 get_filename_component(_abs_FILE ${_current_FILE} ABSOLUTE)
49 # if "SKIP_AUTOMOC" is set to true, we will not handle this file here.
50 # here. this is required to make bouic work correctly:
51 # we need to add generated .cpp files to the sources (to compile them),
52 # but we cannot let automoc handle them, as the .cpp files don't exist yet when
53 # cmake is run for the very first time on them -> however the .cpp files might
54 # exist at a later run. at that time we need to skip them, so that we don't add two
55 # different rules for the same moc file
56 get_source_file_property(_skip ${_abs_FILE} SKIP_AUTOMOC)
58 if (EXISTS ${_abs_FILE} AND NOT _skip)
60 file(READ ${_abs_FILE} _contents)
62 get_filename_component(_abs_PATH ${_abs_FILE} PATH)
64 string(REGEX MATCHALL "#include +[^ ]+_moc\\.cpp[\">]" _match "${_contents}")
66 foreach (_current_MOC_INC ${_match})
67 string(REGEX MATCH "[^ <\"]+_moc\\.cpp" _current_MOC "${_current_MOC_INC}")
69 get_filename_component(_basename ${_current_MOC} NAME_WE)
71 string(LENGTH ${_basename} _length)
72 MATH(EXPR _mocless_length ${_length}-4)
73 STRING(SUBSTRING ${_basename} 0 ${_mocless_length} _mocless_name )
75 set(_header ${_abs_PATH}/${_mocless_name}.h)
77 #message(STATUS "moc : ${_header}")
81 #set(_header ${CMAKE_CURRENT_SOURCE_DIR}/${_basename}.h)
82 #set(_header ${_abs_PATH}/${_basename}.h)
83 set(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_current_MOC})
85 #set(_moc ${_abs_PATH}/${_current_MOC})
86 add_custom_command(OUTPUT ${_moc}
87 COMMAND ${QT_MOC_EXECUTABLE}
88 ARGS ${_moc_INCS} ${_header} -o ${_moc}
89 MAIN_DEPENDENCY ${_header}
91 macro_add_file_dependencies(${_abs_FILE} ${_moc})
93 endforeach (_current_MOC_INC)
95 #message(STATUS "moc not found : ${_abs_FILE} ")
98 endif (EXISTS ${_abs_FILE} AND NOT _skip)
99 endforeach (_current_FILE)
100 endmacro (LYX_AUTOMOC)
104 # folders in the project
105 # mode==flat : no folders
106 # mode==split : standart behavior of cmake, split heders and sources
107 # mode== <other values" : code is in this folder
108 macro(project_source_group mode sources headers)
109 #message(STATUS ${mode})
110 #message(STATUS ${sources} ${headers})
111 if(${mode} MATCHES "flat")
112 source_group("Source Files" Files)
113 source_group("Header Files" Files)
114 else(${mode} MATCHES "flat")
115 if(NOT ${mode} MATCHES "split")
116 source_group("${mode}" FILES ${${sources}} ${${headers}})
117 source_group("cmake" FILES CMakeLists.txt)
118 endif(NOT ${mode} MATCHES "split")
119 endif(${mode} MATCHES "flat")
120 endmacro(project_source_group mode sources headers)