Qt Creator and runnig CMake custom targets without triggering build



  • Hi,
    My project uses bunch of custom made bat/python files to generate some source files. Execution of those bat/python files is hidden inside CMake custom targets like :

    add_custom_target(server_build COMMAND "${PROJECT_SOURCE_DIR}/sivi.bat" "X86Win" WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}")
    

    And there is one executable and one library.
    In VS project those target are visible as separate projects in solution and are allowed to be run independently of each other. With result placed in the same build folder.

    Currently as I see it - Qt Creator allows me to define separate RUN targets. However - configuration in this RUN targets is the same as in above custom target.
    alt text
    Beside doubling work (it should get those date from CMake custom target definitions, I don't want do trigger build BEFORE running any of those targets as they generate files essential for build to succeed creating protocol-22 catch.

    In short:

    • how to run custom target WITHOUT triggering build from inside IDE?
    • how to add custom targets to run configuration directly from CMake? Or QtCreator detects what he can run?
    • I would like to make as much changes in CMake files without touching Qt Creator so any one with CMake files could do the same.

  • Moderators

    @SebastianM Someone else had this same question recently.. What I gathered from that thread is that you can't. At least nobody came up with a solution.



  • If those 'custom targets' could be treated by Qt Creator as BUILD targets - then it would solve whole case.
    makefiles treat all targets the same when triggering - only this what is inside differs.



  • I do not understand your question: "Triggering a target" is done by building that specific target.

    Are your custom targets listed in the build configuration of your project? Then you should be able to add more cmake calls building your custom target to your build configuration.

    Or better yet: You make the default build target depend on your custom targets and have cmake trigger them for you. That would work with creator out of the box and also simplifies things everywhere else.



  • Hi,
    I would like to be able to start in. uic_server_ivi target separately. Then after its completed (and some valuable files are generated) - then run another target - ie. copy_ivi_..... And so on.

    How can I create possibility to run ie. 3 different targets, each one separately, each one selectable from Build Kit widget?
    I think that's the main question - how to select which target build quickly from gui? Not by manipulating project build steps.

    PS: I found working solution to this.
    alt text

    • I removed all build configurations except Debug. Rename it and set build steps with selected cmake target.
    • Clone this configuration, point it to the same build directory, rename and use different cmake target as build step.
    • Then repeat this for all expected custom target.

    Now in Manage Build Kits I see those targets, I can choose them and with BUILD command execute them.

    This is satisfying solution for now. I would like to be able to set this from inside CMake - another wish...


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.