Skip to content

CMake: detect_MADNESS_configuration() fails against MADNESS >= 48dc6494b (MADmisc genex leaks into try_compile) #576

Description

@evaleev

Summary

detect_MADNESS_configuration() fails to configure against any MADNESS newer than
48dc6494b
(Aug 21 2026). It copies MADworld's INTERFACE_INCLUDE_DIRECTORIES verbatim into
CMAKE_REQUIRED_INCLUDES and then runs CHECK_CXX_SOURCE_COMPILES, but that property now
contains an unevaluated generator expression naming a MADNESS target. try_compile()
generates a standalone project in which no MADNESS target exists, so the expression is a
hard error there rather than an include path.

This does not affect the currently pinned TA_TRACKED_MADNESS_TAG (666765ca6, May 21
2026), which predates the MADNESS change — it bites anyone pointing
FETCHCONTENT_SOURCE_DIR_MADNESS at a current MADNESS checkout, and it will block the next
pin bump.

Reproducer

cmake -S . -B build \
  -DFETCHCONTENT_SOURCE_DIR_MADNESS=<a MADNESS checkout at or after 48dc6494b> \
  ...
-- Performing Test MADNESS_HAS_TBB
CMake Error at build/CMakeFiles/CMakeScratch/TryCompile-SE5mo9/CMakeLists.txt:11 (include_directories):
  Error evaluating generator expression:

    $<TARGET_PROPERTY:MADmisc,INTERFACE_INCLUDE_DIRECTORIES>

  Target "MADmisc" not found.

CMake Error at .../Internal/CheckSourceCompiles.cmake:104 (try_compile):
  Failed to generate test project build system.
Call Stack (most recent call first):
  .../CheckCXXSourceCompiles.cmake:58 (cmake_check_source_compiles)
  cmake/modules/DetectMADNESSConfig.cmake:27 (CHECK_CXX_SOURCE_COMPILES)
  CMakeLists.txt:347 (detect_MADNESS_configuration)

-- Configuring incomplete, errors occurred!

Reproduces on both MADNESS_TASK_BACKEND=Pthreads and PaRSEC.

Cause

MADNESS 48dc6494b ("misc: make it a leaf component so world can depend on it") inverted
the previously cyclic misc/world edge:

-add_mad_library(world MADWORLD_SOURCES MADWORLD_HEADERS "common;${ELEMENTAL_PACKAGE_NAME}" "madness/world")
+add_mad_library(world MADWORLD_SOURCES MADWORLD_HEADERS "misc;common;${ELEMENTAL_PACKAGE_NAME}" "madness/world")

add_mad_library propagates a dependency's include dirs as an unevaluated generator
expression (MADNESS cmake/modules/AddMADLibrary.cmake):

if(TARGET ${deptargetname})
    target_include_directories(${targetname} PUBLIC
        $<TARGET_PROPERTY:${deptargetname},INTERFACE_INCLUDE_DIRECTORIES>)

so MADworld's INTERFACE_INCLUDE_DIRECTORIES now literally contains the string
$<TARGET_PROPERTY:MADmisc,INTERFACE_INCLUDE_DIRECTORIES>.

That injection is guarded by if(TARGET MAD${_dep}), and misc is the first MAD*
library target world has ever depended on
common has no MADcommon target
anywhere, so it was silently skipped. That is why this only surfaces now.

Note the MADNESS change is not itself at fault: it explicitly handles
MADNESS_BUILD_MADWORLD_ONLY=ON ("because MADworld links it,
MADNESS_BUILD_MADWORLD_ONLY=ON now configures, builds and installs MADmisc"), and
MADmisc is defined in TA's configuration. The failure is purely that a generator
expression cannot survive into a try_compile sub-project.

Suggested fix

TA already carries an ad-hoc version of this workaround in the same macro — an
if (TARGET El) branch that strips El-matching entries, i.e. a one-off patch for exactly
this hazard. Generalize it: drop every entry containing $< before it reaches
CMAKE_REQUIRED_INCLUDES. A generator expression is never a usable include path in a
try_compile, and the plain directories that remain are what the madness/config.h probe
actually needs.

This also subsumes the El special case (those entries are genexes too) and is more
precise than a substring match on El, which would drop a legitimate path containing
those letters.

Activity

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

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