CMake: Another go at linear dependencies
This simplifies the linear dependencies for custom targets. Should be single shot for make this time. Fixes: lp:1831643 * https://bugs.launchpad.net/kicad/+bug/1831643
This commit is contained in:
parent
7ebda0247f
commit
720889edd0
|
@ -29,51 +29,27 @@
|
||||||
# - Parallel builds all depend on the same files, and CMake will generate the same file multiple times in the same location.
|
# - Parallel builds all depend on the same files, and CMake will generate the same file multiple times in the same location.
|
||||||
# This can be problematic if the files are generated at the same time and overwrite each other.
|
# This can be problematic if the files are generated at the same time and overwrite each other.
|
||||||
# - To fix this, we create a custom target (outputTarget) that the parallel builds depend on.
|
# - To fix this, we create a custom target (outputTarget) that the parallel builds depend on.
|
||||||
# - This almost works except that our targets that depend on targets don't get the file-level dependencies
|
|
||||||
# - So we have one additional layer of indirection to create an intermediate target with file dependencies
|
|
||||||
# AND build dependencies. This creates the needed rebuild for appropriate source object changes.
|
# AND build dependencies. This creates the needed rebuild for appropriate source object changes.
|
||||||
function( make_lexer outputTarget inputFile outHeaderFile outCppFile enum )
|
function( make_lexer outputTarget inputFile outHeaderFile outCppFile enum )
|
||||||
get_filename_component( outHeaderFileBase ${outHeaderFile} NAME )
|
|
||||||
get_filename_component( outCppFileBase ${outCppFile} NAME )
|
|
||||||
set( intermediateHeader "${CMAKE_CURRENT_BINARY_DIR}/${outHeaderFileBase}.1" )
|
|
||||||
set( intermediateCpp "${CMAKE_CURRENT_BINARY_DIR}/${outCppFileBase}.1" )
|
|
||||||
set( intermediateTarget "${outHeaderFileBase}.target" )
|
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT ${intermediateHeader}
|
OUTPUT ${outHeaderFile}
|
||||||
${intermediateCpp}
|
${outCppFile}
|
||||||
COMMAND ${CMAKE_COMMAND}
|
COMMAND ${CMAKE_COMMAND}
|
||||||
-Denum=${enum}
|
-Denum=${enum}
|
||||||
-DinputFile=${inputFile}
|
-DinputFile=${inputFile}
|
||||||
-DoutHeaderFile=${intermediateHeader}
|
-DoutHeaderFile=${outHeaderFile}
|
||||||
-DoutCppFile=${intermediateCpp}
|
-DoutCppFile=${outCppFile}
|
||||||
-P ${CMAKE_MODULE_PATH}/TokenList2DsnLexer.cmake
|
-P ${CMAKE_MODULE_PATH}/TokenList2DsnLexer.cmake
|
||||||
DEPENDS ${inputFile}
|
|
||||||
${CMAKE_MODULE_PATH}/TokenList2DsnLexer.cmake
|
|
||||||
COMMENT "TokenList2DsnLexer.cmake creating:
|
COMMENT "TokenList2DsnLexer.cmake creating:
|
||||||
${outHeaderFile} and
|
${outHeaderFile} and
|
||||||
${outCppFile} from
|
${outCppFile} from
|
||||||
${inputFile}"
|
${inputFile}"
|
||||||
)
|
)
|
||||||
|
|
||||||
add_custom_target(
|
add_custom_target( ${outputTarget}
|
||||||
${intermediateTarget}
|
DEPENDS ${inputFile}
|
||||||
DEPENDS ${intermediateHeader}
|
${CMAKE_MODULE_PATH}/TokenList2DsnLexer.cmake
|
||||||
${intermediateCpp}
|
|
||||||
)
|
|
||||||
|
|
||||||
add_custom_command(
|
|
||||||
OUTPUT ${outHeaderFile}
|
|
||||||
${outCppFile}
|
|
||||||
DEPENDS ${intermediateTarget} ${intermediateHeader} ${intermediateCpp}
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy ${intermediateHeader} ${outHeaderFile}
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy ${intermediateCpp} ${outCppFile}
|
|
||||||
)
|
|
||||||
|
|
||||||
add_custom_target(
|
|
||||||
${outputTarget} ALL
|
|
||||||
DEPENDS ${outHeaderFile}
|
|
||||||
${outCppFile}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# extra_args, if any, are treated as source files (typically headers) which
|
# extra_args, if any, are treated as source files (typically headers) which
|
||||||
|
|
Loading…
Reference in New Issue