qtcmakeqt5qtremoteobjects

cmake qt5_generate_repc() places rep header in CMAKE_CURRENT_BINARY_DIR


I'm trying to determine the right way to build my project. Due to requirements I'm using cmake instead of qmake. In my Qt project I'm using Remote Objects.

The problem is that qt5_generate_repc generates my header from the .rep file and places it in the CMAKE_CURRENT_BINARY_DIR and to make it accessible for include I need to target_include_directories my build directory and I'm not sure if that's a good idea.

Maybe there is a better way or I don't understand some fundamentals?


Solution

  • The problem is that qt5_generate_repc that generates me header from .rep file places it in the CMAKE_CURRENT_BINARY_DIR and to make it accessible for include I need to target_include_directories my build directory and I'm not sure if that's a good idea.

    That is a perfectly normal and accepted practice and indeed is the best thing to do for build-time generated sources. You should do this.

    The simple reason is that you should never write to the source directory in an out-of-tree build, which is the blessed way to use CMake (out-of-tree).

    The overall effect is to prevent a class of name clashing and overwriting issues that might occur.