Skip to content

Add setting "preConfigureTask"#4960

Open
erdemiru wants to merge 2 commits into
microsoft:mainfrom
erdemiru:main
Open

Add setting "preConfigureTask"#4960
erdemiru wants to merge 2 commits into
microsoft:mainfrom
erdemiru:main

Conversation

@erdemiru
Copy link
Copy Markdown

@erdemiru erdemiru commented Jun 3, 2026

This changes introduce a new feature

The following changes are proposed:

  • Add a new setting "preConfigureTask"
    • If set, the task bearing the name set is called before CMake configure run.

The purpose of this change

The purpose of this change is to enable users to set up tasks before CMake configuration, allowing for greater automation. This is particularly useful when external tools are required to generate source code and CMake files before the cmake configure stage.

Other Notes/Information

While pre-build and post-configure tasks are already supported, they are insufficient when additional tools are needed to generate CMake files. In my use case, toolchain flags, such as included paths, libraries and also list of generated source files are all based on input JSON or XML configuration files. Using execute_process() or custom commands have many other drawbacks in such cases:

  • file(GLOB ) has to used in configure time since the list of generated files are dynamic based on the xml input.
  • when included cmake files are updated by the external tool, re-configure has to be triggered.
  • ...

@erdemiru
Copy link
Copy Markdown
Author

erdemiru commented Jun 3, 2026

@microsoft-github-policy-service agree company="QualCode"

Copy link
Copy Markdown

@jonahgraham jonahgraham left a comment

Choose a reason for hiding this comment

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

FWIW I approve of this as I think it resolves #2449 too.

IIUC It leaves one small side-effect. If people have done the workaround suggested in #2449 (comment) then if those users apply this change and leave pre run task on, and run the configure as a task, the pre configure task will run twice. If my understanding is correct, then the release notes may want to point this out.

Comment thread package.nls.json Outdated
"cmake-tools.configuration.cmake.emscriptenSearchDirs.description": "Directories where Emscripten may be installed.",
"cmake-tools.configuration.cmake.mergedCompileCommands.description": "Recursively collect and merge all compile_commands.json found in the cmake.buildDirectory.",
"cmake-tools.configuration.cmake.copyCompileCommands.description": "Copy compile_commands.json to this location after a successful configure.",
"cmake-tools.configuration.cmake.preConfigureTask.description": "If set, this named task will be executed before a successful CMake configure.",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I don't think the preConfigureTask is conditional on the configure being successful.

Suggested change
"cmake-tools.configuration.cmake.preConfigureTask.description": "If set, this named task will be executed before a successful CMake configure.",
"cmake-tools.configuration.cmake.preConfigureTask.description": "If set, this named task will be executed before CMake configure.",

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks @jonahgraham, I've updated the wording with your suggestions.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants