On Tue, Mar 22, 2016 at 11:49 AM, Brad King <[email protected]> wrote: > Please revise 0001 to apply cleanly on top of 78ec0461. > > Also please revise 0002 to avoid using the ZERO_CHECK target because > it does not exist in all VS generators. I had added custom target > to the test case to use instead.
Done - see attached.
From 892918c84b5205f9d08854d2fd98e08a39d69f77 Mon Sep 17 00:00:00 2001 From: Taylor Braun-Jones <[email protected]> Date: Mon, 21 Mar 2016 14:34:34 -0400 Subject: [PATCH 1/3] VS: Improve unit test macros 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 352bbd5..f36aab2 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 "TestStartup") error("TestStartup 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 6f3cae57f8b38129fd1d847f63e9da843e97e09a Mon Sep 17 00:00:00 2001 From: Taylor Braun-Jones <[email protected]> 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..c0a545a --- /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 "TestStartup") + error("TestStartup 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..a64c8ce --- /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 "TestStartup") -- 2.7.2.windows.1
From cb31fff77dd02da33b151fb8936a1549d7bb305f Mon Sep 17 00:00:00 2001 From: Taylor Braun-Jones <[email protected]> Date: Mon, 21 Mar 2016 16:05:41 -0400 Subject: [PATCH 3/3] VS: 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
