1
0

Qt4Macros.cmake 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. # This file is included by FindQt4.cmake, don't include it directly.
  2. #=============================================================================
  3. # Copyright 2005-2009 Kitware, Inc.
  4. #
  5. # Distributed under the OSI-approved BSD License (the "License");
  6. # see accompanying file Copyright.txt for details.
  7. #
  8. # This software is distributed WITHOUT ANY WARRANTY; without even the
  9. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. # See the License for more information.
  11. #=============================================================================
  12. # (To distribute this file outside of CMake, substitute the full
  13. # License text for the above reference.)
  14. ######################################
  15. #
  16. # Macros for building Qt files
  17. #
  18. ######################################
  19. MACRO (QT4_EXTRACT_OPTIONS _qt4_files _qt4_options)
  20. SET(${_qt4_files})
  21. SET(${_qt4_options})
  22. SET(_QT4_DOING_OPTIONS FALSE)
  23. FOREACH(_currentArg ${ARGN})
  24. IF ("${_currentArg}" STREQUAL "OPTIONS")
  25. SET(_QT4_DOING_OPTIONS TRUE)
  26. ELSE ("${_currentArg}" STREQUAL "OPTIONS")
  27. IF(_QT4_DOING_OPTIONS)
  28. LIST(APPEND ${_qt4_options} "${_currentArg}")
  29. ELSE(_QT4_DOING_OPTIONS)
  30. LIST(APPEND ${_qt4_files} "${_currentArg}")
  31. ENDIF(_QT4_DOING_OPTIONS)
  32. ENDIF ("${_currentArg}" STREQUAL "OPTIONS")
  33. ENDFOREACH(_currentArg)
  34. ENDMACRO (QT4_EXTRACT_OPTIONS)
  35. # macro used to create the names of output files preserving relative dirs
  36. MACRO (QT4_MAKE_OUTPUT_FILE infile prefix ext outfile )
  37. STRING(LENGTH ${CMAKE_CURRENT_BINARY_DIR} _binlength)
  38. STRING(LENGTH ${infile} _infileLength)
  39. SET(_checkinfile ${CMAKE_CURRENT_SOURCE_DIR})
  40. IF(_infileLength GREATER _binlength)
  41. STRING(SUBSTRING "${infile}" 0 ${_binlength} _checkinfile)
  42. IF(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
  43. FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_BINARY_DIR} ${infile})
  44. ELSE(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
  45. FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile})
  46. ENDIF(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
  47. ELSE(_infileLength GREATER _binlength)
  48. FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile})
  49. ENDIF(_infileLength GREATER _binlength)
  50. IF(WIN32 AND rel MATCHES "^[a-zA-Z]:") # absolute path
  51. STRING(REGEX REPLACE "^([a-zA-Z]):(.*)$" "\\1_\\2" rel "${rel}")
  52. ENDIF(WIN32 AND rel MATCHES "^[a-zA-Z]:")
  53. SET(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${rel}")
  54. STRING(REPLACE ".." "__" _outfile ${_outfile})
  55. GET_FILENAME_COMPONENT(outpath ${_outfile} PATH)
  56. GET_FILENAME_COMPONENT(_outfile ${_outfile} NAME_WE)
  57. FILE(MAKE_DIRECTORY ${outpath})
  58. SET(${outfile} ${outpath}/${prefix}${_outfile}.${ext})
  59. ENDMACRO (QT4_MAKE_OUTPUT_FILE )
  60. MACRO (QT4_GET_MOC_FLAGS _moc_flags)
  61. SET(${_moc_flags})
  62. GET_DIRECTORY_PROPERTY(_inc_DIRS INCLUDE_DIRECTORIES)
  63. FOREACH(_current ${_inc_DIRS})
  64. IF("${_current}" MATCHES "\\.framework/?$")
  65. STRING(REGEX REPLACE "/[^/]+\\.framework" "" framework_path "${_current}")
  66. SET(${_moc_flags} ${${_moc_flags}} "-F${framework_path}")
  67. ELSE("${_current}" MATCHES "\\.framework/?$")
  68. SET(${_moc_flags} ${${_moc_flags}} "-I${_current}")
  69. ENDIF("${_current}" MATCHES "\\.framework/?$")
  70. ENDFOREACH(_current ${_inc_DIRS})
  71. GET_DIRECTORY_PROPERTY(_defines COMPILE_DEFINITIONS)
  72. FOREACH(_current ${_defines})
  73. SET(${_moc_flags} ${${_moc_flags}} "-D${_current}")
  74. ENDFOREACH(_current ${_defines})
  75. IF(Q_WS_WIN)
  76. SET(${_moc_flags} ${${_moc_flags}} -DWIN32)
  77. ENDIF(Q_WS_WIN)
  78. ENDMACRO(QT4_GET_MOC_FLAGS)
  79. # helper macro to set up a moc rule
  80. MACRO (QT4_CREATE_MOC_COMMAND infile outfile moc_flags moc_options)
  81. # For Windows, create a parameters file to work around command line length limit
  82. IF (WIN32)
  83. # Pass the parameters in a file. Set the working directory to
  84. # be that containing the parameters file and reference it by
  85. # just the file name. This is necessary because the moc tool on
  86. # MinGW builds does not seem to handle spaces in the path to the
  87. # file given with the @ syntax.
  88. GET_FILENAME_COMPONENT(_moc_outfile_name "${outfile}" NAME)
  89. GET_FILENAME_COMPONENT(_moc_outfile_dir "${outfile}" PATH)
  90. IF(_moc_outfile_dir)
  91. SET(_moc_working_dir WORKING_DIRECTORY ${_moc_outfile_dir})
  92. ENDIF(_moc_outfile_dir)
  93. SET (_moc_parameters_file ${outfile}_parameters)
  94. SET (_moc_parameters ${moc_flags} ${moc_options} -o "${outfile}" "${infile}")
  95. STRING (REPLACE ";" "\n" _moc_parameters "${_moc_parameters}")
  96. FILE (WRITE ${_moc_parameters_file} "${_moc_parameters}")
  97. ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
  98. COMMAND ${QT_MOC_EXECUTABLE} @${_moc_outfile_name}_parameters
  99. DEPENDS ${infile}
  100. ${_moc_working_dir}
  101. VERBATIM)
  102. ELSE (WIN32)
  103. ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
  104. COMMAND ${QT_MOC_EXECUTABLE}
  105. ARGS ${moc_flags} ${moc_options} -o ${outfile} ${infile}
  106. DEPENDS ${infile} VERBATIM)
  107. ENDIF (WIN32)
  108. ENDMACRO (QT4_CREATE_MOC_COMMAND)
  109. MACRO (QT4_GENERATE_MOC infile outfile )
  110. # get include dirs and flags
  111. QT4_GET_MOC_FLAGS(moc_flags)
  112. GET_FILENAME_COMPONENT(abs_infile ${infile} ABSOLUTE)
  113. SET(_outfile "${outfile}")
  114. IF(NOT IS_ABSOLUTE "${outfile}")
  115. SET(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${outfile}")
  116. ENDIF(NOT IS_ABSOLUTE "${outfile}")
  117. QT4_CREATE_MOC_COMMAND(${abs_infile} ${_outfile} "${moc_flags}" "")
  118. SET_SOURCE_FILES_PROPERTIES(${outfile} PROPERTIES SKIP_AUTOMOC TRUE) # dont run automoc on this file
  119. ENDMACRO (QT4_GENERATE_MOC)
  120. # QT4_WRAP_CPP(outfiles inputfile ... )
  121. MACRO (QT4_WRAP_CPP outfiles )
  122. # get include dirs
  123. QT4_GET_MOC_FLAGS(moc_flags)
  124. QT4_EXTRACT_OPTIONS(moc_files moc_options ${ARGN})
  125. FOREACH (it ${moc_files})
  126. GET_FILENAME_COMPONENT(it ${it} ABSOLUTE)
  127. QT4_MAKE_OUTPUT_FILE(${it} moc_ cxx outfile)
  128. QT4_CREATE_MOC_COMMAND(${it} ${outfile} "${moc_flags}" "${moc_options}")
  129. SET(${outfiles} ${${outfiles}} ${outfile})
  130. ENDFOREACH(it)
  131. ENDMACRO (QT4_WRAP_CPP)
  132. # QT4_WRAP_UI(outfiles inputfile ... )
  133. MACRO (QT4_WRAP_UI outfiles )
  134. QT4_EXTRACT_OPTIONS(ui_files ui_options ${ARGN})
  135. FOREACH (it ${ui_files})
  136. GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
  137. GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
  138. SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.h)
  139. ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
  140. COMMAND ${QT_UIC_EXECUTABLE}
  141. ARGS ${ui_options} -o ${outfile} ${infile}
  142. MAIN_DEPENDENCY ${infile} VERBATIM)
  143. SET(${outfiles} ${${outfiles}} ${outfile})
  144. ENDFOREACH (it)
  145. ENDMACRO (QT4_WRAP_UI)
  146. # QT4_ADD_RESOURCES(outfiles inputfile ... )
  147. MACRO (QT4_ADD_RESOURCES outfiles )
  148. QT4_EXTRACT_OPTIONS(rcc_files rcc_options ${ARGN})
  149. FOREACH (it ${rcc_files})
  150. GET_FILENAME_COMPONENT(outfilename ${it} NAME_WE)
  151. GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
  152. GET_FILENAME_COMPONENT(rc_path ${infile} PATH)
  153. SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.cxx)
  154. SET(_RC_DEPENDS)
  155. IF(EXISTS "${infile}")
  156. # parse file for dependencies
  157. # all files are absolute paths or relative to the location of the qrc file
  158. FILE(READ "${infile}" _RC_FILE_CONTENTS)
  159. STRING(REGEX MATCHALL "<file[^<]+" _RC_FILES "${_RC_FILE_CONTENTS}")
  160. FOREACH(_RC_FILE ${_RC_FILES})
  161. STRING(REGEX REPLACE "^<file[^>]*>" "" _RC_FILE "${_RC_FILE}")
  162. IF(NOT IS_ABSOLUTE "${_RC_FILE}")
  163. SET(_RC_FILE "${rc_path}/${_RC_FILE}")
  164. ENDIF(NOT IS_ABSOLUTE "${_RC_FILE}")
  165. SET(_RC_DEPENDS ${_RC_DEPENDS} "${_RC_FILE}")
  166. ENDFOREACH(_RC_FILE)
  167. # Since this cmake macro is doing the dependency scanning for these files,
  168. # let's make a configured file and add it as a dependency so cmake is run
  169. # again when dependencies need to be recomputed.
  170. QT4_MAKE_OUTPUT_FILE("${infile}" "" "qrc.depends" out_depends)
  171. CONFIGURE_FILE("${infile}" "${out_depends}" COPY_ONLY)
  172. ELSE(EXISTS "${infile}")
  173. # The .qrc file does not exist (yet). Let's add a dependency and hope
  174. # that it will be generated later
  175. SET(out_depends)
  176. ENDIF(EXISTS "${infile}")
  177. ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
  178. COMMAND ${QT_RCC_EXECUTABLE}
  179. ARGS ${rcc_options} -name ${outfilename} -o ${outfile} ${infile}
  180. MAIN_DEPENDENCY ${infile}
  181. DEPENDS ${_RC_DEPENDS} "${out_depends}" VERBATIM)
  182. SET(${outfiles} ${${outfiles}} ${outfile})
  183. ENDFOREACH (it)
  184. ENDMACRO (QT4_ADD_RESOURCES)
  185. MACRO(QT4_ADD_DBUS_INTERFACE _sources _interface _basename)
  186. GET_FILENAME_COMPONENT(_infile ${_interface} ABSOLUTE)
  187. SET(_header ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h)
  188. SET(_impl ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp)
  189. SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc)
  190. GET_SOURCE_FILE_PROPERTY(_nonamespace ${_interface} NO_NAMESPACE)
  191. IF(_nonamespace)
  192. SET(_params -N -m)
  193. ELSE(_nonamespace)
  194. SET(_params -m)
  195. ENDIF(_nonamespace)
  196. GET_SOURCE_FILE_PROPERTY(_classname ${_interface} CLASSNAME)
  197. IF(_classname)
  198. SET(_params ${_params} -c ${_classname})
  199. ENDIF(_classname)
  200. GET_SOURCE_FILE_PROPERTY(_include ${_interface} INCLUDE)
  201. IF(_include)
  202. SET(_params ${_params} -i ${_include})
  203. ENDIF(_include)
  204. ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
  205. COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} ${_params} -p ${_basename} ${_infile}
  206. DEPENDS ${_infile} VERBATIM)
  207. SET_SOURCE_FILES_PROPERTIES(${_impl} PROPERTIES SKIP_AUTOMOC TRUE)
  208. QT4_GENERATE_MOC(${_header} ${_moc})
  209. SET(${_sources} ${${_sources}} ${_impl} ${_header} ${_moc})
  210. MACRO_ADD_FILE_DEPENDENCIES(${_impl} ${_moc})
  211. ENDMACRO(QT4_ADD_DBUS_INTERFACE)
  212. MACRO(QT4_ADD_DBUS_INTERFACES _sources)
  213. FOREACH (_current_FILE ${ARGN})
  214. GET_FILENAME_COMPONENT(_infile ${_current_FILE} ABSOLUTE)
  215. GET_FILENAME_COMPONENT(_basename ${_current_FILE} NAME)
  216. # get the part before the ".xml" suffix
  217. STRING(TOLOWER ${_basename} _basename)
  218. STRING(REGEX REPLACE "(.*\\.)?([^\\.]+)\\.xml" "\\2" _basename ${_basename})
  219. QT4_ADD_DBUS_INTERFACE(${_sources} ${_infile} ${_basename}interface)
  220. ENDFOREACH (_current_FILE)
  221. ENDMACRO(QT4_ADD_DBUS_INTERFACES)
  222. MACRO(QT4_GENERATE_DBUS_INTERFACE _header) # _customName OPTIONS -some -options )
  223. QT4_EXTRACT_OPTIONS(_customName _qt4_dbus_options ${ARGN})
  224. GET_FILENAME_COMPONENT(_in_file ${_header} ABSOLUTE)
  225. GET_FILENAME_COMPONENT(_basename ${_header} NAME_WE)
  226. IF (_customName)
  227. if (IS_ABSOLUTE ${_customName})
  228. get_filename_component(_containingDir ${_customName} PATH)
  229. if (NOT EXISTS ${_containingDir})
  230. file(MAKE_DIRECTORY "${_containingDir}")
  231. endif()
  232. SET(_target ${_customName})
  233. else()
  234. SET(_target ${CMAKE_CURRENT_BINARY_DIR}/${_customName})
  235. endif()
  236. ELSE (_customName)
  237. SET(_target ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.xml)
  238. ENDIF (_customName)
  239. ADD_CUSTOM_COMMAND(OUTPUT ${_target}
  240. COMMAND ${QT_DBUSCPP2XML_EXECUTABLE} ${_qt4_dbus_options} ${_in_file} -o ${_target}
  241. DEPENDS ${_in_file} VERBATIM
  242. )
  243. ENDMACRO(QT4_GENERATE_DBUS_INTERFACE)
  244. MACRO(QT4_ADD_DBUS_ADAPTOR _sources _xml_file _include _parentClass) # _optionalBasename _optionalClassName)
  245. GET_FILENAME_COMPONENT(_infile ${_xml_file} ABSOLUTE)
  246. SET(_optionalBasename "${ARGV4}")
  247. IF (_optionalBasename)
  248. SET(_basename ${_optionalBasename} )
  249. ELSE (_optionalBasename)
  250. STRING(REGEX REPLACE "(.*[/\\.])?([^\\.]+)\\.xml" "\\2adaptor" _basename ${_infile})
  251. STRING(TOLOWER ${_basename} _basename)
  252. ENDIF (_optionalBasename)
  253. SET(_optionalClassName "${ARGV5}")
  254. SET(_header ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h)
  255. SET(_impl ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp)
  256. SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc)
  257. IF(_optionalClassName)
  258. ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
  259. COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -c ${_optionalClassName} -i ${_include} -l ${_parentClass} ${_infile}
  260. DEPENDS ${_infile} VERBATIM
  261. )
  262. ELSE(_optionalClassName)
  263. ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
  264. COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -i ${_include} -l ${_parentClass} ${_infile}
  265. DEPENDS ${_infile} VERBATIM
  266. )
  267. ENDIF(_optionalClassName)
  268. QT4_GENERATE_MOC(${_header} ${_moc})
  269. SET_SOURCE_FILES_PROPERTIES(${_impl} PROPERTIES SKIP_AUTOMOC TRUE)
  270. MACRO_ADD_FILE_DEPENDENCIES(${_impl} ${_moc})
  271. SET(${_sources} ${${_sources}} ${_impl} ${_header} ${_moc})
  272. ENDMACRO(QT4_ADD_DBUS_ADAPTOR)
  273. MACRO(QT4_AUTOMOC)
  274. QT4_GET_MOC_FLAGS(_moc_INCS)
  275. SET(_matching_FILES )
  276. FOREACH (_current_FILE ${ARGN})
  277. GET_FILENAME_COMPONENT(_abs_FILE ${_current_FILE} ABSOLUTE)
  278. # if "SKIP_AUTOMOC" is set to true, we will not handle this file here.
  279. # This is required to make uic work correctly:
  280. # we need to add generated .cpp files to the sources (to compile them),
  281. # but we cannot let automoc handle them, as the .cpp files don't exist yet when
  282. # cmake is run for the very first time on them -> however the .cpp files might
  283. # exist at a later run. at that time we need to skip them, so that we don't add two
  284. # different rules for the same moc file
  285. GET_SOURCE_FILE_PROPERTY(_skip ${_abs_FILE} SKIP_AUTOMOC)
  286. IF ( NOT _skip AND EXISTS ${_abs_FILE} )
  287. FILE(READ ${_abs_FILE} _contents)
  288. GET_FILENAME_COMPONENT(_abs_PATH ${_abs_FILE} PATH)
  289. STRING(REGEX MATCHALL "# *include +[^ ]+\\.moc[\">]" _match "${_contents}")
  290. IF(_match)
  291. FOREACH (_current_MOC_INC ${_match})
  292. STRING(REGEX MATCH "[^ <\"]+\\.moc" _current_MOC "${_current_MOC_INC}")
  293. GET_FILENAME_COMPONENT(_basename ${_current_MOC} NAME_WE)
  294. IF(EXISTS ${_abs_PATH}/${_basename}.hpp)
  295. SET(_header ${_abs_PATH}/${_basename}.hpp)
  296. ELSE(EXISTS ${_abs_PATH}/${_basename}.hpp)
  297. SET(_header ${_abs_PATH}/${_basename}.h)
  298. ENDIF(EXISTS ${_abs_PATH}/${_basename}.hpp)
  299. SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_current_MOC})
  300. QT4_CREATE_MOC_COMMAND(${_header} ${_moc} "${_moc_INCS}" "")
  301. MACRO_ADD_FILE_DEPENDENCIES(${_abs_FILE} ${_moc})
  302. ENDFOREACH (_current_MOC_INC)
  303. ENDIF(_match)
  304. ENDIF ( NOT _skip AND EXISTS ${_abs_FILE} )
  305. ENDFOREACH (_current_FILE)
  306. ENDMACRO(QT4_AUTOMOC)
  307. MACRO(QT4_CREATE_TRANSLATION _qm_files)
  308. QT4_EXTRACT_OPTIONS(_lupdate_files _lupdate_options ${ARGN})
  309. SET(_my_sources)
  310. SET(_my_dirs)
  311. SET(_my_tsfiles)
  312. SET(_ts_pro)
  313. FOREACH (_file ${_lupdate_files})
  314. GET_FILENAME_COMPONENT(_ext ${_file} EXT)
  315. GET_FILENAME_COMPONENT(_abs_FILE ${_file} ABSOLUTE)
  316. IF(_ext MATCHES "ts")
  317. LIST(APPEND _my_tsfiles ${_abs_FILE})
  318. ELSE(_ext MATCHES "ts")
  319. IF(NOT _ext)
  320. LIST(APPEND _my_dirs ${_abs_FILE})
  321. ELSE(NOT _ext)
  322. LIST(APPEND _my_sources ${_abs_FILE})
  323. ENDIF(NOT _ext)
  324. ENDIF(_ext MATCHES "ts")
  325. ENDFOREACH(_file)
  326. FOREACH(_ts_file ${_my_tsfiles})
  327. IF(_my_sources)
  328. # make a .pro file to call lupdate on, so we don't make our commands too
  329. # long for some systems
  330. GET_FILENAME_COMPONENT(_ts_name ${_ts_file} NAME_WE)
  331. SET(_ts_pro ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_ts_name}_lupdate.pro)
  332. SET(_pro_srcs)
  333. FOREACH(_pro_src ${_my_sources})
  334. SET(_pro_srcs "${_pro_srcs} \"${_pro_src}\"")
  335. ENDFOREACH(_pro_src ${_my_sources})
  336. SET(_pro_includes)
  337. GET_DIRECTORY_PROPERTY(_inc_DIRS INCLUDE_DIRECTORIES)
  338. FOREACH(_pro_include ${_inc_DIRS})
  339. GET_FILENAME_COMPONENT(_abs_include "${_pro_include}" ABSOLUTE)
  340. SET(_pro_includes "${_pro_includes} \"${_abs_include}\"")
  341. ENDFOREACH(_pro_include ${CMAKE_CXX_INCLUDE_PATH})
  342. FILE(WRITE ${_ts_pro} "SOURCES = ${_pro_srcs}\nINCLUDEPATH = ${_pro_includes}\n")
  343. ENDIF(_my_sources)
  344. ADD_CUSTOM_COMMAND(OUTPUT ${_ts_file}
  345. COMMAND ${QT_LUPDATE_EXECUTABLE}
  346. ARGS ${_lupdate_options} ${_ts_pro} ${_my_dirs} -ts ${_ts_file}
  347. DEPENDS ${_my_sources} ${_ts_pro} VERBATIM)
  348. ENDFOREACH(_ts_file)
  349. QT4_ADD_TRANSLATION(${_qm_files} ${_my_tsfiles})
  350. ENDMACRO(QT4_CREATE_TRANSLATION)
  351. MACRO(QT4_ADD_TRANSLATION _qm_files)
  352. FOREACH (_current_FILE ${ARGN})
  353. GET_FILENAME_COMPONENT(_abs_FILE ${_current_FILE} ABSOLUTE)
  354. GET_FILENAME_COMPONENT(qm ${_abs_FILE} NAME_WE)
  355. GET_SOURCE_FILE_PROPERTY(output_location ${_abs_FILE} OUTPUT_LOCATION)
  356. IF(output_location)
  357. FILE(MAKE_DIRECTORY "${output_location}")
  358. SET(qm "${output_location}/${qm}.qm")
  359. ELSE(output_location)
  360. SET(qm "${CMAKE_CURRENT_BINARY_DIR}/${qm}.qm")
  361. ENDIF(output_location)
  362. ADD_CUSTOM_COMMAND(OUTPUT ${qm}
  363. COMMAND ${QT_LRELEASE_EXECUTABLE}
  364. ARGS ${_abs_FILE} -qm ${qm}
  365. DEPENDS ${_abs_FILE} VERBATIM
  366. )
  367. SET(${_qm_files} ${${_qm_files}} ${qm})
  368. ENDFOREACH (_current_FILE)
  369. ENDMACRO(QT4_ADD_TRANSLATION)