Skip to content

Commit

Permalink
[cmake] fix one-step build (#192)
Browse files Browse the repository at this point in the history
In one-step build, llvm include directory will be prepended into include
directories list, and this cause the IR backend using LLVM provided
IntinsicImpl.inc file. This commit add `BEFORE` keyword into
include_directories macro to force prepend buddy-mlir backend include
directory.

Signed-off-by: Avimitin <[email protected]>
  • Loading branch information
Avimitin authored Aug 31, 2023
1 parent 19fb275 commit 7b420a7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 10 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ endif()
#-------------------------------------------------------------------------------

project(buddy-mlir LANGUAGES CXX C)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED YES)

Expand Down Expand Up @@ -61,14 +61,18 @@ else()
#-------------------------------------------------------------------------------
# MLIR/LLVM Configuration
#-------------------------------------------------------------------------------


# Allow passing external LLVM source, instead of forcing user using the vendored one
if (NOT LLVM_PROJECT_SOURCE_DIR)
set(LLVM_PROJECT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/llvm")
message(STATUS "Using LLVM Project ${LLVM_PROJECT_SOURCE_DIR}")
endif()

set(MLIR_MAIN_SRC_DIR ${LLVM_MAIN_SRC_DIR}/../mlir)
set(MLIR_INCLUDE_DIR ${LLVM_MAIN_SRC_DIR}/../mlir/include)
set(MLIR_INCLUDE_DIR ${MLIR_MAIN_SRC_DIR}/include)
set(MLIR_GENERATED_INCLUDE_DIR ${LLVM_BINARY_DIR}/tools/mlir/include)
set(LLVM_MLIR_BINARY_DIR ${CMAKE_BINARY_DIR}/bin)
set(MLIR_INCLUDE_DIRS "${MLIR_INCLUDE_DIR};${MLIR_GENERATED_INCLUDE_DIR}")
set(LLVM_PROJECT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/llvm")
set(LLVM_MLIR_SOURCE_DIR "${LLVM_MAIN_SRC_DIR}/../mlir")
endif()

#-------------------------------------------------------------------------------
Expand Down Expand Up @@ -97,7 +101,7 @@ include_directories(${BUDDY_MIDEND_INCLUDE_DIR})
include_directories(${BUDDY_MIDEND_INCLUDE_DIR}/Interface)
include_directories(${BUDDY_MIDEND_INCLUDE_DIR}/Dialect)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/midend/include/Dialect)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/backend/include)
include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}/backend/include)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${BUDDY_SOURCE_DIR}/lib)
include_directories(${BUDDY_THIRDPARTY_INCLUDE_DIR})
Expand Down
2 changes: 1 addition & 1 deletion midend/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ add_subdirectory(Utils)

add_mlir_library(static_mlir_async_runtime
STATIC
${LLVM_MLIR_SOURCE_DIR}/lib/ExecutionEngine/AsyncRuntime.cpp
${MLIR_MAIN_SRC_DIR}/lib/ExecutionEngine/AsyncRuntime.cpp

EXCLUDE_FROM_LIBMLIR

Expand Down

0 comments on commit 7b420a7

Please sign in to comment.