@@ -292,7 +292,10 @@ namespace vix::commands::BuildCommand
292292 const std::string &toolchainContent)
293293 {
294294 artifact_cache::Artifact a;
295- a.package = sanitize_cache_component (plan.projectDir .filename ().string ());
295+ a.package = sanitize_cache_component (
296+ !plan.defaultTargetName .empty ()
297+ ? plan.defaultTargetName
298+ : plan.projectDir .filename ().string ());
296299 a.version = " local" ;
297300 a.target = sanitize_cache_component (
298301 opt.targetTriple .empty () ? detect_native_target_triple () : opt.targetTriple );
@@ -896,6 +899,9 @@ namespace vix::commands::BuildCommand
896899 userProjectDir = fs::absolute (userProjectDir).lexically_normal ();
897900
898901 fs::path cmakeSourceDir = userProjectDir;
902+ std::string defaultTargetName = userProjectDir.filename ().string ();
903+ bool generatedFromVixApp = false ;
904+
899905 const fs::path cmakeListsPath = userProjectDir / " CMakeLists.txt" ;
900906 const fs::path appManifestPath = userProjectDir / " vix.app" ;
901907
@@ -927,6 +933,8 @@ namespace vix::commands::BuildCommand
927933 }
928934
929935 cmakeSourceDir = generateResult.sourceDir ;
936+ defaultTargetName = loadResult.manifest .name ;
937+ generatedFromVixApp = true ;
930938 }
931939
932940 const auto presetOpt = build::resolve_builtin_preset (opt.preset );
@@ -935,13 +943,17 @@ namespace vix::commands::BuildCommand
935943 return std::nullopt ;
936944
937945 process::Plan plan;
938- plan.projectDir = cmakeSourceDir;
946+ plan.userProjectDir = userProjectDir;
947+ plan.cmakeSourceDir = cmakeSourceDir;
948+ plan.projectDir = userProjectDir;
949+ plan.defaultTargetName = defaultTargetName;
950+ plan.generatedFromVixApp = generatedFromVixApp;
939951 plan.preset = *presetOpt;
940952
941953 plan.launcher = detect_launcher (opt);
942954 plan.fastLinkerFlag = detect_fast_linker_flag (opt);
943955 plan.projectFingerprint =
944- util::compute_cmake_config_fingerprint (plan.projectDir );
956+ util::compute_cmake_config_fingerprint (plan.cmakeSourceDir );
945957
946958 if (!opt.targetTriple .empty ())
947959 plan.buildDir = userProjectDir / (plan.preset .buildDirName + " -" + opt.targetTriple );
@@ -1031,12 +1043,15 @@ namespace vix::commands::BuildCommand
10311043 static std::optional<fs::path> resolve_main_executable (
10321044 const fs::path &buildDir,
10331045 const fs::path &projectDir,
1034- const std::string &buildTarget)
1046+ const std::string &buildTarget,
1047+ const std::string &defaultTargetName)
10351048 {
10361049 const std::string preferredBase =
10371050 !buildTarget.empty ()
10381051 ? buildTarget
1039- : projectDir.filename ().string ();
1052+ : (!defaultTargetName.empty ()
1053+ ? defaultTargetName
1054+ : projectDir.filename ().string ());
10401055
10411056 const std::string preferredName = platform_executable_name (preferredBase);
10421057
@@ -1258,7 +1273,12 @@ namespace vix::commands::BuildCommand
12581273 if (!opt.outPath .empty ())
12591274 return fs::absolute (fs::path (opt.outPath ));
12601275
1261- return plan.buildDir / platform_executable_name (plan.projectDir .filename ().string ());
1276+ const std::string target =
1277+ !plan.defaultTargetName .empty ()
1278+ ? plan.defaultTargetName
1279+ : plan.projectDir .filename ().string ();
1280+
1281+ return plan.buildDir / platform_executable_name (target);
12621282 }
12631283
12641284 static bool file_exists_regular (const fs::path &path)
@@ -1608,7 +1628,7 @@ namespace vix::commands::BuildCommand
16081628
16091629 if (opt.exportBin )
16101630 {
1611- const fs::path dest = plan.projectDir / outputBinary.filename ();
1631+ const fs::path dest = plan.userProjectDir / outputBinary.filename ();
16121632
16131633 if (!export_built_binary (outputBinary, dest, opt.quiet ))
16141634 return 1 ;
@@ -1672,7 +1692,7 @@ namespace vix::commands::BuildCommand
16721692 {
16731693 try
16741694 {
1675- clean_local_build_dirs (plan_.projectDir , opt_.targetTriple , opt_.quiet );
1695+ clean_local_build_dirs (plan_.userProjectDir , opt_.targetTriple , opt_.quiet );
16761696 }
16771697 catch (const std::exception &)
16781698 {
@@ -1766,7 +1786,7 @@ namespace vix::commands::BuildCommand
17661786
17671787 std::vector<artifact_cache::ProjectInput> projectInputs =
17681788 artifact_cache::ArtifactCache::snapshot_project_inputs (
1769- plan_.projectDir ,
1789+ plan_.userProjectDir ,
17701790 previousState ? &previousState->inputs : nullptr );
17711791
17721792 const bool buildStateHit =
@@ -1787,14 +1807,14 @@ namespace vix::commands::BuildCommand
17871807 }
17881808
17891809 build::BuildGraphConfig graphConfig;
1790- graphConfig.projectDir = plan_.projectDir ;
1810+ graphConfig.projectDir = plan_.userProjectDir ;
17911811 graphConfig.buildDir = plan_.buildDir ;
17921812 graphConfig.objectDir = plan_.buildDir / " .vix" / " obj" ;
17931813 graphConfig.compiler = " c++" ;
17941814 graphConfig.buildFingerprint = plan_.signature ;
17951815
1796- graphConfig.includeDirs .push_back ((plan_.projectDir / " include" ).string ());
1797- graphConfig.includeDirs .push_back ((plan_.projectDir / " src" ).string ());
1816+ graphConfig.includeDirs .push_back ((plan_.userProjectDir / " include" ).string ());
1817+ graphConfig.includeDirs .push_back ((plan_.userProjectDir / " src" ).string ());
17981818
17991819 graphConfig.flags .push_back (" -Wall" );
18001820 graphConfig.flags .push_back (" -Wextra" );
@@ -1927,7 +1947,15 @@ namespace vix::commands::BuildCommand
19271947 if (debug_build_details_enabled () && !opt_.quiet )
19281948 {
19291949 out.print (" Using project directory:\n " );
1930- out.print (" • " + plan_.projectDir .string () + " \n\n " );
1950+ out.print (" • " + plan_.userProjectDir .string () + " \n " );
1951+
1952+ if (plan_.generatedFromVixApp )
1953+ {
1954+ out.print (" Using generated CMake source:\n " );
1955+ out.print (" • " + plan_.cmakeSourceDir .string () + " \n " );
1956+ }
1957+
1958+ out.print (" \n " );
19311959 }
19321960
19331961 if (!opt_.targetTriple .empty ())
@@ -1952,7 +1980,7 @@ namespace vix::commands::BuildCommand
19521980
19531981 if (verboseMode && !opt_.quiet )
19541982 {
1955- out.print (" Configuring " + plan_. projectDir . filename (). string ( ) +
1983+ out.print (" Configuring " + build::default_build_target_name (opt_, plan_ ) +
19561984 " (" + display_build_profile (plan_) + " )\n " );
19571985
19581986 if (debug_build_details_enabled ())
@@ -1988,7 +2016,7 @@ namespace vix::commands::BuildCommand
19882016 const std::string log = util::read_text_file_or_empty (plan_.configureLog );
19892017 const bool handled = vix::cli::ErrorHandler::printBuildErrors (
19902018 log,
1991- plan_.projectDir / " CMakeLists.txt" ,
2019+ plan_.cmakeSourceDir / " CMakeLists.txt" ,
19922020 " CMake configure failed" );
19932021
19942022 if (!opt_.quiet && !handled)
@@ -2044,8 +2072,9 @@ namespace vix::commands::BuildCommand
20442072
20452073 const auto exeOpt = resolve_main_executable (
20462074 plan_.buildDir ,
2047- plan_.projectDir ,
2048- opt_.buildTarget );
2075+ plan_.userProjectDir ,
2076+ opt_.buildTarget ,
2077+ plan_.defaultTargetName );
20492078
20502079 if (exeOpt)
20512080 lastBinary = exeOpt->string ();
@@ -2142,7 +2171,7 @@ namespace vix::commands::BuildCommand
21422171 const std::string log = util::read_text_file_or_empty (plan_.buildLog );
21432172 const bool handled = vix::cli::ErrorHandler::printBuildErrors (
21442173 log,
2145- plan_.projectDir / " CMakeLists.txt" ,
2174+ plan_.cmakeSourceDir / " CMakeLists.txt" ,
21462175 " Build failed" );
21472176
21482177 if (!opt_.quiet && !handled)
@@ -2161,8 +2190,9 @@ namespace vix::commands::BuildCommand
21612190
21622191 const auto exeOpt = resolve_main_executable (
21632192 plan_.buildDir ,
2164- plan_.projectDir ,
2165- opt_.buildTarget );
2193+ plan_.userProjectDir ,
2194+ opt_.buildTarget ,
2195+ plan_.defaultTargetName );
21662196
21672197 if (exeOpt)
21682198 lastBinary = exeOpt->string ();
@@ -2230,8 +2260,9 @@ namespace vix::commands::BuildCommand
22302260 {
22312261 const auto exeOpt = resolve_main_executable (
22322262 plan_.buildDir ,
2233- plan_.projectDir ,
2234- opt_.buildTarget );
2263+ plan_.userProjectDir ,
2264+ opt_.buildTarget ,
2265+ plan_.defaultTargetName );
22352266
22362267 if (!exeOpt)
22372268 {
@@ -2243,7 +2274,7 @@ namespace vix::commands::BuildCommand
22432274 fs::path dest;
22442275 if (opt_.exportBin )
22452276 {
2246- dest = plan_.projectDir / exeOpt->filename ();
2277+ dest = plan_.userProjectDir / exeOpt->filename ();
22472278 }
22482279 else
22492280 {
0 commit comments