The Nina generator does not generate all needed dependencies?

This buildPreset works with Unix Makefiles, but not with Ninja:

{
  "version": 6,
  "cmakeMinimumRequired": {
    "major": 3,
    "minor": 25,
    "patch": 0
  },
  "configurePresets": [
    {
      "name": "dev",
      "displayName": "developer Ninja build on unix with Coverage",
      "description": "NOTE: coverage must be the first to overwrite Release build! CK",
      "inherits": ["coverage-Darwin", "ci-Darwin", "doxygen"],
      "generator": "Ninja",
      "installDir": "${sourceDir}/stagedir",
      "cacheVariables": {
        "CMAKE_PREFIX_PATH": {
          "type": "path",
          "value": "${sourceDir}/stagedir"
        }
      }
    }
  ],
  "buildPresets": [
    {
      "name": "dev",
      "configurePreset": "dev",
      "configuration": "Coverage",
      "targets": ["all", "format-fix", "spell-fix", "test", "coverage", "install"]
    }
  ],
  "testPresets": [
    {
      "name": "dev",
      "configurePreset": "dev",
      "configuration": "Coverage",
      "output": {
        "outputOnFailure": true
      }
    }
  ],
  "workflowPresets": [
    {
      "name": "dev",
      "steps": [
        {
          "type": "configure",
          "name": "dev"
        },
        {
          "type": "build",
          "name": "dev"
        },
        {
          "type": "test",
          "name": "dev"
        }
      ]
    }
  ]
}
bash-5.2$ cmake --workflow --preset dev
Executing workflow step 1 of 3: configure preset "dev"

Preset CMake variables:

  BUILD_MCSS_DOCS:BOOL="TRUE"
  BUILD_SHARED_LIBS="ON"
  BUILD_TESTING="ON"
  CMAKE_BUILD_TYPE="Coverage"
  CMAKE_CXX_EXTENSIONS="OFF"
  CMAKE_CXX_FLAGS="-fstack-protector-strong -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Wcast-qual -Wformat=2 -Wundef -Werror=float-equal -Wshadow -Wcast-align -Wunused -Wnull-dereference -Wdouble-promotion -Wimplicit-fallthrough -Wextra-semi -Woverloaded-virtual -Wnon-virtual-dtor -Wold-style-cast"
  CMAKE_CXX_FLAGS_COVERAGE="-Og -g --coverage"
  CMAKE_CXX_STANDARD="20"
  CMAKE_CXX_STANDARD_REQUIRED="ON"
  CMAKE_EXE_LINKER_FLAGS_COVERAGE="--coverage"
  CMAKE_EXPORT_COMPILE_COMMANDS="ON"
  CMAKE_INSTALL_PREFIX:PATH="/Users/clausklein/Workspace/cpp/cmake-init-shared-static/stagedir"
  CMAKE_PREFIX_PATH:STRING="/Users/clausklein/Workspace/cpp/cmake-init-shared-static/stagedir"
  CMAKE_SHARED_LINKER_FLAGS_COVERAGE="--coverage"
  ENABLE_COVERAGE="ON"
  shared_DEVELOPER_MODE="ON"

-- The CXX compiler identification is Clang 17.0.6
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/local/opt/llvm/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY - Success
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY - Success
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Success
-- Found Python3: /usr/local/Frameworks/Python.framework/Versions/3.12/bin/python3.12 (found suitable version "3.12.2", minimum required is "3.6") found components: Interpreter
-- Configuring done (4.1s)
-- Generating done (0.0s)
-- Build files have been written to: /Users/clausklein/Workspace/cpp/cmake-init-shared-static/build/coverage

Executing workflow step 2 of 3: build preset "dev"

[0/10] Running tests...
Test project /Users/clausklein/Workspace/cpp/cmake-init-shared-static/build/coverage
    Start 1: shared_test
Could not find executable /Users/clausklein/Workspace/cpp/cmake-init-shared-static/build/coverage/test/shared_test
Looked in the following places:
/Users/clausklein/Workspace/cpp/cmake-init-shared-static/build/coverage/test/shared_test

. . .

Unable to find executable: /Users/clausklein/Workspace/cpp/cmake-init-shared-static/build/coverage/test/shared_test
1/1 Test #1: shared_test ......................***Not Run   0.00 sec

