Skip to content
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

Miscellaneous changes to support in-tree builds. #185

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

stellaraccident
Copy link
Contributor

  • Conditions find_package hsakmt on the pressence of the target.
  • Move finding of clang/llvm-objcopy to a common place and use an in-tree target if available.
  • Add options for depending on in-tree device libs.

This is a roll-up of changes that I needed to do in order to build ROCR-Runtime with other parts of the toolkit. In my final arrangement, I am only using the first point, but I believe the second/third are general improvements -- so including those as well.

* Conditions find_package hsakmt on the pressence of the target.
* Move finding of clang/llvm-objcopy to a common place and use an in-tree target if available.
* Add options for depending on in-tree device libs.

This is a roll-up of changes that I needed to do in order to build ROCR-Runtime with other parts of the toolkit. In my final arrangement, I am only using the first point, but I believe the second/third are general improvements -- so including those as well.
if(TARGET hsakmt::hsakmt)
message(STATUS "Using build dep on hsakmt")
else()
find_package(hsakmt 1.0 REQUIRED HINTS ${CMAKE_INSTALL_PREFIX} PATHS /opt/rocm)
Copy link

Choose a reason for hiding this comment

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

The find_package should be disabled by the superproject either by using the OVERRIDE_FIND_PACKAGE in FetchContent_Declare or by using the register_source_package function as described here:

function(register_source_package NAME)
  file(WRITE "${CMAKE_BINARY_DIR}/__pkg/${NAME}/${NAME}Config.cmake" "")
  set(${NAME}_DIR ${CMAKE_BINARY_DIR}/__pkg/${NAME} CACHE PATH "")
endfunction()

pkg_check_modules(drm REQUIRED IMPORTED_TARGET libdrm)

## Find dependencies that may be built with us or from an installed package.
if(TARGET hsakmt::hsakmt)
Copy link

Choose a reason for hiding this comment

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

We should not be checking for if(TARGET) as this would require the superproject to order the add_subdirectory based on the dependency order. This can be quite fragile as we would need to change the order if the dependencies between components change. Instead we should just let cmake order the dependencies.

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