Skip to content

Cmake improvements#98

Open
Marco Liebel (quic-mliebel) wants to merge 14 commits into
qualcomm:mainfrom
quic-mliebel:cmake-improvements
Open

Cmake improvements#98
Marco Liebel (quic-mliebel) wants to merge 14 commits into
qualcomm:mainfrom
quic-mliebel:cmake-improvements

Conversation

@quic-mliebel

Copy link
Copy Markdown
Contributor

The main goal of this MR is to enable the use of Qbox with find_package(qbox). The hello-qbox example demonstrates how to do it.

Extract elf_loader into its own header/.cc so all libelf types and
includes live in the .cc only; loader.h delegates elf_load() to
gs::elf_loader. Move the libelf include dir to PRIVATE. This lets
libelf become a PRIVATE dependency, needed for find_package(qbox).

Signed-off-by: Marco Liebel <marco.liebel@oss.qualcomm.com>
Extract zip_extract/zip_extract_nested plus a zip_open_from_memory
helper into zip_loader.{h,cc}; public headers see only an opaque
zip_t* forward decl. Move json_zip_archive into reg_model_maker.cc
and route smmuv3/smmu500 through zip_open_from_memory. loader.h keeps
a zip_t* handle so in-memory (INCBIN) archives are read from the live
handle. Lets libzip become PRIVATE, needed for find_package(qbox).

Add gs_memory/router/reg_router BUILD_INTERFACE include dirs to
compile reg_model_maker.cc in-tree.

Signed-off-by: Marco Liebel <marco.liebel@oss.qualcomm.com>
With zip.h and libelf.h no longer in public headers, move zip, libelf,
Threads, pybind11, and dl to PRIVATE on qbox. rpc and Crow stay PUBLIC
for now (pass, monitor, char_backend_socket inherit them transitively);
they move to PRIVATE in the next commit. The pass and monitor plugins
link rpc and Crow explicitly since they use them directly.

Signed-off-by: Marco Liebel <marco.liebel@oss.qualcomm.com>
Drop the PackageProject.cmake dependency. Use CMake's built-in
configure_package_config_file, write_basic_package_version_file, and
install(EXPORT) to generate a qbox:: namespaced package config.
qboxConfig.cmake.in calls find_dependency for all public deps; Lua is
exported in the same export set.

Move rpc and Crow to PRIVATE on qbox. Targets that need them link
explicitly: pass->rpc, monitor->Crow, char_backend_socket gets an
asio::asio guard, and test targets link gtest/gmock directly.

Signed-off-by: Marco Liebel <marco.liebel@oss.qualcomm.com>
Convert hello-qbox to a standalone project demonstrating external
consumption of qbox via find_package(qbox) + qbox::qbox. Remove it
from the main build tree and fix INSTALL_INTERFACE paths to match the
install layout. A CI job builds and runs it against an installed Qbox.

Signed-off-by: Marco Liebel <marco.liebel@oss.qualcomm.com>
char_backend_socket includes <asio.hpp> but had no explicit asio dep;
it worked via Crow's transitive PUBLIC linkage. Moving Crow to PRIVATE
broke this on macOS. Link asio::asio if present, else find_path (with
Homebrew hints) and apply the include dir, ASIO_STANDALONE, and
Threads. Linkage is PUBLIC since the header includes <asio.hpp>.

Signed-off-by: Marco Liebel <marco.liebel@oss.qualcomm.com>
Remove the duplicate gs_addexpackage for rpclib introduced when
PackageProject.cmake was deleted; rpclib is already fetched below.
Drop the dead EXPORT qqvpTargets from the dynmod install (no matching
install(EXPORT) exists; dynmods are runtime-loaded plugins) and the
COMPONENT names referencing the undefined LIBRARY_NAME.

Signed-off-by: Marco Liebel <marco.liebel@oss.qualcomm.com>
The qemu-components install interface used an absolute
${CMAKE_INSTALL_PREFIX} path, leaking a non-relocatable path into
qboxTargets.cmake and pointing consumers at the install root instead
of the qemu include dir. Use a relative path so it resolves to
${_IMPORT_PREFIX}/qemu-components/common/include.

