From d3c0120a2b2ee72c3aa3958b364b9016a27f5006 Mon Sep 17 00:00:00 2001 From: Daniel Adler Date: Mon, 19 Aug 2024 12:23:38 +0200 Subject: [PATCH] cmake/add_obx_schema: dependency chain via previous output cppfile --- cmake/FindObjectBoxGenerator.cmake | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/cmake/FindObjectBoxGenerator.cmake b/cmake/FindObjectBoxGenerator.cmake index 87fac91..ced8da8 100644 --- a/cmake/FindObjectBoxGenerator.cmake +++ b/cmake/FindObjectBoxGenerator.cmake @@ -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}) @@ -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})