From 7f598ea7cd01b52f9f5c14fc1d38e0eb097e7892 Mon Sep 17 00:00:00 2001 From: Daniel Adler Date: Wed, 14 Aug 2024 10:19:12 +0200 Subject: [PATCH 1/6] test/cmake: run parallel --- test/cmake/cmake.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/cmake/cmake.go b/test/cmake/cmake.go index 2cc17f6..51c9fcd 100644 --- a/test/cmake/cmake.go +++ b/test/cmake/cmake.go @@ -196,7 +196,7 @@ func (cmake *Cmake) BuildWithTarget(target string) ([]byte, []byte, error) { return cmakeExec(cmake.ConfDir, "--build", cmake.BuildDir, "--target", target, - // "--parallel "+strconv.FormatInt(int64(runtime.NumCPU()/2), 10), + "--parallel "+strconv.FormatInt(int64(runtime.NumCPU()/2), 10), ) } @@ -204,7 +204,7 @@ func (cmake *Cmake) BuildWithTarget(target string) ([]byte, []byte, error) { func (cmake *Cmake) BuildDefaults() ([]byte, []byte, error) { return cmakeExec(cmake.ConfDir, "--build", cmake.BuildDir, - // "--parallel "+strconv.FormatInt(int64(runtime.NumCPU()/2), 10), + "--parallel "+strconv.FormatInt(int64(runtime.NumCPU()/2), 10), ) } @@ -213,7 +213,7 @@ func (cmake *Cmake) BuildDefaultsWithConfig(config string) ([]byte, []byte, erro return cmakeExec(cmake.ConfDir, "--build", cmake.BuildDir, "--config", config, - // "--parallel "+strconv.FormatInt(int64(runtime.NumCPU()/2), 10), + "--parallel "+strconv.FormatInt(int64(runtime.NumCPU()/2), 10), ) } @@ -223,7 +223,7 @@ func (cmake *Cmake) BuildTargetWithConfig(config, target string) ([]byte, []byte "--build", cmake.BuildDir, "--config", config, "--target", target, - // "--parallel "+strconv.FormatInt(int64(runtime.NumCPU()/2), 10), + "--parallel "+strconv.FormatInt(int64(runtime.NumCPU()/2), 10), ) } From e5bc1050b3ca5a21c1d67fe486f6301c3cf31484 Mon Sep 17 00:00:00 2001 From: Daniel Adler Date: Wed, 14 Aug 2024 10:53:06 +0200 Subject: [PATCH 2/6] cmake/add_obx_schema: added dependency chain --- cmake/FindObjectBoxGenerator.cmake | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmake/FindObjectBoxGenerator.cmake b/cmake/FindObjectBoxGenerator.cmake index 71ae05e..6f16367 100644 --- a/cmake/FindObjectBoxGenerator.cmake +++ b/cmake/FindObjectBoxGenerator.cmake @@ -414,11 +414,17 @@ function (add_obx_schema) ${schema_filepath} DEPENDS ${schema_filepath} - USES_TERMINAL # Needed for ninja ) 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}) list(APPEND sources ${cppfile} ${hppfile}) endforeach() + add_dependencies(${ARG_TARGET} ${previous_custom_target}) target_sources(${ARG_TARGET} PRIVATE ${sources}) if (NOT ARG_INSOURCE) From 957d404a561bf7e69bcf60eb4fa6348b5dc46c56 Mon Sep 17 00:00:00 2001 From: Daniel Adler Date: Mon, 19 Aug 2024 10:21:21 +0200 Subject: [PATCH 3/6] FindObjectBoxGenerator.cmake: Minor doc fix --- cmake/FindObjectBoxGenerator.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/FindObjectBoxGenerator.cmake b/cmake/FindObjectBoxGenerator.cmake index 6f16367..87fac91 100644 --- a/cmake/FindObjectBoxGenerator.cmake +++ b/cmake/FindObjectBoxGenerator.cmake @@ -87,8 +87,8 @@ One caveat with ``INSOURCE`` is that a cmake clean (cmake --target clean) also d ``OUTPUT_DIR`` specifies the location for auto-generated files in the source tree (default: current source directory). -If you have multiple schemas (multiple calls to ``add_obx_schema()``), you need to use different ``OUTPUT_DIR``s -to ensure a clear separation of generated files (e.g. avoid overwriting files with the same name). +If you have multiple schemas (multiple calls to ``add_obx_schema()``), you need to use different ``OUTPUT_DIR`` +directories to ensure a clear separation of generated files (e.g. avoid overwriting files with the same name). * For in-source (``INSOURCE``) builds, this affects all generated files. The given directory can be relative to current source directory or can be given as absolute path. From 28dd5180acbce5a0b47c21a9c571cd15f7fb25b6 Mon Sep 17 00:00:00 2001 From: Daniel Adler Date: Mon, 19 Aug 2024 12:23:38 +0200 Subject: [PATCH 4/6] 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}) From 79e94e54a6f55d49b33ee9ac2e3644559ea07b05 Mon Sep 17 00:00:00 2001 From: Markus Date: Mon, 19 Aug 2024 14:57:58 +0200 Subject: [PATCH 5/6] cpp-flat test: use OUTPUT_DIR to separate the outputs Otherwise, there's a concurrency issue with the model files --- test/integration/cmake/projects/cpp-flat/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/integration/cmake/projects/cpp-flat/CMakeLists.txt b/test/integration/cmake/projects/cpp-flat/CMakeLists.txt index f1bbc7c..1d67fb8 100644 --- a/test/integration/cmake/projects/cpp-flat/CMakeLists.txt +++ b/test/integration/cmake/projects/cpp-flat/CMakeLists.txt @@ -23,7 +23,7 @@ if (DO_INSOURCE) SCHEMA_FILES task.fbs INSOURCE - OUTPUT_DIR_HEADERS + OUTPUT_DIR schema1 ) add_obx_schema( @@ -32,7 +32,7 @@ if (DO_INSOURCE) SCHEMA_FILES monster.fbs INSOURCE - OUTPUT_DIR_HEADERS + OUTPUT_DIR schema2 ) target_include_directories(objectbox-test PRIVATE schema1 schema2) From 1f85b66c0473345459247646a12f13ba4d9a3f1c Mon Sep 17 00:00:00 2001 From: Daniel Adler Date: Mon, 19 Aug 2024 16:57:09 +0200 Subject: [PATCH 6/6] FindObjectBoxGenerator: insource output headers default to output source dir --- cmake/FindObjectBoxGenerator.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/FindObjectBoxGenerator.cmake b/cmake/FindObjectBoxGenerator.cmake index ced8da8..93d1bd4 100644 --- a/cmake/FindObjectBoxGenerator.cmake +++ b/cmake/FindObjectBoxGenerator.cmake @@ -303,8 +303,10 @@ function (add_obx_schema) if (ARG_INSOURCE) if (OBX_GEN_OUTPUT_DIR) set(OBX_GEN_OUTPUT_DIR_SRC ${OBX_GEN_OUTPUT_DIR}) + set(OBX_GEN_OUTPUT_DIR_HEADERS ${OBX_GEN_OUTPUT_DIR}) else() set(OBX_GEN_OUTPUT_DIR_SRC) + set(OBX_GEN_OUTPUT_DIR_HEADERS) endif() if (ARG_OUTPUT_DIR_HEADERS) if(IS_ABSOLUTE ${ARG_OUTPUT_DIR_HEADERS}) @@ -313,8 +315,6 @@ function (add_obx_schema) set(OBX_GEN_OUTPUT_DIR_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_OUTPUT_DIR_HEADERS}) endif() file(MAKE_DIRECTORY ${OBX_GEN_OUTPUT_DIR_HEADERS}) - else() - set(OBX_GEN_OUTPUT_DIR_HEADERS) endif() else () # out-of-source: if (ARG_OUTPUT_DIR_HEADERS)