Skip to content

Fix magic_enum discovery for build-dir CDT_ROOT#43

Closed
heifner wants to merge 1 commit intomasterfrom
fix/magic-enum-build-dir
Closed

Fix magic_enum discovery for build-dir CDT_ROOT#43
heifner wants to merge 1 commit intomasterfrom
fix/magic-enum-build-dir

Conversation

@heifner
Copy link
Copy Markdown
Contributor

@heifner heifner commented Mar 26, 2026

Summary

  • When using a CDT build directory as CDT_ROOT (not an installed prefix), magic_enum headers live under vcpkg_installed/ rather than the top-level include/, causing contract builds to fail with 'magic_enum/magic_enum.hpp' file not found
  • find_cdt_magic_enum now searches both the installed layout (CDT_ROOT/include) and vcpkg build-dir layout (CDT_ROOT/vcpkg_installed/x64-linux/include)
  • Stores the discovered path in a CACHE INTERNAL variable and adds it directly to target include directories, since the WASM toolchain does not propagate INTERFACE_INCLUDE_DIRECTORIES through target_link_libraries
  • Adds magic_enum link for non-interface protobuf targets in target_add_protobuf

When using a CDT build directory as CDT_ROOT (instead of a proper
install prefix), magic_enum headers live under vcpkg_installed/ rather
than the top-level include/. This caused contract builds to fail with
'magic_enum/magic_enum.hpp' file not found.

- Search both installed layout (CDT_ROOT/include) and vcpkg build-dir
  layout (CDT_ROOT/vcpkg_installed/x64-linux/include)
- Store found path in a CACHE INTERNAL variable and add it directly to
  target include directories, since the WASM toolchain does not
  propagate INTERFACE_INCLUDE_DIRECTORIES through target_link_libraries
- Add magic_enum link for non-interface protobuf targets
@heifner heifner requested a review from jglanz March 26, 2026 14:48
Copy link
Copy Markdown
Collaborator

@jglanz jglanz left a comment

Choose a reason for hiding this comment

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

This won't work. The library is required and VCPKG is not available in the CDT toolchain

${CDT_CONTRACT_INCLUDE_PATH}")
if(NOT DEFINED _CDT_MAGIC_ENUM_INCLUDE_DIR)
# Search candidate directories: installed layout, then vcpkg build-dir layout
set(_magic_enum_search_dirs
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Use correct VCPKG variables instead of specifying installed dir and triplet

@heifner
Copy link
Copy Markdown
Contributor Author

heifner commented Mar 26, 2026

Going with a different approach

@heifner heifner closed this Mar 26, 2026
@heifner heifner deleted the fix/magic-enum-build-dir branch March 26, 2026 16:05
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