0% tests passed, 1 tests failed out of 1

Total Test time (real) =   0.00 sec

The following tests FAILED:
	  1 - shared_test (Not Run)
Errors while running CTest
Output from these tests are in: /Users/clausklein/Workspace/cpp/cmake-init-shared-static/build/coverage/Testing/Temporary/LastTest.log
Use "--rerun-failed --output-on-failure" to re-run the failed cases verbosely.
[0/10] Building CXX object test/CMakeFiles/shared_test.dir/source/shared_test.cpp.o
FAILED: CMakeFiles/test.util 
cd /Users/clausklein/Workspace/cpp/cmake-init-shared-static/build/coverage && /usr/local/Cellar/cmake/3.29.1/bin/ctest --force-new-ctest-process
[2/10] Fixing spelling errors
Used config files:
    1: .codespellrc
[4/10] Generating coverage report
FAILED: CMakeFiles/coverage /Users/clausklein/Workspace/cpp/cmake-init-shared-static/build/coverage/CMakeFiles/coverage 
cd /Users/clausklein/Workspace/cpp/cmake-init-shared-static/build/coverage && lcov -c -q -o /Users/clausklein/Workspace/cpp/cmake-init-shared-static/build/coverage/coverage.info -d /Users/clausklein/Workspace/cpp/cmake-init-shared-static/build/coverage --include "/Users/clausklein/Workspace/cpp/cmake-init-shared-static/*" && genhtml --legend -f -q /Users/clausklein/Workspace/cpp/cmake-init-shared-static/build/coverage/coverage.info -p /Users/clausklein/Workspace/cpp/cmake-init-shared-static -o /Users/clausklein/Workspace/cpp/cmake-init-shared-static/build/coverage/coverage_html
geninfo: ERROR: no .gcda files found in /Users/clausklein/Workspace/cpp/cmake-init-shared-static/build/coverage
	(use "geninfo --ignore-errors empty ..." to bypass this error)
[6/10] Building CXX object test/CMakeFiles/shared_test.dir/source/shared_test.cpp.o
ninja: build stopped: subcommand failed.
make: *** [coverage] Error 1
bash-5.2$ 

this works:
gmake -C build/coverage/ clean all test install -j 12
but this not:
ninja -C build/coverage/ clean all test install -j 12

How does the ninja build fail? Is there an associated error message?

Same result as with build preset.

test must depend from all
install must depend from all

It seems, that this is set for the generated makefiles.

Can you please provide a full example that demonstrates the problem? Stripping down the existing project may also find a chunk of logic that is associated with the behavior.

The cmake tutorial step 5 for example:

bash-5.2$ cmake  -B build-mk -S . -D CMAKE_INSTALL_PREFIX=/tmp/test
-- The C compiler identification is Clang 17.0.6
-- The CXX compiler identification is Clang 17.0.6
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/local/opt/llvm/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/local/opt/llvm/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (2.1s)
-- Generating done (0.0s)
-- Build files have been written to: /Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build-mk
bash-5.2$ make -C build-mk all test install
[ 16%] Building CXX object MathFunctions/CMakeFiles/SqrtLibrary.dir/mysqrt.cxx.o
[ 33%] Linking CXX static library libSqrtLibrary.a
[ 33%] Built target SqrtLibrary
[ 50%] Building CXX object MathFunctions/CMakeFiles/MathFunctions.dir/MathFunctions.cxx.o
[ 66%] Linking CXX static library libMathFunctions.a
[ 66%] Built target MathFunctions
[ 83%] Building CXX object CMakeFiles/Tutorial.dir/tutorial.cxx.o
[100%] Linking CXX executable Tutorial
[100%] Built target Tutorial
Running tests...
Test project /Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build-mk
      Start  1: Runs
 1/10 Test  #1: Runs .............................   Passed    0.24 sec
      Start  2: Usage
 2/10 Test  #2: Usage ............................   Passed    0.00 sec
      Start  3: StandardUse
 3/10 Test  #3: StandardUse ......................   Passed    0.00 sec
      Start  4: Comp4
 4/10 Test  #4: Comp4 ............................   Passed    0.00 sec
      Start  5: Comp9
 5/10 Test  #5: Comp9 ............................   Passed    0.00 sec
      Start  6: Comp5
 6/10 Test  #6: Comp5 ............................   Passed    0.00 sec
      Start  7: Comp7
 7/10 Test  #7: Comp7 ............................   Passed    0.00 sec
      Start  8: Comp25
 8/10 Test  #8: Comp25 ...........................   Passed    0.00 sec
      Start  9: Comp-25
 9/10 Test  #9: Comp-25 ..........................   Passed    0.00 sec
      Start 10: Comp0.0001
