CMake add_custom_command/_target in different directories for cross-compilation

后端 未结 2 1566
礼貌的吻别
礼貌的吻别 2020-12-16 23:20

In CMake, I\'m trying to build a project that includes libraries for multiple different processor architectures, compiled by different toolchains. For each architecture, st

2条回答
  •  天涯浪人
    2020-12-16 23:50

    Spot On!

    add_dependencies allowed me to create the final dependency 'link' between add_custom_target created targets, and add_custom_target generates the targets needed to get add_custom_command to create real content in the makefile, i.e., My add_custom_command wouldn't generate output to the makefiles unless the OUTPUT's from the add_custom_command were specified as dependencies in the add_custom_target command.

    Then to get the add_custom_command's to execute in the correct order, I had to use the target names defined in the add_custom_target's as dependencies in the add_dependencies. NOTE: The OUTPUT's specified in the add_custom_command and add_custom_target commands had to be specified in separate quoted paths, i.e.:

    add_custom_command(OUTPUT "out1 out2 out3" ...)  # WRONG!
    add_custom_target(CUSTOMTARG1 "out1 out2 out3")  # WRONG!
    
    add_custom_command(OUTPUT "out1" "out2" "out3" ...)  # RIGHT!
    add_custom_target(CUSTOMTARG1 "out1" "out2" "out3")  # RIGHT!
    

    If I didn't have them in separate quoted paths, the makefile built the outputs every time regardless of whether they existed or not!

提交回复
热议问题