Skip to content

Commit cc47342

Browse files
akosthekissrobertsipka
authored andcommitted
Fix cmakelists of doctests to run generation only once (#2347)
Custom commands with outputs used in multiple targets are prone to being executed multiple times in parallel builds (and the repeated overwrites of the outputs may lead to various hard-to-debug errors). The fix is to add a custom target that depends on the custom command and make the existing targets using the outputs depend on the new custom target. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss [email protected]
1 parent 2996434 commit cc47342

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tests/unit-doc/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,15 @@ add_custom_command(
5959
COMMENT "Generating doctests"
6060
)
6161

62+
# Add custom target to trigger the custom command above. Targets below can/must
63+
# depend on this one so that the custom command gets executed only once.
64+
add_custom_target(all-doc-files DEPENDS ${DOCTEST_COMPILE} ${DOCTEST_LINK} ${DOCTEST_RUN})
65+
6266
# Process compile-only doctests: add them to a dummy library
6367
# (named libcompile-doc-tests.a) to trigger compilation.
6468
if(NOT ("${DOCTEST_COMPILE}" STREQUAL ""))
6569
add_library(compile-doc-tests STATIC ${DOCTEST_COMPILE})
70+
add_dependencies(compile-doc-tests all-doc-files)
6671
target_link_libraries(compile-doc-tests jerry-ext jerry-core jerry-port-default-minimal)
6772
set_property(TARGET compile-doc-tests APPEND_STRING PROPERTY COMPILE_FLAGS "${COMPILE_FLAGS_DOCTEST}")
6873
endif()
@@ -74,6 +79,7 @@ macro(doctest_add_executables NAME_PREFIX)
7479
set(TARGET_NAME ${NAME_PREFIX}-${TARGET_NAME})
7580

7681
add_executable(${TARGET_NAME} ${DOCTEST_NAME})
82+
add_dependencies(${TARGET_NAME} all-doc-files)
7783
set_property(TARGET ${TARGET_NAME} APPEND_STRING PROPERTY COMPILE_FLAGS "${COMPILE_FLAGS_DOCTEST}")
7884
set_property(TARGET ${TARGET_NAME} PROPERTY LINK_FLAGS "${LINKER_FLAGS_COMMON}")
7985
target_link_libraries(${TARGET_NAME} jerry-ext jerry-core jerry-port-default-minimal)

0 commit comments

Comments
 (0)