开发者

How to set output path of cmake / qt4 command QT4_WRAP_UI

开发者 https://www.devze.com 2023-01-21 15:18 出处:网络
I use the cmake command QT4_WRAP_UI. Is there an option to control the output path of the generated header开发者_如何转开发 files?Here is QT4_WRAP_UI source code:

I use the cmake command QT4_WRAP_UI. Is there an option to control the output path of the generated header开发者_如何转开发 files?


Here is QT4_WRAP_UI source code:

MACRO (QT4_WRAP_UI outfiles )
  QT4_EXTRACT_OPTIONS(ui_files ui_options ${ARGN})

  FOREACH (it ${ui_files})
    GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
    GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
    SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.h) # Here we set output
    ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
      COMMAND ${QT_UIC_EXECUTABLE}
      ARGS ${ui_options} -o ${outfile} ${infile}
      MAIN_DEPENDENCY ${infile})
    SET(${outfiles} ${${outfiles}} ${outfile})
  ENDFOREACH (it)

ENDMACRO (QT4_WRAP_UI)

As you can see, the outfile variable is build from CMAKE_CURRENT_BINARY_DIR variable. You can create a custom macro that will replace that line.


I had to find a solution to this. I did create a custom macro, but I think it would be nicer if the macro in cmake upstream would handle this automagically.

See my proposal here


You can simply add the ${CMAKE_CURRENT_BINARY_DIR} to the include dir:

include_directories(${CMAKE_CURRENT_BINARY_DIR})
0

精彩评论

暂无评论...
验证码 换一张
取 消