diff options
31 files changed, 278 insertions, 39 deletions
diff --git a/Help/command/cmake_minimum_required.rst b/Help/command/cmake_minimum_required.rst index dc65a9e..9535bf3 100644 --- a/Help/command/cmake_minimum_required.rst +++ b/Help/command/cmake_minimum_required.rst @@ -1,29 +1,14 @@ cmake_minimum_required ---------------------- -Set the minimum required version of cmake for a project. - -:: +Set the minimum required version of cmake for a project and +update `Policy Settings`_ to match the version given:: cmake_minimum_required(VERSION major.minor[.patch[.tweak]] [FATAL_ERROR]) If the current version of CMake is lower than that required it will -stop processing the project and report an error. When a version -higher than 2.4 is specified the command implicitly invokes - -:: - - cmake_policy(VERSION major[.minor[.patch[.tweak]]]) - -which sets the cmake policy version level to the version specified. -When version 2.4 or lower is given the command implicitly invokes - -:: - - cmake_policy(VERSION 2.4) - -which enables compatibility features for CMake 2.4 and lower. +stop processing the project and report an error. The ``FATAL_ERROR`` option is accepted but ignored by CMake 2.6 and higher. It should be specified so CMake versions 2.4 and lower fail @@ -39,3 +24,27 @@ with an error instead of just a warning. Calling ``cmake_minimum_required()`` inside a :command:`function` limits some effects to the function scope when invoked. Such calls should not be made with the intention of having global effects. + +Policy Settings +^^^^^^^^^^^^^^^ + +The ``cmake_minimum_required(VERSION)`` command implicitly invokes the +:command:`cmake_policy(VERSION)` command to specify that the current +project code is written for the given version of CMake. +All policies introduced in the specified version or earlier will be +set to use NEW behavior. All policies introduced after the specified +version will be unset. This effectively requests behavior preferred +as of a given CMake version and tells newer CMake versions to warn +about their new policies. + +When a version higher than 2.4 is specified the command implicitly +invokes:: + + cmake_policy(VERSION major[.minor[.patch[.tweak]]]) + +which sets the cmake policy version level to the version specified. +When version 2.4 or lower is given the command implicitly invokes:: + + cmake_policy(VERSION 2.4) + +which enables compatibility features for CMake 2.4 and lower. diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index 578f85a..73d1142 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -76,6 +76,7 @@ Properties on Directories /prop_dir/VARIABLES /prop_dir/VS_GLOBAL_SECTION_POST_section /prop_dir/VS_GLOBAL_SECTION_PRE_section + /prop_dir/VS_STARTUP_PROJECT .. _`Target Properties`: diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index cb50051..5fd5c5c 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -114,6 +114,7 @@ Variables that Change Behavior /variable/CMAKE_COLOR_MAKEFILE /variable/CMAKE_CONFIGURATION_TYPES /variable/CMAKE_DEBUG_TARGET_PROPERTIES + /variable/CMAKE_DEPENDS_IN_PROJECT_ONLY /variable/CMAKE_DISABLE_FIND_PACKAGE_PackageName /variable/CMAKE_ERROR_DEPRECATED /variable/CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION diff --git a/Help/prop_dir/VS_STARTUP_PROJECT.rst b/Help/prop_dir/VS_STARTUP_PROJECT.rst new file mode 100644 index 0000000..edd4832 --- /dev/null +++ b/Help/prop_dir/VS_STARTUP_PROJECT.rst @@ -0,0 +1,12 @@ +VS_STARTUP_PROJECT +------------------ + +Specify the default startup project in a Visual Studio solution. + +The property must be set to the name of an existing target. This +will cause that project to be listed first in the generated solution +file causing Visual Studio to make it the startup project if the +solution has never been opened before. + +If this property is not specified, then the "ALL_BUILD" project +will be the default. diff --git a/Help/release/dev/cmake-depend-in-project-only.rst b/Help/release/dev/cmake-depend-in-project-only.rst new file mode 100644 index 0000000..8553e80 --- /dev/null +++ b/Help/release/dev/cmake-depend-in-project-only.rst @@ -0,0 +1,6 @@ +cmake-depend-in-project-only +---------------------------- + +* The :ref:`Makefile Generators` learned to optionally limit dependency + scanning only to files in the project source and build trees. + See the :variable:`CMAKE_DEPENDS_IN_PROJECT_ONLY` variable. diff --git a/Help/release/dev/vs-startup-project.rst b/Help/release/dev/vs-startup-project.rst new file mode 100644 index 0000000..f467400 --- /dev/null +++ b/Help/release/dev/vs-startup-project.rst @@ -0,0 +1,6 @@ +vs-startup-project +------------------ + +* The :ref:`Visual Studio Generators` learned to honor a new + :prop_dir:`VS_STARTUP_PROJECT` directory property that specifies + the default startup project for generated solutions (``.sln`` files). diff --git a/Help/variable/CMAKE_DEPENDS_IN_PROJECT_ONLY.rst b/Help/variable/CMAKE_DEPENDS_IN_PROJECT_ONLY.rst new file mode 100644 index 0000000..7179071 --- /dev/null +++ b/Help/variable/CMAKE_DEPENDS_IN_PROJECT_ONLY.rst @@ -0,0 +1,10 @@ +CMAKE_DEPENDS_IN_PROJECT_ONLY +----------------------------- + +When set to ``TRUE`` in a directory, the build system produced by the +:ref:`Makefile Generators` is set up to only consider dependencies on source +files that appear either in the source or in the binary directories. Changes +to source files outside of these directories will not cause rebuilds. + +This should be used carefully in cases where some source files are picked up +through external headers during the build. diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index 728dcdf..9e6083db 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -464,6 +464,8 @@ function(_Boost_GUESS_COMPILER_PREFIX _ret) set(_boost_COMPILER "-bcb") elseif(CMAKE_CXX_COMPILER_ID STREQUAL "SunPro") set(_boost_COMPILER "-sw") + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "XL") + set(_boost_COMPILER "-xlc") elseif (MINGW) if(${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} VERSION_LESS 1.34) set(_boost_COMPILER "-mgw") # no GCC version encoding prior to 1.34 diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 37e2b54..2377831 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 5) -set(CMake_VERSION_PATCH 20160324) +set(CMake_VERSION_PATCH 20160325) #set(CMake_VERSION_RC 1) diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index 8227b82..7b51fdf 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -94,16 +94,34 @@ void cmGlobalVisualStudio71Generator TargetDependSet projectTargets; TargetDependSet originalTargets; this->GetTargetSets(projectTargets, originalTargets, root, generators); - OrderedTargetDependSet orderedProjectTargets(projectTargets, "ALL_BUILD"); + OrderedTargetDependSet orderedProjectTargets( + projectTargets, this->GetStartupProjectName(root)); - this->WriteTargetsToSolution(fout, root, orderedProjectTargets); + // Generate the targets specification to a string. We will put this in + // the actual .sln file later. As a side effect, this method also + // populates the set of folders. + std::ostringstream targetsSlnString; + this->WriteTargetsToSolution(targetsSlnString, root, orderedProjectTargets); + // VS 7 does not support folders specified first. + if (this->GetVersion() <= VS71) + { + fout << targetsSlnString.str(); + } + + // Generate folder specification. bool useFolderProperty = this->UseFolderProperty(); if (useFolderProperty) { this->WriteFolders(fout); } + // Now write the actual target specification content. + if (this->GetVersion() > VS71) + { + fout << targetsSlnString.str(); + } + // Write out the configurations information for the solution fout << "Global\n"; // Write out the configurations for the solution diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 00bb511..04146fb 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -89,19 +89,13 @@ 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: // - if (this->UseFolderProperty()) + if (this->UseFolderProperty() && this->GetVersion() > VS71) { allBuild->SetProperty("FOLDER", this->GetPredefinedTargetsFolder()); } -#endif // Now make all targets depend on the ALL_BUILD target for(std::vector<cmLocalGenerator*>::iterator i = gen.begin(); @@ -519,6 +513,32 @@ cmGlobalVisualStudioGenerator::GetUtilityDepend( } //---------------------------------------------------------------------------- +std::string +cmGlobalVisualStudioGenerator::GetStartupProjectName( + cmLocalGenerator const* root) const +{ + const char* n = root->GetMakefile()->GetProperty("VS_STARTUP_PROJECT"); + if (n && *n) + { + std::string startup = n; + if (this->FindTarget(startup)) + { + return startup; + } + else + { + root->GetMakefile()->IssueMessage( + cmake::AUTHOR_WARNING, + "Directory property VS_STARTUP_PROJECT specifies target " + "'" + startup + "' that does not exist. Ignoring."); + } + } + + // default, if not specified + return this->GetAllTargetName(); +} + +//---------------------------------------------------------------------------- #include <windows.h> //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index ac9111e..723a75f 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -106,6 +106,8 @@ public: void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; + std::string GetStartupProjectName(cmLocalGenerator const* root) const; + void AddSymbolExportCommand( cmGeneratorTarget*, std::vector<cmCustomCommand>& commands, std::string const& configName); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 62fea3d..afdff33 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -34,6 +34,7 @@ #include <cmsys/Terminal.h> #include <queue> +#include <algorithm> //---------------------------------------------------------------------------- // Escape special characters in Makefile dependency lines @@ -1971,6 +1972,57 @@ void cmLocalUnixMakefileGenerator3::ClearDependencies(cmMakefile* mf, } +namespace +{ + // Helper predicate for removing absolute paths that don't point to the + // source or binary directory. It is used when CMAKE_DEPENDS_IN_PROJECT_ONLY + // is set ON, to only consider in-project dependencies during the build. + class NotInProjectDir + { + public: + // Constructor with the source and binary directory's path + NotInProjectDir(const std::string& sourceDir, + const std::string& binaryDir) + : SourceDir(sourceDir), BinaryDir(binaryDir) {} + + // Operator evaluating the predicate + bool operator()(const std::string& path) const + { + // Keep all relative paths: + if(!cmSystemTools::FileIsFullPath(path)) + { + return false; + } + // If it's an absolute path, check if it starts with the source + // direcotory: + return (!(IsInDirectory(SourceDir, path)|| + IsInDirectory(BinaryDir, path))); + } + + private: + // Helper function used by the predicate + static bool IsInDirectory(const std::string& baseDir, + const std::string& testDir) + { + // First check if the test directory "starts with" the base directory: + if (testDir.find(baseDir) != 0) + { + return false; + } + // If it does, then check that it's either the same string, or that the + // next character is a slash: + return ((testDir.size() == baseDir.size())|| + (testDir[baseDir.size()] == '/')); + } + + // The path to the source directory + std::string SourceDir; + // The path to the binary directory + std::string BinaryDir; + }; +} + + void cmLocalUnixMakefileGenerator3 ::WriteDependLanguageInfo(std::ostream& cmakefileStream, cmGeneratorTarget* target) @@ -2058,6 +2110,15 @@ void cmLocalUnixMakefileGenerator3 this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); this->GetIncludeDirectories(includes, target, l->first, config); + if(this->Makefile->IsOn("CMAKE_DEPENDS_IN_PROJECT_ONLY")) + { + const char* sourceDir = this->GetState()->GetSourceDirectory(); + const char* binaryDir = this->GetState()->GetBinaryDirectory(); + std::vector<std::string>::iterator itr = + std::remove_if(includes.begin(), includes.end(), + ::NotInProjectDir(sourceDir, binaryDir)); + includes.erase(itr, includes.end()); + } for(std::vector<std::string>::iterator i = includes.begin(); i != includes.end(); ++i) { diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 1df5cec..aa6f7c8 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2503,15 +2503,22 @@ const char* cmMakefile::GetDefinition(const std::string& name) const cmVariableWatch* vv = this->GetVariableWatch(); if ( vv && !this->SuppressWatches ) { - if ( def ) - { - vv->VariableAccessed(name, cmVariableWatch::VARIABLE_READ_ACCESS, - def, this); - } - else - { + bool const watch_function_executed = vv->VariableAccessed(name, - cmVariableWatch::UNKNOWN_VARIABLE_READ_ACCESS, def, this); + def ? cmVariableWatch::VARIABLE_READ_ACCESS + : cmVariableWatch::UNKNOWN_VARIABLE_READ_ACCESS, + def, this); + + if (watch_function_executed) + { + // A callback was executed and may have caused re-allocation of the + // variable storage. Look it up again for now. + // FIXME: Refactor variable storage to avoid this problem. + def = this->StateSnapshot.GetDefinition(name); + if(!def) + { + def = this->GetState()->GetInitializedCacheValue(name); + } } } #endif diff --git a/Source/cmVariableWatch.cxx b/Source/cmVariableWatch.cxx index 57dde31..a200718 100644 --- a/Source/cmVariableWatch.cxx +++ b/Source/cmVariableWatch.cxx @@ -96,7 +96,7 @@ void cmVariableWatch::RemoveWatch(const std::string& variable, } } -void cmVariableWatch::VariableAccessed(const std::string& variable, +bool cmVariableWatch::VariableAccessed(const std::string& variable, int access_type, const char* newValue, const cmMakefile* mf) const @@ -112,5 +112,7 @@ void cmVariableWatch::VariableAccessed(const std::string& variable, (*it)->Method(variable, access_type, (*it)->ClientData, newValue, mf); } + return true; } + return false; } diff --git a/Source/cmVariableWatch.h b/Source/cmVariableWatch.h index 0ca4a55..2f082af 100644 --- a/Source/cmVariableWatch.h +++ b/Source/cmVariableWatch.h @@ -42,7 +42,7 @@ public: /** * This method is called when variable is accessed */ - void VariableAccessed(const std::string& variable, int access_type, + bool VariableAccessed(const std::string& variable, int access_type, const char* newValue, const cmMakefile* mf) const; /** diff --git a/Tests/RunCMake/BuildDepends/MakeInProjectOnly.c b/Tests/RunCMake/BuildDepends/MakeInProjectOnly.c new file mode 100644 index 0000000..bcb8745 --- /dev/null +++ b/Tests/RunCMake/BuildDepends/MakeInProjectOnly.c @@ -0,0 +1,2 @@ +#include <MakeInProjectOnly.h> +int main() { return MakeInProjectOnly(); } diff --git a/Tests/RunCMake/BuildDepends/MakeInProjectOnly.cmake b/Tests/RunCMake/BuildDepends/MakeInProjectOnly.cmake new file mode 100644 index 0000000..add9aeb --- /dev/null +++ b/Tests/RunCMake/BuildDepends/MakeInProjectOnly.cmake @@ -0,0 +1,16 @@ +enable_language(C) +get_filename_component(include_dir "${CMAKE_BINARY_DIR}" PATH) +include_directories("${include_dir}") +add_executable(MakeInProjectOnly MakeInProjectOnly.c) +set(CMAKE_DEPENDS_IN_PROJECT_ONLY 1) +file(GENERATE OUTPUT check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT " +if (check_step EQUAL 1) + set(check_pairs + \"$<TARGET_FILE:MakeInProjectOnly>|${include_dir}/MakeInProjectOnly.h\" + ) +else() + set(check_pairs + \"${include_dir}/MakeInProjectOnly.h|\$<TARGET_FILE:MakeInProjectOnly>\" + ) +endif() +") diff --git a/Tests/RunCMake/BuildDepends/MakeInProjectOnly.step1.cmake b/Tests/RunCMake/BuildDepends/MakeInProjectOnly.step1.cmake new file mode 100644 index 0000000..d6551ab --- /dev/null +++ b/Tests/RunCMake/BuildDepends/MakeInProjectOnly.step1.cmake @@ -0,0 +1,3 @@ +file(WRITE "${RunCMake_TEST_BINARY_DIR}/../MakeInProjectOnly.h" [[ +int MakeInProjectOnly(void) { return 0; } +]]) diff --git a/Tests/RunCMake/BuildDepends/MakeInProjectOnly.step2.cmake b/Tests/RunCMake/BuildDepends/MakeInProjectOnly.step2.cmake new file mode 100644 index 0000000..145605b --- /dev/null +++ b/Tests/RunCMake/BuildDepends/MakeInProjectOnly.step2.cmake @@ -0,0 +1,3 @@ +file(WRITE "${RunCMake_TEST_BINARY_DIR}/../MakeInProjectOnly.h" [[ +int MakeInProjectOnly(void) { return 1; } +]]) diff --git a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake index 26ffcc0..6b2b85a 100644 --- a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake +++ b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake @@ -41,6 +41,11 @@ endif() run_BuildDepends(Custom-Always) +if(RunCMake_GENERATOR MATCHES "Make" AND + NOT "${RunCMake_BINARY_DIR}" STREQUAL "${RunCMake_SOURCE_DIR}") + run_BuildDepends(MakeInProjectOnly) +endif() + function(run_ReGeneration) # test re-generation of project even if CMakeLists.txt files disappeared diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 048b5e3..d22c39c 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -235,7 +235,10 @@ endif() if("${CMAKE_GENERATOR}" MATCHES "Visual Studio") add_RunCMake_test(include_external_msproject) - add_RunCMake_test(VSSolution) + if("${CMAKE_GENERATOR}" MATCHES "Visual Studio ([789]|10)" AND NOT CMAKE_VS_DEVENV_COMMAND) + set(NO_USE_FOLDERS 1) + endif() + add_RunCMake_test(VSSolution -DNO_USE_FOLDERS=${NO_USE_FOLDERS}) endif() if("${CMAKE_GENERATOR}" MATCHES "Visual Studio ([^789]|[789][0-9])") diff --git a/Tests/RunCMake/VSSolution/RunCMakeTest.cmake b/Tests/RunCMake/VSSolution/RunCMakeTest.cmake index 6ae158d..afd74a1 100644 --- a/Tests/RunCMake/VSSolution/RunCMakeTest.cmake +++ b/Tests/RunCMake/VSSolution/RunCMakeTest.cmake @@ -8,3 +8,9 @@ run_cmake(MorePost) run_cmake(PrePost) run_cmake(Override1) run_cmake(Override2) +run_cmake(StartupProject) +run_cmake(StartupProjectMissing) + +if(RunCMake_GENERATOR MATCHES "Visual Studio ([^7]|[7][0-9])" AND NOT NO_USE_FOLDERS) + run_cmake(StartupProjectUseFolders) +endif() diff --git a/Tests/RunCMake/VSSolution/StartupProject-check.cmake b/Tests/RunCMake/VSSolution/StartupProject-check.cmake new file mode 100644 index 0000000..f36aab2 --- /dev/null +++ b/Tests/RunCMake/VSSolution/StartupProject-check.cmake @@ -0,0 +1,5 @@ +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/StartupProject.cmake b/Tests/RunCMake/VSSolution/StartupProject.cmake new file mode 100644 index 0000000..7192f3d --- /dev/null +++ b/Tests/RunCMake/VSSolution/StartupProject.cmake @@ -0,0 +1,2 @@ +add_custom_target(TestStartup) +set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT "TestStartup") diff --git a/Tests/RunCMake/VSSolution/StartupProjectMissing-check.cmake b/Tests/RunCMake/VSSolution/StartupProjectMissing-check.cmake new file mode 100644 index 0000000..b1017dd --- /dev/null +++ b/Tests/RunCMake/VSSolution/StartupProjectMissing-check.cmake @@ -0,0 +1,5 @@ +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/StartupProjectMissing-stderr.txt b/Tests/RunCMake/VSSolution/StartupProjectMissing-stderr.txt new file mode 100644 index 0000000..da92c6d --- /dev/null +++ b/Tests/RunCMake/VSSolution/StartupProjectMissing-stderr.txt @@ -0,0 +1,4 @@ +^CMake Warning \(dev\) in CMakeLists.txt: + Directory property VS_STARTUP_PROJECT specifies target 'DoesNotExist' that + does not exist. Ignoring. +This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/VSSolution/StartupProjectMissing.cmake b/Tests/RunCMake/VSSolution/StartupProjectMissing.cmake new file mode 100644 index 0000000..907a877 --- /dev/null +++ b/Tests/RunCMake/VSSolution/StartupProjectMissing.cmake @@ -0,0 +1 @@ +set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT "DoesNotExist") 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..8e422a4 --- /dev/null +++ b/Tests/RunCMake/VSSolution/StartupProjectUseFolders.cmake @@ -0,0 +1,3 @@ +add_custom_target(TestStartup) +set_property(GLOBAL PROPERTY USE_FOLDERS ON) +set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT "TestStartup") diff --git a/Tests/RunCMake/VSSolution/solution_parsing.cmake b/Tests/RunCMake/VSSolution/solution_parsing.cmake index dd158ef..4e5bb59 100644 --- a/Tests/RunCMake/VSSolution/solution_parsing.cmake +++ b/Tests/RunCMake/VSSolution/solution_parsing.cmake @@ -50,6 +50,21 @@ macro(parseGlobalSections arg_out_pre arg_out_post testName) endmacro() +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\\(") + 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() + + macro(testGlobalSection prefix sectionName) if(NOT DEFINED ${prefix}_${sectionName}) error("Section ${sectionName} does not exist") |