title: Print compilation error to stdout in cmake
body: <p>I am looking for a way to detect failure during the java compilation, followed by a way to print the error message in stdout instead of redirecting it to a file.</p>
  <pre><code>function(generate_swagger_code spec_path lang package_name)
    set(target_dir ${CMAKE_CURRENT_BINARY_DIR}/swagger)
    get_filename_component(fname_noext ${spec_path} NAME_WE)
    add_custom_target(generate_swagger_${fname_noext} ALL
      COMMAND ${CMAKE_COMMAND} -E make_directory ${target_dir}
      COMMENT &quot;Starting swagger autogeneration in ${target_dir}&quot;
      COMMAND java
        -jar ${SWAGGER_CODEGEN_CLI} generate
        -i ${spec_path}
        -l ${lang}
        -DpackageName=${package_name}
        -o ${target_dir} &amp;&gt; ${target_dir}/autogenerate.log
      VERBATIM
    )
  endfunction(generate_swagger_code)
  </code></pre>