Use BYPRODUCTS to keep ninja builds from re-running codegen every time

This partially reverts f02466de8a, but behavior
should be the same under MSVC, which that commit attempted to fix. From
https://cmake.org/cmake/help/v3.14/command/add_custom_command.html:

> The `BYPRODUCTS` option is ignored on non-Ninja generators except to mark
> byproducts `GENERATED`.

Since `$GENERATED_HDRS` are already marked generated, this change should have
no effect on non-Ninja generators.
develop
lethosor 2019-05-13 19:38:24 -04:00
parent f2bd697d64
commit dd9c433f17
1 changed files with 5 additions and 1 deletions

@ -264,10 +264,14 @@ FILE(GLOB GENERATE_INPUT_SCRIPTS ${dfapi_SOURCE_DIR}/xml/*.pm ${dfapi_SOURCE_DIR
FILE(GLOB GENERATE_INPUT_XMLS ${dfapi_SOURCE_DIR}/xml/df.*.xml) FILE(GLOB GENERATE_INPUT_XMLS ${dfapi_SOURCE_DIR}/xml/df.*.xml)
set(CODEGEN_OUT ${dfapi_SOURCE_DIR}/include/df/codegen.out.xml) set(CODEGEN_OUT ${dfapi_SOURCE_DIR}/include/df/codegen.out.xml)
IF(NOT("${CMAKE_GENERATOR}" STREQUAL Ninja))
# use BYPRODUCTS instead under Ninja to avoid rebuilds
LIST(APPEND CODEGEN_OUT ${GENERATED_HDRS}) LIST(APPEND CODEGEN_OUT ${GENERATED_HDRS})
ENDIF()
ADD_CUSTOM_COMMAND( ADD_CUSTOM_COMMAND(
OUTPUT ${CODEGEN_OUT} OUTPUT ${CODEGEN_OUT}
BYPRODUCTS ${GENERATED_HDRS}
COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/xml/codegen.pl COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/xml/codegen.pl
${CMAKE_CURRENT_SOURCE_DIR}/xml ${CMAKE_CURRENT_SOURCE_DIR}/xml
${CMAKE_CURRENT_SOURCE_DIR}/include/df ${CMAKE_CURRENT_SOURCE_DIR}/include/df