@@ -87,8 +87,8 @@ One caveat with ``INSOURCE`` is that a cmake clean (cmake --target clean) also d
8787
8888``OUTPUT_DIR`` specifies the location for auto-generated files in the source tree
8989(default: current source directory).
90- If you have multiple schemas (multiple calls to ``add_obx_schema()``), you need to use different ``OUTPUT_DIR``s
91- to ensure a clear separation of generated files (e.g. avoid overwriting files with the same name).
90+ If you have multiple schemas (multiple calls to ``add_obx_schema()``), you need to use different ``OUTPUT_DIR``
91+ directories to ensure a clear separation of generated files (e.g. avoid overwriting files with the same name).
9292
9393* For in-source (``INSOURCE``) builds, this affects all generated files.
9494 The given directory can be relative to current source directory or can be given as absolute path.
@@ -303,8 +303,10 @@ function (add_obx_schema)
303303 if (ARG_INSOURCE)
304304 if (OBX_GEN_OUTPUT_DIR)
305305 set (OBX_GEN_OUTPUT_DIR_SRC ${OBX_GEN_OUTPUT_DIR} )
306+ set (OBX_GEN_OUTPUT_DIR_HEADERS ${OBX_GEN_OUTPUT_DIR} )
306307 else ()
307308 set (OBX_GEN_OUTPUT_DIR_SRC)
309+ set (OBX_GEN_OUTPUT_DIR_HEADERS)
308310 endif ()
309311 if (ARG_OUTPUT_DIR_HEADERS)
310312 if (IS_ABSOLUTE ${ARG_OUTPUT_DIR_HEADERS} )
@@ -313,8 +315,6 @@ function (add_obx_schema)
313315 set (OBX_GEN_OUTPUT_DIR_HEADERS ${CMAKE_CURRENT_SOURCE_DIR} /${ARG_OUTPUT_DIR_HEADERS} )
314316 endif ()
315317 file (MAKE_DIRECTORY ${OBX_GEN_OUTPUT_DIR_HEADERS} )
316- else ()
317- set (OBX_GEN_OUTPUT_DIR_HEADERS)
318318 endif ()
319319 else () # out-of-source:
320320 if (ARG_OUTPUT_DIR_HEADERS)
@@ -353,6 +353,8 @@ function (add_obx_schema)
353353 set (OBX_GEN_OUTPUT_MODEL_H_ONCE "objectbox-model.h" )
354354 endif ()
355355
356+ set (prev_cppfile) # previous cppfile used for artificial dependency chain
357+
356358 # Add a custom call to invoke the generator for each provided schema file.
357359 foreach (SCHEMA_FILE ${ARG_SCHEMA_FILES} )
358360
@@ -413,13 +415,13 @@ function (add_obx_schema)
413415 ${ARG_EXTRA_OPTIONS}
414416 ${schema_filepath}
415417 DEPENDS
416- ${schema_filepath}
417- USES_TERMINAL # Needed for ninja
418+ ${schema_filepath}
419+ ${prev_cppfile} # artificial dependency to ensure no parallel execution
418420 )
419421 set (OBX_GEN_OUTPUT_MODEL_H_ONCE "" ) # Once only; clear after the first custom command.
422+ set (prev_cppfile ${cppfile} )
420423 list (APPEND sources ${cppfile} ${hppfile} )
421424 endforeach ()
422-
423425 target_sources (${ARG_TARGET} PRIVATE ${sources} )
424426 if (NOT ARG_INSOURCE)
425427 target_include_directories (${ARG_TARGET} PRIVATE ${OBX_GEN_OUTPUT_DIR_HEADERS} )
0 commit comments