Skip to content

Add STDEXEC_MAIN_PROJECT and STDEXEC_INSTALL to CMake#1931

Open
mathisloge wants to merge 3 commits intoNVIDIA:mainfrom
mathisloge:patch-3
Open

Add STDEXEC_MAIN_PROJECT and STDEXEC_INSTALL to CMake#1931
mathisloge wants to merge 3 commits intoNVIDIA:mainfrom
mathisloge:patch-3

Conversation

@mathisloge
Copy link
Contributor

@mathisloge mathisloge commented Mar 13, 2026

It is common practice to be able to disable install targets because they can conflict with in-tree builds (for example when stdexec is added via CPM).

Most projects use a top-level project check to enable installs by default when stdexec is the main project and otherwise disable them. I've applied the same pattern here and also replaced the remaining BUILD_TESTING usages with STDEXEC_BUILD_TESTS.

  • Disable install/export targets by default; enable only when stdexec is the top-level project.
  • Add STDEXEC_MAIN_PROJECT and STDEXEC_INSTALL.
  • Replace remaining BUILD_TESTING with STDEXEC_BUILD_TESTS.
  • Conditionally install asioexec, tbbexec, etc., to avoid conflicts when used as a dependency.

At least resolves my pain with the install targets when pulling stdexec via CPM/FetchContent or add_subdirectory.

@copy-pr-bot
Copy link

copy-pr-bot bot commented Mar 13, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Copy link
Collaborator

@ericniebler ericniebler left a comment

Choose a reason for hiding this comment

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

this looks good. just one comment.

# CMake project, unless they explicitly set STDEXEC_BUILD_TESTS=TRUE,
# or they enabled CTest's BUILD_TESTING option
if ((CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) OR BUILD_TESTING)
if (STDEXEC_MAIN_PROJECT OR BUILD_TESTING)
Copy link
Collaborator

Choose a reason for hiding this comment

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

did you say you were replacing uses of BUILD_TESTING?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yeah, that was one question I wanted to ask:
I wanted to add STDEXEC_MAIN_PROJECT AND BUILD_TESTING (changed OR -> AND) to have the following behavior:

if STDEXEC_MAIN_PROJECT then use BUILD_TESTING as a default value of STDEXEC_BUILD_TESTS
if not STDEXEC_MAIN_PROJECT default to FALSE as a default value of STDEXEC_BUILD_TESTS.

Therefore if using stdexec as a top level project, you could either use BUILD_TESTING or STDEXEC_BUILD_TESTS and for cases where stdexec is used as a subproject one have to use STDEXEC_BUILD_TESTS to enable tests.

Would that be an accaptable default behavior?

Copy link
Collaborator

Choose a reason for hiding this comment

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

sounds good to me.

@ericniebler
Copy link
Collaborator

/ok to test b9a585f

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.

2 participants