Skip to content

STDEXEC_MAIN_PROJECT always OFF — install targets never run, breaking Conan packaging #1938

@solarispika

Description

@solarispika

Description

Commit c9a1dc5 introduced STDEXEC_MAIN_PROJECT and STDEXEC_INSTALL to make install targets opt-out when stdexec is used as a subproject. The intent is correct, but the top-level project detection has a bug that causes STDEXEC_INSTALL to always be OFF, so cmake --install copies nothing.

Root Cause

The detection logic in CMakeLists.txt:

if (NOT DEFINED STDEXEC_MAIN_PROJECT)
  set(STDEXEC_MAIN_PROJECT OFF)
  if (NOT DEFINED PROJECT_NAME)
    set(STDEXEC_MAIN_PROJECT ON)
  endif ()
endif ()

This check runs after project(STDEXEC ...) has already been called. At that point PROJECT_NAME is always defined as "STDEXEC", so the NOT DEFINED PROJECT_NAME branch is never taken and STDEXEC_MAIN_PROJECT is always OFF.

As a result STDEXEC_INSTALL defaults to OFF and all install() rules are skipped — even when stdexec is the top-level project.

Impact

Conan's package() step calls cmake --install, which now installs nothing. Headers are not copied into the package, making the Conan package broken.

Suggested Fix

Use the standard CMake idiom to detect top-level project instead:

if (NOT DEFINED STDEXEC_MAIN_PROJECT)
  if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
    set(STDEXEC_MAIN_PROJECT ON)
  else()
    set(STDEXEC_MAIN_PROJECT OFF)
  endif()
endif()

Or equivalently, move the PROJECT_NAME check to before the project() call.

cc @mathisloge — could you take a look? You may have a better sense of the intended behavior here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions