Skip to content

Commit

Permalink
add boost fetch-content
Browse files Browse the repository at this point in the history
  • Loading branch information
makslevental committed Aug 18, 2024
1 parent 9d8c3b7 commit 819f985
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 37 deletions.
52 changes: 24 additions & 28 deletions cmake/iree_aie_xrt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,26 @@
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

include(${CMAKE_CURRENT_LIST_DIR}/iree_aie_utils.cmake)

if(TARGET iree-aie-xclbinutil)
return()
endif()

if(WIN32)
set(STATIC_OR_SHARED ON)
else()
# R_X86_64_PC32 relocation at offset 0x684 against symbol
#`boost::system::detail::cat_holder<void>::system_category_instance' can not be used; recompile with -fPIC
set(STATIC_OR_SHARED OFF)
endif()
set(Boost_USE_STATIC_LIBS ${SHARED_OR_STATIC} CACHE BOOL "" FORCE)
include(FetchContent)
include(${CMAKE_CURRENT_LIST_DIR}/iree_aie_utils.cmake)

find_package(Threads REQUIRED)
find_package(Boost REQUIRED COMPONENTS filesystem program_options system)

set(Boost_USE_STATIC_LIBS ON)
set(BOOST_INCLUDE_LIBRARIES thread filesystem system program_options)
set(BOOST_ENABLE_CMAKE ON)
set(FETCHCONTENT_QUIET FALSE) # Needed to print downloading progress
FetchContent_Declare(
Boost
URL https://github.com/boostorg/boost/releases/download/boost-1.81.0/boost-1.81.0.7z
USES_TERMINAL_DOWNLOAD TRUE
GIT_PROGRESS TRUE
DOWNLOAD_NO_EXTRACT FALSE)
FetchContent_MakeAvailable(Boost)
message(STATUS "Boost include directories:" ${Boost_INCLUDE_DIRS})

set(IREE_XRT_SOURCE_DIR "${IREE_AMD_AIE_SOURCE_DIR}/third_party/XRT/src")
Expand Down Expand Up @@ -123,21 +127,15 @@ file(
"${_xclbinutil_source_dir}/XclBinUtilMain.cxx"
)

if(WIN32)
set(STATIC_OR_SHARED STATIC)
else()
# R_X86_64_PC32 relocation at offset 0x684 against symbol
#`boost::system::detail::cat_holder<void>::system_category_instance' can not be used; recompile with -fPIC
set(STATIC_OR_SHARED SHARED)
endif()
add_library(iree-aie-xclbinutil ${STATIC_OR_SHARED} ${_xclbinutil_srcs})
add_library(iree-aie-xclbinutil STATIC ${_xclbinutil_srcs})
target_compile_options(iree-aie-xclbinutil PRIVATE -fexceptions -frtti)

set(THREADS_PREFER_PTHREAD_FLAG ON)
set(_xclbin_libs
Boost::filesystem
Boost::program_options
Boost::system
$<BUILD_LOCAL_INTERFACE:Boost::any>
$<BUILD_LOCAL_INTERFACE:Boost::filesystem>
$<BUILD_LOCAL_INTERFACE:Boost::program_options>
$<BUILD_LOCAL_INTERFACE:Boost::system>
Threads::Threads)
set(_xclbinutil_compile_definitions
-DBOOST_BIND_GLOBAL_PLACEHOLDERS
Expand All @@ -146,9 +144,6 @@ set(_xclbinutil_compile_definitions

if(WIN32)
list(APPEND _xclbinutil_compile_definitions -D"/EHsc")
# Uncomment if you get LINK : fatal error LNK1104: cannot open file
# 'libboost_filesystem-vc142-mt-gd-x64-1_74.lib'
# target_compile_definitions(iree-aie-xclbinutil PUBLIC BOOST_ALL_DYN_LINK)
else()
list(APPEND _xclbinutil_compile_definitions -DENABLE_JSON_SCHEMA_VALIDATION)
list(APPEND _xclbin_libs $<BUILD_LOCAL_INTERFACE:transformcdo>)
Expand Down Expand Up @@ -204,7 +199,8 @@ foreach(_core_lib IN LISTS _core_libs)
${IREE_XRT_SOURCE_DIR}/runtime_src/core/common/elf)
target_compile_definitions(${_core_lib} PRIVATE -DBOOST_BIND_GLOBAL_PLACEHOLDERS)
target_link_libraries(${_core_lib} PRIVATE
Boost::filesystem
Boost::program_options
Boost::system)
$<BUILD_LOCAL_INTERFACE:Boost::any>
$<BUILD_LOCAL_INTERFACE:Boost::filesystem>
$<BUILD_LOCAL_INTERFACE:Boost::program_options>
$<BUILD_LOCAL_INTERFACE:Boost::system>)
endforeach()
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,9 @@ iree_cc_library(
iree-amd-aie::aie_runtime::iree_aie_runtime_static
iree::target::amd-aie::Transforms
iree-aie-bootgen
iree-aie-xclbinutil
)

if(IREE_AMD_AIE_ENABLE_XRT_DRIVER)
# on windows for some reason `DEPS` above doesn't trigger a build
# and also doesn't point to the .dll (points to .lib instead)
target_link_libraries(iree_target_amd-aie_Target_AIETargets PRIVATE iree-aie-xclbinutil)
# add_dependencies(iree_target_amd-aie_Target_AIETargets iree-aie-xclbinutil)
endif()

iree_cc_library(
NAME
Target
Expand Down
2 changes: 0 additions & 2 deletions iree_compiler_plugin.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
find_package(Boost REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})

set(IREE_AMD_AIE_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}")
set(IREE_AMD_AIE_RUNTIME_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/runtime/src)
Expand Down

0 comments on commit 819f985

Please sign in to comment.