Skip to content

ENH: Add NO_SOURCE_GROUPS option to ctkBuild macros - #1447

Open
kislinsk wants to merge 1 commit into
commontk:masterfrom
MITK:add-no-source-groups-option
Open

ENH: Add NO_SOURCE_GROUPS option to ctkBuild macros#1447
kislinsk wants to merge 1 commit into
commontk:masterfrom
MITK:add-no-source-groups-option

Conversation

@kislinsk

Copy link
Copy Markdown
Contributor

Disclaimer: We (MITK) are currently catching up on the latest CTK master branch
since we forked for Qt 6 back in 2023. We found a few bugs that are not caught by
your CI and mostly affect external users of CTK.

Adds an opt-out so a consumer can apply its own source_group() layout.
Without it, CTK's source_group("Resources" ...) and
source_group("Generated" ...) override the grouping the consumer set up
before calling the macro.

Note this is currently a hard break rather than a cosmetic one for consumers
that already pass the flag: CtkMacroParseArguments appends an unrecognised
token to the preceding named argument's list, so passing NO_SOURCE_GROUPS
after OUTPUT_DIR <dir> silently yields MY_OUTPUT_DIR=<dir>;NO_SOURCE_GROUPS
and the plug-in lands in a bogus directory.

Applied to all four macros (ctkMacroBuildApp, ctkMacroBuildLib,
ctkMacroBuildPlugin, ctkMacroBuildQtPlugin) for consistency.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a NO_SOURCE_GROUPS opt-out across CTK’s build macros so external consumers can keep their own source_group() layout without CTK overriding it, and ensures the flag is properly parsed (avoiding it being accidentally appended to a preceding named argument like OUTPUT_DIR).

Changes:

  • Recognize NO_SOURCE_GROUPS as a supported option in all four build macros’ argument parsing.
  • Guard source_group("Resources" ...) (and source_group("Generated" ...) in the plugin macro) behind if(NOT MY_NO_SOURCE_GROUPS).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
CMake/ctkMacroBuildQtPlugin.cmake Adds NO_SOURCE_GROUPS option parsing and skips CTK resource grouping when requested.
CMake/ctkMacroBuildPlugin.cmake Adds NO_SOURCE_GROUPS option parsing and conditionally disables both Resources/Generated group assignments.
CMake/ctkMacroBuildLib.cmake Adds NO_SOURCE_GROUPS option parsing and conditionally disables Resources grouping.
CMake/ctkMacroBuildApp.cmake Adds NO_SOURCE_GROUPS option parsing and conditionally disables Resources grouping.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lassoan lassoan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good, I have just one general question (and a minor comment inline): Do you really want to specify NO_SOURCE_GROUPS manually for every call of all these macros? If a CTK_NO_SOURCE_GROUPS CMake option was introduced that set the desired behavior globally, then all the callers could be left unchanged.

PLUGIN_DIR designer
${ARGN})
cmake_parse_arguments(MY
"" # no options

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to be consistent then include all arguments (including NO_SOURCE_GROUPS) here; or just do the minimum (only list NAME, as nothing else is used here).

ctkMacroBuildApp, ctkMacroBuildLib, ctkMacroBuildPlugin and
ctkMacroBuildQtPlugin call source_group() to categorize resources and
generated files. A project that embeds these macros and organizes its
sources itself cannot keep its own layout, because the calls inside the
macros run after the caller's and take precedence.

Guard them with a CTK_NO_SOURCE_GROUPS option, so such a project can opt
out centrally instead of passing an argument at every call site.
@kislinsk
kislinsk force-pushed the add-no-source-groups-option branch from f59c778 to 498beb9 Compare July 25, 2026 19:52
@kislinsk

Copy link
Copy Markdown
Contributor Author

You're right. We are using the macro(s) only in our own wrapper macro(s) so we do not need to specify the arguments over and over again, but the global solution is more elegant. I amended the commit accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants