On Fri, Mar 18, 2016 at 1:31 PM, Brad King <brad.k...@kitware.com> wrote: > > Please check that the revised version works for you.
I did some more thorough testing and ran into an issue when USE_FOLDERS is enabled. The problem is actually the same one affecting the ALL_BUILD target that is preventing it from being grouped with the PREDEFINED_TARGETS_FOLDER as it should be. It's not actually the first target in a .sln file that is treated as the default startup project, but rather the first _fully defined target_. See this SO comment thread: http://stackoverflow.com/questions/694730/why-is-set-as-startup-option-stored-in-the-suo-file-and-not-the-sln-file#comment40597475_1808352 The solution is to just list all folders in the .sln file first (patch 0002). With the fix in patch 0002, ALL_BUILD can then be put in PREDEFINED_TARGETS_FOLDER (patch 0003). Taylor
From 2e4adaba69cd61143c468dc50b9bc82a06d5e484 Mon Sep 17 00:00:00 2001 From: Taylor Braun-Jones <taylor.braunjo...@avigilon.com> Date: Mon, 21 Mar 2016 14:34:34 -0400 Subject: [PATCH 1/3] fixup! VS: Add option to choose the `.sln` startup project (#15578) Change `getFirstProject` macro to more flexible version `getProjectNames` --- Tests/RunCMake/VSSolution/StartupProject-check.cmake | 3 ++- .../RunCMake/VSSolution/StartupProjectMissing-check.cmake | 3 ++- Tests/RunCMake/VSSolution/solution_parsing.cmake | 15 ++++++++------- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Tests/RunCMake/VSSolution/StartupProject-check.cmake b/Tests/RunCMake/VSSolution/StartupProject-check.cmake index fd7cc28..8890334 100644 --- a/Tests/RunCMake/VSSolution/StartupProject-check.cmake +++ b/Tests/RunCMake/VSSolution/StartupProject-check.cmake @@ -1,4 +1,5 @@ -getFirstProject(first_project StartupProject) +getProjectNames(projects) +list(GET projects 0 first_project) if(NOT first_project STREQUAL "ZERO_CHECK") error("ZERO_CHECK is not the startup project") endif() diff --git a/Tests/RunCMake/VSSolution/StartupProjectMissing-check.cmake b/Tests/RunCMake/VSSolution/StartupProjectMissing-check.cmake index 95fede7..b1017dd 100644 --- a/Tests/RunCMake/VSSolution/StartupProjectMissing-check.cmake +++ b/Tests/RunCMake/VSSolution/StartupProjectMissing-check.cmake @@ -1,4 +1,5 @@ -getFirstProject(first_project StartupProjectMissing) +getProjectNames(projects) +list(GET projects 0 first_project) if(NOT first_project STREQUAL "ALL_BUILD") error("ALL_BUILD is not the startup project") endif() diff --git a/Tests/RunCMake/VSSolution/solution_parsing.cmake b/Tests/RunCMake/VSSolution/solution_parsing.cmake index 001b584..4e5bb59 100644 --- a/Tests/RunCMake/VSSolution/solution_parsing.cmake +++ b/Tests/RunCMake/VSSolution/solution_parsing.cmake @@ -50,17 +50,18 @@ macro(parseGlobalSections arg_out_pre arg_out_post testName) endmacro() -macro(getFirstProject arg_out_first_project testName) - set(${arg_out_first_project} "") - set(sln "${RunCMake_TEST_BINARY_DIR}/${testName}.sln") +macro(getProjectNames arg_out_projects) + set(${arg_out_projects} "") + set(sln "${RunCMake_TEST_BINARY_DIR}/${test}.sln") if(NOT EXISTS "${sln}") error("Expected solution file ${sln} does not exist") endif() file(STRINGS "${sln}" project_lines REGEX "^Project\\(") - list(GET project_lines 0 first_project) - string(REGEX REPLACE ".* = \"" "" first_project "${first_project}") - string(REGEX REPLACE "\", .*" "" first_project "${first_project}") - set(${arg_out_first_project} "${first_project}") + foreach(project_line IN LISTS project_lines) + string(REGEX REPLACE ".* = \"" "" project_line "${project_line}") + string(REGEX REPLACE "\", .*" "" project_line "${project_line}") + list(APPEND ${arg_out_projects} "${project_line}") + endforeach() endmacro() -- 2.7.2.windows.1
From 898826c3dfb86078c6b42578d4bb5ae991552ecc Mon Sep 17 00:00:00 2001 From: Taylor Braun-Jones <taylor.braunjo...@avigilon.com> Date: Mon, 21 Mar 2016 16:01:20 -0400 Subject: [PATCH 2/3] VS: Fix default target support for targets nested inside a folder --- Source/cmGlobalVisualStudio71Generator.cxx | 5 ++++- Tests/RunCMake/VSSolution/RunCMakeTest.cmake | 1 + Tests/RunCMake/VSSolution/StartupProjectUseFolders-check.cmake | 9 +++++++++ Tests/RunCMake/VSSolution/StartupProjectUseFolders.cmake | 2 ++ 4 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 Tests/RunCMake/VSSolution/StartupProjectUseFolders-check.cmake create mode 100644 Tests/RunCMake/VSSolution/StartupProjectUseFolders.cmake diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index f6796a5..289fbb5 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -97,7 +97,8 @@ void cmGlobalVisualStudio71Generator OrderedTargetDependSet orderedProjectTargets( projectTargets, this->GetStartupProjectName(root)); - this->WriteTargetsToSolution(fout, root, orderedProjectTargets); + std::stringstream targetsSlnString; + this->WriteTargetsToSolution(targetsSlnString, root, orderedProjectTargets); bool useFolderProperty = this->UseFolderProperty(); if (useFolderProperty) @@ -105,6 +106,8 @@ void cmGlobalVisualStudio71Generator this->WriteFolders(fout); } + fout << targetsSlnString.str(); + // Write out the configurations information for the solution fout << "Global\n"; // Write out the configurations for the solution diff --git a/Tests/RunCMake/VSSolution/RunCMakeTest.cmake b/Tests/RunCMake/VSSolution/RunCMakeTest.cmake index 8ae9598..19b309c 100644 --- a/Tests/RunCMake/VSSolution/RunCMakeTest.cmake +++ b/Tests/RunCMake/VSSolution/RunCMakeTest.cmake @@ -10,3 +10,4 @@ run_cmake(Override1) run_cmake(Override2) run_cmake(StartupProject) run_cmake(StartupProjectMissing) +run_cmake(StartupProjectUseFolders) diff --git a/Tests/RunCMake/VSSolution/StartupProjectUseFolders-check.cmake b/Tests/RunCMake/VSSolution/StartupProjectUseFolders-check.cmake new file mode 100644 index 0000000..36e4dca --- /dev/null +++ b/Tests/RunCMake/VSSolution/StartupProjectUseFolders-check.cmake @@ -0,0 +1,9 @@ +getProjectNames(projects) +list(GET projects 0 first_project) +if(NOT first_project STREQUAL "CMakePredefinedTargets") + error("CMakePredefinedTargets is not the first project") +endif() +list(GET projects 1 second_project) +if(NOT second_project STREQUAL "ZERO_CHECK") + error("ZERO_CHECK does not immediately follow the CMakePredefinedTargets project") +endif() diff --git a/Tests/RunCMake/VSSolution/StartupProjectUseFolders.cmake b/Tests/RunCMake/VSSolution/StartupProjectUseFolders.cmake new file mode 100644 index 0000000..7c31b97 --- /dev/null +++ b/Tests/RunCMake/VSSolution/StartupProjectUseFolders.cmake @@ -0,0 +1,2 @@ +set_property(GLOBAL PROPERTY USE_FOLDERS ON) +set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT "ZERO_CHECK") -- 2.7.2.windows.1
From 7094ef12d6d41b0959874b83fab262bf9f8de3d9 Mon Sep 17 00:00:00 2001 From: Taylor Braun-Jones <taylor.braunjo...@avigilon.com> Date: Mon, 21 Mar 2016 16:05:41 -0400 Subject: [PATCH 3/3] Put ALL_BUILD in the PREDEFINED_TARGETS_FOLDER --- Source/cmGlobalVisualStudioGenerator.cxx | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index b11b49a..9817b09 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -89,11 +89,6 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets() cmGeneratorTarget* gt = new cmGeneratorTarget(allBuild, gen[0]); gen[0]->AddGeneratorTarget(gt); -#if 0 - // Can't activate this code because we want ALL_BUILD - // selected as the default "startup project" when first - // opened in Visual Studio... And if it's nested in a - // folder, then that doesn't happen. // // Organize in the "predefined targets" folder: // @@ -101,7 +96,6 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets() { allBuild->SetProperty("FOLDER", this->GetPredefinedTargetsFolder()); } -#endif // Now make all targets depend on the ALL_BUILD target for(std::vector<cmLocalGenerator*>::iterator i = gen.begin(); -- 2.7.2.windows.1
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers