Skip to content
  • Evan Wilde's avatar
    file(GENERATE): Restore INPUT|CONTENT parse checking · 88f90a72
    Evan Wilde authored and Brad King's avatar Brad King committed
    Refactoring in commit bff468c9 (cmFileCommand: Use cm::optional for
    keyword argument presence, 2022-06-30, v3.25.0-rc1~512^2) accidentally
    broke the check that the input argument is either `INPUT` or `CONTENT`.
    
    The check is supposed to fail when arguments are passed in the wrong
    order.  For example:
    
        file(GENERATE OUTPUT ...
             TARGET <target>
             CONTENT <content>)
    
    Prior to this fix, the input method would be CONTENT, but because the
    first parsed keyword is not `CONTENT`, `inputIsContent` would be false.
    The first parsed keyword isn't INPUT either, so we would not continue
    into the error condition. CMake would then try to handle this as an
    input file, when there isn't one, resulting in uninitialized memory
    usage and segfaults or corruption later on.
    
    Fixes: #25169
    88f90a72