From 2f58ca798642385a28c0b7636b66bafeaeb33e36 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Tue, 10 Nov 2026 09:36:45 +0100 Subject: [PATCH 1/2] Declare a project in the old-tree fixture so that Ninja generates it, and check it with Ninja (#514) --- test/cmake/CheckTestOptions.cmake | 8 ++++++++ test/cmake/test-options/CMakeLists.txt | 2 ++ 2 files changed, 10 insertions(+) diff --git a/test/cmake/CheckTestOptions.cmake b/test/cmake/CheckTestOptions.cmake index 294eb2e8..8e09e5cc 100644 --- a/test/cmake/CheckTestOptions.cmake +++ b/test/cmake/CheckTestOptions.cmake @@ -42,6 +42,14 @@ endforeach() configure("old build tree" upgraded OPTIONS -DOLD_TREE=ON -DENABLE_TESTING=ON -DENABLE_COVERAGE=ON) configure("old cache is not migrated" upgraded OPTIONS -DOLD_TREE=OFF -DTOP_LEVEL=ON EXPECT "TESTING=OFF LEGACY=ON" "COVERAGE=OFF LEGACY=ON") +# The same upgrade with Ninja, whatever the default generator of the machine (CMAKE_GENERATOR): Ninja refuses to +# generate a tree that declares no project (#514). +find_program(ninja ninja) +if(ninja) + configure("old build tree with Ninja" upgraded-ninja OPTIONS -G Ninja -DOLD_TREE=ON -DENABLE_TESTING=ON -DENABLE_COVERAGE=ON) + configure("old cache is not migrated with Ninja" upgraded-ninja OPTIONS -DOLD_TREE=OFF -DTOP_LEVEL=ON + EXPECT "TESTING=OFF LEGACY=ON" "COVERAGE=OFF LEGACY=ON") +endif() configure("generic toolchain option" toolchain OPTIONS -DTOP_LEVEL=ON "-DCMAKE_TOOLCHAIN_FILE=${ROOT}/test/cmake/test-options/Toolchain.cmake" -DTOOLCHAIN_LEGACY=ON EXPECT "TESTING=OFF LEGACY=") diff --git a/test/cmake/test-options/CMakeLists.txt b/test/cmake/test-options/CMakeLists.txt index 4aac041e..09950c93 100644 --- a/test/cmake/test-options/CMakeLists.txt +++ b/test/cmake/test-options/CMakeLists.txt @@ -6,6 +6,8 @@ if(OLD_TREE) option(ENABLE_COVERAGE "Enable coverage reporting for gcc/clang" FALSE) option(ENABLE_SANITIZER_ADDRESS "Enable address sanitizer" OFF) message(STATUS "Former options of ${ROOT} declared") + # A generator such as Ninja refuses to generate a tree whose CMakeLists.txt never calls project() (#514). + project(TestOptions LANGUAGES NONE) return() endif() if(FIXTURE_VERSION) From fc0b3d506e7e842b8d761fadd2cbc25ad007f85e Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Tue, 10 Nov 2026 09:55:05 +0100 Subject: [PATCH 2/2] Assert that the old-tree regression ran with Ninja and find it under its other names (#514) --- test/cmake/CheckTestOptions.cmake | 9 +++++---- test/cmake/test-options/CMakeLists.txt | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/test/cmake/CheckTestOptions.cmake b/test/cmake/CheckTestOptions.cmake index 8e09e5cc..a8f87f68 100644 --- a/test/cmake/CheckTestOptions.cmake +++ b/test/cmake/CheckTestOptions.cmake @@ -42,11 +42,12 @@ endforeach() configure("old build tree" upgraded OPTIONS -DOLD_TREE=ON -DENABLE_TESTING=ON -DENABLE_COVERAGE=ON) configure("old cache is not migrated" upgraded OPTIONS -DOLD_TREE=OFF -DTOP_LEVEL=ON EXPECT "TESTING=OFF LEGACY=ON" "COVERAGE=OFF LEGACY=ON") -# The same upgrade with Ninja, whatever the default generator of the machine (CMAKE_GENERATOR): Ninja refuses to -# generate a tree that declares no project (#514). -find_program(ninja ninja) +# The same upgrade with Ninja, whatever the default generator of the machine (CMAKE_GENERATOR). Ninja refuses to +# generate a tree that declares no project, which the old-tree fixture once was (#514): it must keep generating. +find_program(ninja NAMES ninja-build ninja samu) if(ninja) - configure("old build tree with Ninja" upgraded-ninja OPTIONS -G Ninja -DOLD_TREE=ON -DENABLE_TESTING=ON -DENABLE_COVERAGE=ON) + configure("old build tree with Ninja" upgraded-ninja OPTIONS -G Ninja -DOLD_TREE=ON -DENABLE_TESTING=ON -DENABLE_COVERAGE=ON + EXPECT "Old tree generated with Ninja") configure("old cache is not migrated with Ninja" upgraded-ninja OPTIONS -DOLD_TREE=OFF -DTOP_LEVEL=ON EXPECT "TESTING=OFF LEGACY=ON" "COVERAGE=OFF LEGACY=ON") endif() diff --git a/test/cmake/test-options/CMakeLists.txt b/test/cmake/test-options/CMakeLists.txt index 09950c93..f8562781 100644 --- a/test/cmake/test-options/CMakeLists.txt +++ b/test/cmake/test-options/CMakeLists.txt @@ -8,6 +8,7 @@ if(OLD_TREE) message(STATUS "Former options of ${ROOT} declared") # A generator such as Ninja refuses to generate a tree whose CMakeLists.txt never calls project() (#514). project(TestOptions LANGUAGES NONE) + message(STATUS "Old tree generated with ${CMAKE_GENERATOR}") return() endif() if(FIXTURE_VERSION)