@@ -339,6 +339,43 @@ namespace vix::commands::CheckCommand::detail
339339 return {};
340340 }
341341
342+ static bool cmake_cache_has_global_packages_include (
343+ const fs::path &buildDir,
344+ const fs::path &expectedFile)
345+ {
346+ const fs::path cacheFile = buildDir / " CMakeCache.txt" ;
347+ if (!fs::exists (cacheFile))
348+ return false ;
349+
350+ const std::string value =
351+ read_cmake_cache_value (cacheFile, " CMAKE_PROJECT_TOP_LEVEL_INCLUDES" );
352+
353+ if (value.empty ())
354+ return false ;
355+
356+ std::error_code ec1, ec2;
357+ const fs::path lhs = fs::weakly_canonical (fs::path (value), ec1);
358+ const fs::path rhs = fs::weakly_canonical (expectedFile, ec2);
359+
360+ if (!ec1 && !ec2)
361+ return lhs == rhs;
362+
363+ return fs::path (value) == expectedFile;
364+ }
365+
366+ static bool should_force_reconfigure_for_global_packages (
367+ const fs::path &buildDir,
368+ const fs::path &globalPackagesFile)
369+ {
370+ if (!has_cmake_cache (buildDir))
371+ return true ;
372+
373+ if (!fs::exists (globalPackagesFile))
374+ return true ;
375+
376+ return !cmake_cache_has_global_packages_include (buildDir, globalPackagesFile);
377+ }
378+
342379#ifndef _WIN32
343380 static std::string guess_project_name_from_dir (const fs::path &projectDir)
344381 {
@@ -680,23 +717,26 @@ namespace vix::commands::CheckCommand::detail
680717
681718 print_header (opt, projectDir, configurePreset, buildDir, hasDedicatedSanPreset, shouldRunRuntime);
682719
683- if (!has_cmake_cache (buildDir))
720+ const auto globalPackagesFile = write_global_packages_file (buildDir);
721+ if (!globalPackagesFile)
722+ {
723+ style::error (" Failed to prepare global packages integration file." );
724+ style::hint (" Check filesystem permissions for the build directory." );
725+ return 2 ;
726+ }
727+
728+ const bool needsConfigure =
729+ should_force_reconfigure_for_global_packages (buildDir, *globalPackagesFile);
730+
731+ if (needsConfigure)
684732 {
685733 if (!opt.quiet )
686734 {
687- ui::info_line (std::cout, " No matching CMake cache found for this check profile." );
735+ ui::info_line (std::cout, " Project configuration is required for this check profile." );
688736 ui::kv (std::cout, " action" , " configure" );
689737 ui::one_line_spacer (std::cout);
690738 }
691739
692- const auto globalPackagesFile = write_global_packages_file (buildDir);
693- if (!globalPackagesFile)
694- {
695- style::error (" Failed to prepare global packages integration file." );
696- style::hint (" Check filesystem permissions for the build directory." );
697- return 2 ;
698- }
699-
700740#ifdef _WIN32
701741 std::ostringstream conf;
702742 if (summary.sanitizersEnabled && !hasDedicatedSanPreset)
@@ -768,6 +808,7 @@ namespace vix::commands::CheckCommand::detail
768808 {
769809 ui::ok_line (std::cout, " CMake cache detected for this check profile." );
770810 ui::kv (std::cout, " build dir" , buildDir.string ());
811+ ui::kv (std::cout, " global deps" , " ready" );
771812 ui::one_line_spacer (std::cout);
772813 }
773814 }
@@ -917,15 +958,18 @@ namespace vix::commands::CheckCommand::detail
917958 return 1 ;
918959 }
919960
920- if (!has_cmake_cache (buildDir))
961+ const auto globalPackagesFile = write_global_packages_file (buildDir);
962+ if (!globalPackagesFile)
921963 {
922- const auto globalPackagesFile = write_global_packages_file (buildDir );
923- if (!globalPackagesFile)
924- {
925- style::error ( " Failed to prepare global packages integration file. " );
926- return 2 ;
927- }
964+ style::error ( " Failed to prepare global packages integration file. " );
965+ return 2 ;
966+ }
967+
968+ const bool needsConfigure =
969+ should_force_reconfigure_for_global_packages (buildDir, *globalPackagesFile);
928970
971+ if (needsConfigure)
972+ {
929973#ifdef _WIN32
930974 std::ostringstream conf;
931975 conf << " cmd /C \" cd /D " << quote (projectDir.string ())
@@ -980,7 +1024,10 @@ namespace vix::commands::CheckCommand::detail
9801024 else
9811025 {
9821026 if (!opt.quiet )
1027+ {
9831028 ui::ok_line (std::cout, " CMake cache detected." );
1029+ ui::kv (std::cout, " global deps" , " ready" );
1030+ }
9841031 }
9851032
9861033#ifdef _WIN32
0 commit comments