Repository navigation
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
105 lines (81 loc) · 3.12 KB
/
Copy pathCMakeLists.txt
File metadata and controls
105 lines (81 loc) · 3.12 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
cmake_minimum_required(VERSION 3.12)
set (CMAKE_CXX_STANDARD 14)
project(SpatialScheduler)
execute_process(
COMMAND git rev-parse --show-toplevel
OUTPUT_VARIABLE REPO_PREFIX)
string(REGEX REPLACE "\n$" "" REPO_PREFIX "${REPO_PREFIX}")
if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/config.cmake)
include(${CMAKE_CURRENT_BINARY_DIR}/config.cmake)
message(STATUS "Using ${CMAKE_CURRENT_BINARY_DIR}/config.cmake")
else()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/config.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/config.cmake)
else()
message(STATUS "config.cmake not found, use defined configs")
endif()
endif()
# Build assumptions
set(BUILD_SHARED_LIBS ON)
if (DEFINED ENV{SS_TOOLS})
set(CMAKE_INSTALL_PREFIX $ENV{SS_TOOLS})
else()
message(FATAL "Please set SS_TOOLS to build!")
endif()
# Debug/Release
#set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_definitions("DEBUG_MODE")
endif()
add_definitions(-DREPO_PREFIX="${REPO_PREFIX}")
# set(CMAKE_POSITION_INDEPENDENT_CODE ON)
add_compile_options(-fno-strict-aliasing)
# Find dependencies: Parser
find_package(FLEX REQUIRED)
find_package(BISON REQUIRED)
find_package(Torch REQUIRED)
FLEX_TARGET(DFG_LEXER ${CMAKE_SOURCE_DIR}/src/dfg/dfg-parser.l
${CMAKE_SOURCE_DIR}/src/dfg/dfg-parser.yy.cc
DEFINES_FILE ${CMAKE_SOURCE_DIR}/src/dfg/dfg-parser.h)
BISON_TARGET(DFG_PARSER ${CMAKE_SOURCE_DIR}/src/dfg/dfg-parser.y
${CMAKE_SOURCE_DIR}/src/dfg/dfg-parser.tab.cc
DEFINES_FILE ${CMAKE_SOURCE_DIR}/src/dfg/dfg-parser.tab.h)
# Generate ssinsts.{cpp/h}
add_executable(inst_model ${CMAKE_SOURCE_DIR}/src/insts/inst_model.cpp)
target_include_directories(inst_model PRIVATE ${CMAKE_SOURCE_DIR}/include)
set(SS_INSTS_H ${CMAKE_SOURCE_DIR}/include/dsa/arch/ssinst.h)
set(SS_INSTS_CXX ${CMAKE_SOURCE_DIR}/src/insts/ssinst.cpp)
set(PA_MODEL ${CMAKE_SOURCE_DIR}/src/insts/"full.ssinst.overhead.csv")
# set(PA_MODEL ${CMAKE_SOURCE_DIR}/src/insts/"full.ssinst.power_area.csv")
add_custom_command(
OUTPUT ${SS_INSTS_H} ${SS_INSTS_CXX}
COMMAND ${CMAKE_BINARY_DIR}/inst_model ${INST_MODEL} ${PA_MODEL} ${SS_INSTS_H} ${SS_INSTS_CXX}
DEPENDS inst_model
)
# Build the library
file(GLOB_RECURSE SRCS ${CMAKE_SOURCE_DIR}/src/*.cpp)
file(GLOB_RECURSE HEADERS ${CMAKE_SOURCE_DIR}/include/*.h)
add_library(dsa
${SRCS}
${SS_INSTS_CXX}
${FLEX_DFG_LEXER_OUTPUTS}
${BISON_DFG_PARSER_OUTPUTS}
)
target_compile_definitions(dsa PRIVATE ENV_CACHE)
set_target_properties(dsa PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_include_directories(dsa PUBLIC
${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/3rd-party/cxxopts/include
${CMAKE_SOURCE_DIR}/3rd-party/ctpl/
${CMAKE_SOURCE_DIR}/3rd-party/libtorch/include/torch/csrc/api/include
${CMAKE_INSTALL_PREFIX}/include
)
target_link_directories(dsa PRIVATE
${CMAKE_INSTALL_PREFIX}/lib ${CMAKE_INSTALL_PREFIX}/lib64
)
target_link_libraries(dsa PRIVATE jsoncpp ${TORCH_LIBRARIES})
# Install the header files and library
install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/)
install(TARGETS dsa DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/)
add_subdirectory(${CMAKE_SOURCE_DIR}/drivers)