-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
71 lines (58 loc) · 2.41 KB
/
CMakeLists.txt
File metadata and controls
71 lines (58 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
cmake_minimum_required(VERSION 3.20)
project(Catalyst-Jeff DESCRIPTION "A jeff plugin for Catalyst" LANGUAGES CXX C)
set(CMAKE_CXX_STANDARD 17 STRING "C++ standard to conform to")
#################
# Build options #
#################
# By default assume dependencies are located side-by-side with this repo.
# Customize these with -DJEFF_SOURCE_DIR= and -DCATALYST_SOURCE_DIR= flags from the command line.
set(JEFF_SOURCE_DIR ../jeff CACHE PATH "Source directory of the jeff project")
set(CATALYST_SOURCE_DIR ../catalyst CACHE PATH "Source directory of the Catalyst project")
# If needed, can also use non-standard build directories for the Catalyst project.
set(CATALYST_BUILD_DIR ${CATALYST_SOURCE_DIR}/mlir/build CACHE PATH "Build directory of the Catalyst MLIR module")
set(MLIR_BUILD_DIR ${CATALYST_SOURCE_DIR}/mlir/llvm-project/build CACHE PATH "Build directory of the MLIR project")
find_package(CapnProto REQUIRED)
message(STATUS "Using CapnProto at: ${CapnProto_DIR}")
# Help CMake locate dependencies:
set(Catalyst_DIR ${CATALYST_BUILD_DIR}/lib/cmake/catalyst)
set(MLIR_DIR ${MLIR_BUILD_DIR}/lib/cmake/mlir)
find_package(Catalyst REQUIRED CONFIG)
message(STATUS "Using CatalystConfig.cmake in: ${Catalyst_DIR}")
message(STATUS "Using MLIRConfig.cmake in: ${MLIR_DIR}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
# These two options are essential for generating a working plugin.
# - needed for correct handling of RTTI stuff (typeinfo)
include(HandleLLVMOptions)
# - needed for the add_llvm_library function which correctly configures the plugin module
include(AddLLVM)
######################
# Build jeff library #
######################
add_library(jeff-lib STATIC)
target_sources(jeff-lib PRIVATE
${JEFF_SOURCE_DIR}/impl/cpp/src/capnp/jeff.capnp.c++
)
target_include_directories(jeff-lib PUBLIC
${JEFF_SOURCE_DIR}/impl/cpp/src/capnp
${CAPNP_INCLUDE_DIRS}
)
target_link_libraries(jeff-lib PUBLIC
${CAPNP_LIBRARIES}
)
############################
# Build Catalyst extension #
############################
add_llvm_library(catalyst-jeff MODULE)
target_sources(catalyst-jeff PRIVATE
src/catalyst_plugin.cpp
src/jeff_export.cpp
)
target_include_directories(catalyst-jeff PRIVATE
${CATALYST_INCLUDE_DIRS}
${MLIR_INCLUDE_DIRS}
${LLVM_INCLUDE_DIRS}
)
target_link_libraries(catalyst-jeff PRIVATE
# no linking against static MLIR libs, since those are provided by the tool we plug-in to
jeff-lib
)