-
Notifications
You must be signed in to change notification settings - Fork 5
EDGEML-14581 - Fix copy_headers to use build-time GLOB via cmake -P #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| ############################################################################### | ||
| # Copyright (C) 2022-2026 Advanced Micro Devices, Inc. All rights reserved. | ||
| # SPDX-License-Identifier: MIT | ||
| ############################################################################### | ||
| # Build-time script: invoked via cmake -P by the copy_headers custom target. | ||
| # Runs GLOB at build time so that paths are resolved fresh on each build rather | ||
| # than being baked into generated build rules at configure time. | ||
| # | ||
| # Expected variables (passed via -D on the cmake -P command line): | ||
| # SRC_DIR - aie-codegen/src source directory | ||
| # REGDB_DIR - aie-regdb/globalparams source directory | ||
| # DST_DIR - destination include/aie_codegen_inc directory | ||
|
|
||
| foreach(_var SRC_DIR REGDB_DIR DST_DIR) | ||
| if(NOT DEFINED ${_var}) | ||
| message(FATAL_ERROR "CopyHeaders.cmake: required variable ${_var} is not defined") | ||
| endif() | ||
| endforeach() | ||
|
|
||
| foreach(_dir SRC_DIR REGDB_DIR) | ||
| if(NOT IS_DIRECTORY "${${_dir}}") | ||
| message(WARNING "CopyHeaders.cmake: ${_dir}=\"${${_dir}}\" is not a directory; " | ||
| "headers from this location will be missing. " | ||
| "Is the submodule initialized?") | ||
| endif() | ||
| endforeach() | ||
|
|
||
| # Reuse the canonical header-dir list from AieCodegenHeaders.cmake so that | ||
| # build-time copies and install-time copies always cover exactly the same set. | ||
| include("${CMAKE_CURRENT_LIST_DIR}/AieCodegenHeaders.cmake") | ||
|
|
||
| set(_hdrs "") | ||
| foreach(_dir IN LISTS _AIE_CODEGEN_HEADER_DIRS) | ||
| file(GLOB _dir_hdrs "${SRC_DIR}/${_dir}/*.h") | ||
| list(APPEND _hdrs ${_dir_hdrs}) | ||
| endforeach() | ||
| file(GLOB _regdb_hdrs "${REGDB_DIR}/*.h") | ||
| list(APPEND _hdrs ${_regdb_hdrs}) | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is now a second definition of "which headers are public" — AieCodegenHeaders.cmake still owns _AIE_CODEGEN_HEADER_DIRS and still drives the install path. They match today (I Can we reuse the existing list? include("${CMAKE_CURRENT_LIST_DIR}/AieCodegenHeaders.cmake") Use the variable, not aie_codegen_collect_headers() — that reads CMAKE_CURRENT_SOURCE_DIR, which is wrong under cmake -P. Keeping the recursive glob is fine too, as long as the install |
||
| foreach(_hdr IN LISTS _hdrs) | ||
| get_filename_component(_name "${_hdr}" NAME) | ||
| file(COPY_FILE "${_hdr}" "${DST_DIR}/${_name}" ONLY_IF_DIFFERENT) | ||
| endforeach() | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this also check the dirs exist, not just that the vars are defined? aie-regdb is often an uninitialized submodule; when it's missing the GLOB silently returns nothing and you get a
confusing missing-header error later. A message(WARNING) on NOT IS_DIRECTORY would do.