Skip to content

Commit

Permalink
cmake/add_obx_schema: dependency chain via previous output cppfile
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-obx committed Aug 19, 2024
1 parent 0ef272c commit d3c0120
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions cmake/FindObjectBoxGenerator.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,8 @@ function (add_obx_schema)
set(OBX_GEN_OUTPUT_MODEL_H_ONCE "objectbox-model.h")
endif ()

set(prev_cppfile) # previous cppfile used for artificial dependency chain

# Add a custom call to invoke the generator for each provided schema file.
foreach(SCHEMA_FILE ${ARG_SCHEMA_FILES})

Expand Down Expand Up @@ -413,19 +415,13 @@ function (add_obx_schema)
${ARG_EXTRA_OPTIONS}
${schema_filepath}
DEPENDS
${schema_filepath}
${schema_filepath}
${prev_cppfile} # artificial dependency to ensure no parallel execution
)
set(OBX_GEN_OUTPUT_MODEL_H_ONCE "") # Once only; clear after the first custom command.
set(custom_target gen-${ARG_TARGET}-${basefile})
add_custom_target(${custom_target} DEPENDS ${cppfile} ${hppfile})
if(previous_custom_target)
add_dependencies(${custom_target} ${previous_custom_target})
endif()
set(previous_custom_target ${custom_target})
set(prev_cppfile ${cppfile})
list(APPEND sources ${cppfile} ${hppfile})
endforeach()
add_dependencies(${ARG_TARGET} ${previous_custom_target})

target_sources(${ARG_TARGET} PRIVATE ${sources})
if (NOT ARG_INSOURCE)
target_include_directories(${ARG_TARGET} PRIVATE ${OBX_GEN_OUTPUT_DIR_HEADERS})
Expand Down

0 comments on commit d3c0120

Please sign in to comment.