mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-14 18:51:42 -06:00
committed by
hanna.rusakovich
parent
efed08ac1a
commit
2628c52e04
@@ -36,6 +36,10 @@ The options are:
|
||||
``<name>``. Relative paths are interpreted with respect to the
|
||||
current source directory.
|
||||
|
||||
.. versionadded:: 4.3
|
||||
Arguments to ``FILES`` may use
|
||||
:manual:`generator expressions <cmake-generator-expressions(7)>`.
|
||||
|
||||
``REGULAR_EXPRESSION``
|
||||
Any source file whose name matches the regular expression will
|
||||
be placed in group ``<name>``.
|
||||
|
||||
4
Help/release/dev/source_group-genex.rst
Normal file
4
Help/release/dev/source_group-genex.rst
Normal file
@@ -0,0 +1,4 @@
|
||||
source_group-genex
|
||||
------------------
|
||||
|
||||
* The :command:`source_group` supports generator expressions
|
||||
@@ -1579,6 +1579,12 @@ bool cmGlobalGenerator::Compute()
|
||||
|
||||
this->AddExtraIDETargets();
|
||||
|
||||
#ifndef CMAKE_BOOTSTRAP
|
||||
for (auto const& localGen : this->LocalGenerators) {
|
||||
localGen->ResolveSourceGroupGenex();
|
||||
}
|
||||
#endif
|
||||
|
||||
// Trace the dependencies, after that no custom commands should be added
|
||||
// because their dependencies might not be handled correctly
|
||||
for (auto const& localGen : this->LocalGenerators) {
|
||||
|
||||
@@ -319,6 +319,13 @@ void cmLocalGenerator::TraceDependencies() const
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef CMAKE_BOOTSTRAP
|
||||
void cmLocalGenerator::ResolveSourceGroupGenex()
|
||||
{
|
||||
this->Makefile->ResolveSourceGroupGenex(this);
|
||||
}
|
||||
#endif
|
||||
|
||||
void cmLocalGenerator::GenerateTestFiles()
|
||||
{
|
||||
if (!this->Makefile->IsOn("CMAKE_TESTING_ENABLED")) {
|
||||
|
||||
@@ -84,6 +84,13 @@ public:
|
||||
*/
|
||||
void TraceDependencies() const;
|
||||
|
||||
#ifndef CMAKE_BOOTSTRAP
|
||||
/**
|
||||
* Resolve source group genex.
|
||||
*/
|
||||
void ResolveSourceGroupGenex();
|
||||
#endif
|
||||
|
||||
virtual void AddHelperCommands() {}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2082,6 +2082,14 @@ namespace {
|
||||
}
|
||||
|
||||
#if !defined(CMAKE_BOOTSTRAP)
|
||||
|
||||
void cmMakefile::ResolveSourceGroupGenex(cmLocalGenerator* lg)
|
||||
{
|
||||
for (cmSourceGroup& sourceGroup : this->SourceGroups) {
|
||||
sourceGroup.ResolveGenex(lg, {});
|
||||
}
|
||||
}
|
||||
|
||||
cmSourceGroup* cmMakefile::GetSourceGroup(
|
||||
std::vector<std::string> const& name) const
|
||||
{
|
||||
|
||||
@@ -612,6 +612,12 @@ public:
|
||||
bool CanIWriteThisFile(std::string const& fileName) const;
|
||||
|
||||
#if !defined(CMAKE_BOOTSTRAP)
|
||||
|
||||
/**
|
||||
* Resolve source group genex.
|
||||
*/
|
||||
void ResolveSourceGroupGenex(cmLocalGenerator* lg);
|
||||
|
||||
/**
|
||||
* Get the vector source groups.
|
||||
*/
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
|
||||
#include <cm/memory>
|
||||
|
||||
#include "cmGeneratorExpression.h"
|
||||
#include "cmSourceFile.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
|
||||
class cmSourceGroupInternals
|
||||
@@ -59,6 +61,26 @@ void cmSourceGroup::SetGroupRegex(char const* regex)
|
||||
}
|
||||
}
|
||||
|
||||
void cmSourceGroup::ResolveGenex(cmLocalGenerator* lg,
|
||||
std::string const& config)
|
||||
{
|
||||
std::set<std::string> files;
|
||||
|
||||
for (std::string const& file : this->GroupFiles) {
|
||||
files.emplace(cmGeneratorExpression::Evaluate(file, lg, config));
|
||||
}
|
||||
|
||||
this->GroupFiles = std::move(files);
|
||||
|
||||
if (!this->Internal) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (cmSourceGroup& group : this->Internal->GroupChildren) {
|
||||
group.ResolveGenex(lg, config);
|
||||
}
|
||||
}
|
||||
|
||||
void cmSourceGroup::AddGroupFile(std::string const& name)
|
||||
{
|
||||
this->GroupFiles.insert(name);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "cmsys/RegularExpression.hxx"
|
||||
|
||||
class cmLocalGenerator;
|
||||
class cmSourceFile;
|
||||
class cmSourceGroupInternals;
|
||||
|
||||
@@ -38,6 +39,11 @@ public:
|
||||
*/
|
||||
void SetGroupRegex(char const* regex);
|
||||
|
||||
/**
|
||||
* Resolve genex.
|
||||
*/
|
||||
void ResolveGenex(cmLocalGenerator* lg, std::string const& config);
|
||||
|
||||
/**
|
||||
* Add a file name to the explicit list of files for this group.
|
||||
*/
|
||||
|
||||
@@ -21,6 +21,7 @@ run_cmake(RuntimeLibrary)
|
||||
run_cmake(SourceGroupCMakeLists)
|
||||
run_cmake(SourceGroupTreeCMakeLists)
|
||||
run_cmake(SourceGroupFileSet)
|
||||
run_cmake(SourceGroupFileSetGenex)
|
||||
run_cmake(VsConfigurationType)
|
||||
run_cmake(VsTargetsFileReferences)
|
||||
run_cmake(VsCustomProps)
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
set(vcFiltersFile "${RunCMake_TEST_BINARY_DIR}/SourceGroupFileSetGenex.vcxproj.filters")
|
||||
if(NOT EXISTS "${vcFiltersFile}")
|
||||
set(RunCMake_TEST_FAILED "Filters file ${vcFiltersFile} does not exist.")
|
||||
return()
|
||||
endif()
|
||||
|
||||
file(STRINGS "${vcFiltersFile}" lines)
|
||||
|
||||
include(${RunCMake_TEST_SOURCE_DIR}/SourceGroupHelpers.cmake)
|
||||
|
||||
find_source_group("${lines}" "Header Files\\SourceGroupFileSetGenex")
|
||||
3
Tests/RunCMake/VS10Project/SourceGroupFileSetGenex.cmake
Normal file
3
Tests/RunCMake/VS10Project/SourceGroupFileSetGenex.cmake
Normal file
@@ -0,0 +1,3 @@
|
||||
add_library(SourceGroupFileSetGenex INTERFACE)
|
||||
target_sources(SourceGroupFileSetGenex PUBLIC FILE_SET HEADERS FILES "$<$<BOOL:TRUE>:iface.h>")
|
||||
source_group("Header Files/SourceGroupFileSetGenex" FILES "$<$<BOOL:TRUE>:iface.h>")
|
||||
Reference in New Issue
Block a user