Signed-off-by: Marco Liebel <marco.liebel@oss.qualcomm.com>
Installed qbox headers transitively include <glib.h>, but neither
qbox's exported interface nor libqemu carried glib's include dir;
in-tree builds only worked via a BUILD_INTERFACE glib shim. External
find_package(qbox) consumers failed with 'glib.h: No such file'.
Discover glib-2.0 via pkg-config, link PkgConfig::GLIB PUBLIC, and
recreate the imported target in qboxConfig.cmake. The shim is retained
for in-tree builds.

Signed-off-by: Marco Liebel <marco.liebel@oss.qualcomm.com>
Platform configs locate sibling files (firmware images, nested
configs) relative to their own Lua chunk source, but a config
passed to --gs_luafile as a bare filename had no directory in that
source, so those lookups broke and the run crashed. Normalize the
path to absolute before luaL_loadfile so a config works the same
however its path is spelled.

Signed-off-by: Marco Liebel <marco.liebel@oss.qualcomm.com>
The project declared CMAKE_CXX_STANDARD 14, but SystemC propagates
cxx_std_17 via PUBLIC linkage, so Qbox silently built as C++17
regardless. The declared standard was misleading and a consumer
could not rely on it. Declare 17 to match reality, and update the
README accordingly.

Signed-off-by: Marco Liebel <marco.liebel@oss.qualcomm.com>
The example became a standalone find_package(qbox) consumer, but
the README still described the old in-tree build, so anyone following
it would use paths that no longer exist and fail to build or run.
Document the install-then-configure workflow, and correct the
manual-firmware note that implied firmware could be built on its own.

Signed-off-by: Marco Liebel <marco.liebel@oss.qualcomm.com>
@markfoodyburton

Copy link
Copy Markdown
Contributor

looks amazing, but - some of it is quite involved, do we need to do an online session on it?

The standalone hello-qbox consumer path was left untested when the
GitLab CI was removed, so a broken find_package(qbox) or install
layout would go unnoticed. Install and archive the existing Ubuntu
GCC matrix build, then consume that artifact in a dependent job that
builds the example and checks its guest output, without rebuilding
qbox. The installed package resolves its libraries and runtime-loaded
plugins via relocatable RPATH, so no library path override is needed.

Signed-off-by: Marco Liebel <marco.liebel@oss.qualcomm.com>
Keystone 0.9.2 vendors an old LLVM that still derives from
std::unary_function and std::binary_function. The project-wide C++17
requirement removes those declarations under libc++, breaking the macOS
and Windows clang builds while libstdc++ continues to provide them.

Enable libc++'s narrow compatibility escape hatch only while adding the
keystone CPM subproject. This keeps qbox and keystone in C++17 mode and
prevents the workaround from reaching later test targets. Remove the
stopgap with the in-flight keystone removal.

Signed-off-by: Marco Liebel <marco.liebel@oss.qualcomm.com>

- name: Upload qbox install tree
if: matrix.os == 'ubuntu-24.04' && matrix.preset == 'gcc'
uses: actions/upload-artifact@v4
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v4
sudo apt-get install -y gcc-aarch64-linux-gnu

- name: Download qbox install tree
uses: actions/download-artifact@v4
Comment thread tests/qbox/CMakeLists.txt
# C++17 mode. Enable libc++'s compatibility hatch for keystone only.
# Remove together with keystone (in-flight removal).
add_compile_definitions(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
cpmfindpackage(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Keystone retirement is planned here: #57

Comment thread CMakeLists.txt
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBELF REQUIRED IMPORTED_TARGET libelf)
pkg_check_modules(LIBZIP REQUIRED IMPORTED_TARGET libzip)
pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is glib required for headers?
Maybe Alwalid Salama (@alwalidsalama) can provide more info.

Comment thread cmake/boilerplate.cmake
################################################################################

# ----- configure include paths and EXPORT PROJECT
macro(gs_export)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

gs_export is also used by QQVP.
We should also update QQVP to cope with this change.

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.

5 participants