mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-22 22:31:18 -05:00
Merge topic 'source_group_forward_slashes'
faf44a8cdb source_group: Support forward slashes in group hierarchy
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4727
This commit is contained in:
@@ -37,11 +37,13 @@ explicitly lists the file with ``FILES`` will be favored, if any.
|
||||
If no group explicitly lists the file, the *last* group whose
|
||||
regular expression matches the file will be favored.
|
||||
|
||||
The ``<name>`` of the group and ``<prefix>`` argument may contain backslashes
|
||||
to specify subgroups:
|
||||
The ``<name>`` of the group and ``<prefix>`` argument may contain forward
|
||||
slashes or backslashes to specify subgroups. Backslashes need to be escaped
|
||||
appropriately:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
source_group(base/subdir ...)
|
||||
source_group(outer\\inner ...)
|
||||
source_group(TREE <root> PREFIX sources\\inc ...)
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
source_group_forward_slashes
|
||||
----------------------------
|
||||
|
||||
* The :command:`source_group` command now also recognizes forward slashes
|
||||
as subgroup delimiters, not just backslashes.
|
||||
@@ -2404,11 +2404,11 @@ cmSourceGroup* cmMakefile::GetOrCreateSourceGroup(
|
||||
|
||||
cmSourceGroup* cmMakefile::GetOrCreateSourceGroup(const std::string& name)
|
||||
{
|
||||
const char* delimiter = this->GetDefinition("SOURCE_GROUP_DELIMITER");
|
||||
if (delimiter == nullptr) {
|
||||
delimiter = "\\";
|
||||
const char* delimiters = this->GetDefinition("SOURCE_GROUP_DELIMITER");
|
||||
if (delimiters == nullptr) {
|
||||
delimiters = "/\\";
|
||||
}
|
||||
return this->GetOrCreateSourceGroup(cmTokenize(name, delimiter));
|
||||
return this->GetOrCreateSourceGroup(cmTokenize(name, delimiters));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,6 +30,9 @@ source_group(Base\\Sub1\\Base FILES bar.c)
|
||||
# a group without files, is currently not created
|
||||
source_group(EmptyGroup)
|
||||
|
||||
# Forward slashes can be delimiters too
|
||||
source_group(Base/Nested FILES nested.c)
|
||||
|
||||
set(root ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
set(tree_files_without_prefix ${root}/sub1/tree_bar.c
|
||||
@@ -58,4 +61,5 @@ source_group(PREFIX "" FILES ${tree_files_with_empty_prefix} TREE ${root})
|
||||
|
||||
add_executable(SourceGroups main.c bar.c foo.c sub1/foo.c sub1/foobar.c baz.c
|
||||
${tree_files_with_prefix} ${tree_files_without_prefix}
|
||||
${tree_files_with_empty_prefix} README.txt)
|
||||
${tree_files_with_empty_prefix} README.txt
|
||||
nested.c)
|
||||
|
||||
@@ -12,6 +12,7 @@ extern int tree_empty_prefix_bar(void);
|
||||
extern int tree_bar(void);
|
||||
extern int tree_foobar(void);
|
||||
extern int tree_baz(void);
|
||||
extern int nested(void);
|
||||
|
||||
int main()
|
||||
{
|
||||
@@ -23,5 +24,8 @@ int main()
|
||||
"tree_empty_prefix_bar: %d\n",
|
||||
tree_prefix_foo(), tree_prefix_bar(), tree_bar(), tree_foobar(),
|
||||
tree_baz(), tree_empty_prefix_foo(), tree_empty_prefix_bar());
|
||||
|
||||
printf("nested: %d\n", nested());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
int nested(void)
|
||||
{
|
||||
return 123;
|
||||
}
|
||||
Reference in New Issue
Block a user