On 06/24/2015 11:13 AM, 정언 wrote:
> The copying command should be run right after each execution of bison.

Yes.

> However, add_custom_command never guarantees a running order of
> internal commands. The documentation says, the commands can run
> parallel so never ever put commands with implicit dependencies.

I'm not sure what text from the documentation you're referencing,
but I think that is warning about listing one output in multiple
independent targets, e.g.

 add_custom_command(OUTPUT out.txt ...)
 add_custom_target(tgt1 DEPENDS out.txt)
 add_custom_target(tgt2 DEPENDS out.txt)

That is not the case here.

> Again, we have two custom commands as a result of passing `VERBOSE` to
> bison_target(). One runs bison, and the other runs cp.

We only need one add_custom_command call.  It can list both outputs
and have two COMMAND arguments.  Something like (untested):

      if(...)
        set(_maybe_copy_verbose_output ${BISON_TARGET_ARG_VERBOSE})
        set(_maybe_copy_verbose_command
          COMMAND ${CMAKE_COMMAND} -E copy 
${BISON_TARGET_output_path}/${BISON_TARGET_output_name}.output 
${BISON_TARGET_ARG_VERBOSE}
          )
      endif()

      add_custom_command(OUTPUT ${BISON_TARGET_outputs} 
${_maybe_copy_verbose_output}
        ${BISON_TARGET_extraoutputs}
        COMMAND ${BISON_EXECUTABLE} ${BISON_TARGET_cmdopt} -o ${BisonOutput} 
${BisonInput}
        ${_maybe_copy_verbose_command}
        DEPENDS ${BisonInput}
        COMMENT "[BISON][${Name}] Building parser with bison ${BISON_VERSION}"
        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})

When both COMMAND options are present they will run sequentially.

> If VERBOSE behaved right, REPORT_FILE would not have any benefits over it.

Wouldn't it be able to skip the intermediate file and copy step?

-Brad

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Reply via email to