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

Update find_package for msgpack to work with 5.x and 6.x. #1616

Open
wants to merge 1 commit into
base: mainline
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions tensilelite/Tensile/Source/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,22 +96,20 @@ if(TENSILE_USE_LLVM OR TENSILE_USE_MSGPACK)
endif()

if(TENSILE_USE_MSGPACK)
find_package(msgpack REQUIRED)
target_compile_definitions(TensileHost PUBLIC -DTENSILE_MSGPACK=1)

if(TARGET msgpackc-cxx)
get_target_property(msgpack_inc msgpackc-cxx INTERFACE_INCLUDE_DIRECTORIES)
elseif(TARGET msgpackc)
get_target_property(msgpack_inc msgpackc INTERFACE_INCLUDE_DIRECTORIES)
endif()

if(DEFINED msgpack_inc)
# include C++ headers manually
# External header includes included as system files
target_include_directories(TensileHost
SYSTEM PRIVATE $<BUILD_INTERFACE:${msgpack_inc}>
)
# See: https://github.com/msgpack/msgpack-c/wiki/Q%26A#how-to-support-both-msgpack-c-c-version-5x-and-6x-
# Prefer 6.x (msgpack-cxx) as that is what we bundle in the build.
find_package(msgpack-cxx CONFIG)
if(msgpack-cxx_FOUND)
# Version 6.x
message(STATUS "Found msgpack-cxx (>=6.x)")
target_link_libraries(TensileHost PUBLIC msgpack-cxx)
else()
# Fallback to <= 5.x
find_package(msgpackc-cxx CONFIG REQUIRED NAMES msgpackc-cxx msgpack)
message(STATUS "Found msgpack (<=5.x)")
target_link_libraries(TensileHost PUBLIC msgpackc)
endif()
target_compile_definitions(TensileHost PUBLIC -DTENSILE_MSGPACK=1)
endif()

if(TENSILE_USE_LLVM)
Expand Down