10/10 Test #10: Comp0.0001 .......................   Passed    0.00 sec

100% tests passed, 0 tests failed out of 10

Total Test time (real) =   0.28 sec
Install the project...
-- Install configuration: ""
-- Installing: /tmp/test/lib/libMathFunctions.a
-- Installing: /tmp/test/lib/libSqrtLibrary.a
-- Installing: /tmp/test/include/MathFunctions.h
-- Installing: /tmp/test/bin/Tutorial
-- Installing: /tmp/test/include/TutorialConfig.h
bash-5.2$ 
bash-5.2$ cmake -G Ninja -B build -S . -D CMAKE_INSTALL_PREFIX=/tmp/test
-- Configuring done (0.1s)
-- Generating done (0.0s)
-- Build files have been written to: /Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build
bash-5.2$ ninja -C build all test install
ninja: Entering directory `build'
[0/4] Running tests...
Test project /Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build
    Start 1: Runs
Could not find executable /Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Tutorial
Looked in the following places:
/Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Tutorial
/Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Tutorial
/Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Release/Tutorial
/Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Release/Tutorial
/Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Debug/Tutorial
/Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Debug/Tutorial
/Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/MinSizeRel/Tutorial
/Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/MinSizeRel/Tutorial
/Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/RelWithDebInfo/Tutorial
/Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/RelWithDebInfo/Tutorial
/Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Deployment/Tutorial
/Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Deployment/Tutorial
/Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Development/Tutorial
/Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Development/Tutorial
Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Tutorial
Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Tutorial
Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Release/Tutorial
Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Release/Tutorial
Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Debug/Tutorial
Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Debug/Tutorial
Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/MinSizeRel/Tutorial
Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/MinSizeRel/Tutorial
Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/RelWithDebInfo/Tutorial
Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/RelWithDebInfo/Tutorial
Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Deployment/Tutorial
Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Deployment/Tutorial
Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Development/Tutorial
Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Development/Tutorial
Unable to find executable: /Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Tutorial
1/2 Test #1: Runs .............................***Not Run   0.00 sec
    Start 2: Usage
Could not find executable /Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Tutorial
Looked in the following places:
/Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Tutorial
/Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Tutorial
/Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Release/Tutorial
/Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Release/Tutorial
/Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Debug/Tutorial
/Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Debug/Tutorial
/Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/MinSizeRel/Tutorial
/Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/MinSizeRel/Tutorial
/Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/RelWithDebInfo/Tutorial
/Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/RelWithDebInfo/Tutorial
/Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Deployment/Tutorial
/Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Deployment/Tutorial
/Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Development/Tutorial
/Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Development/Tutorial
Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Tutorial
Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Tutorial
Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Release/Tutorial
Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Release/Tutorial
Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Debug/Tutorial
Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Debug/Tutorial
Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/MinSizeRel/Tutorial
Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/MinSizeRel/Tutorial
Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/RelWithDebInfo/Tutorial
Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/RelWithDebInfo/Tutorial
Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Deployment/Tutorial
Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Deployment/Tutorial
Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Development/Tutorial
Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Development/Tutorial
Unable to find executable: /Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Tutorial
2/2 Test #2: Usage ............................***Not Run   0.00 sec

0% tests passed, 2 tests failed out of 2

Total Test time (real) =   0.01 sec

The following tests FAILED:
	  1 - Runs (Not Run)
	  2 - Usage (Not Run)
Errors while running CTest
Output from these tests are in: /Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build/Testing/Temporary/LastTest.log
Use "--rerun-failed --output-on-failure" to re-run the failed cases verbosely.
[0/4] Linking CXX static library MathFunctions/libMathFunctions.a
FAILED: CMakeFiles/test.util 
cd /Users/clausklein/Downloads/cmake/Help/guide/tutorial/Step5/build && /usr/local/bin/ctest --force-new-ctest-process
[2/4] Linking CXX static library MathFunctions/libMathFunctions.a
ninja: build stopped: subcommand failed.
bash-5.2$