Skip to content

Commit 8753ad3

Browse files
committed
Merge branch '31-cmake-dependency-chain' into dev
2 parents adcdaff + 1f85b66 commit 8753ad3

3 files changed

Lines changed: 15 additions & 13 deletions

File tree

cmake/FindObjectBoxGenerator.cmake

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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})

test/cmake/cmake.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,15 +196,15 @@ func (cmake *Cmake) BuildWithTarget(target string) ([]byte, []byte, error) {
196196
return cmakeExec(cmake.ConfDir,
197197
"--build", cmake.BuildDir,
198198
"--target", target,
199-
// "--parallel "+strconv.FormatInt(int64(runtime.NumCPU()/2), 10),
199+
"--parallel "+strconv.FormatInt(int64(runtime.NumCPU()/2), 10),
200200
)
201201
}
202202

203203
// Build runs cmake build step.
204204
func (cmake *Cmake) BuildDefaults() ([]byte, []byte, error) {
205205
return cmakeExec(cmake.ConfDir,
206206
"--build", cmake.BuildDir,
207-
// "--parallel "+strconv.FormatInt(int64(runtime.NumCPU()/2), 10),
207+
"--parallel "+strconv.FormatInt(int64(runtime.NumCPU()/2), 10),
208208
)
209209
}
210210

@@ -213,7 +213,7 @@ func (cmake *Cmake) BuildDefaultsWithConfig(config string) ([]byte, []byte, erro
213213
return cmakeExec(cmake.ConfDir,
214214
"--build", cmake.BuildDir,
215215
"--config", config,
216-
// "--parallel "+strconv.FormatInt(int64(runtime.NumCPU()/2), 10),
216+
"--parallel "+strconv.FormatInt(int64(runtime.NumCPU()/2), 10),
217217
)
218218
}
219219

@@ -223,7 +223,7 @@ func (cmake *Cmake) BuildTargetWithConfig(config, target string) ([]byte, []byte
223223
"--build", cmake.BuildDir,
224224
"--config", config,
225225
"--target", target,
226-
// "--parallel "+strconv.FormatInt(int64(runtime.NumCPU()/2), 10),
226+
"--parallel "+strconv.FormatInt(int64(runtime.NumCPU()/2), 10),
227227
)
228228
}
229229

test/integration/cmake/projects/cpp-flat/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ if (DO_INSOURCE)
2323
SCHEMA_FILES
2424
task.fbs
2525
INSOURCE
26-
OUTPUT_DIR_HEADERS
26+
OUTPUT_DIR
2727
schema1
2828
)
2929
add_obx_schema(
@@ -32,7 +32,7 @@ if (DO_INSOURCE)
3232
SCHEMA_FILES
3333
monster.fbs
3434
INSOURCE
35-
OUTPUT_DIR_HEADERS
35+
OUTPUT_DIR
3636
schema2
3737
)
3838
target_include_directories(objectbox-test PRIVATE schema1 schema2)

0 commit comments

Comments
 (0)