-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
67 lines (53 loc) · 1.67 KB
/
CMakeLists.txt
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
cmake_minimum_required(VERSION 3.10)
project(rvpin)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Add ChampSim directories
include_directories(${CMAKE_SOURCE_DIR}/third_party/champsim/inc)
include_directories(${CMAKE_SOURCE_DIR}/third_party/champsim/src)
link_directories(${CMAKE_SOURCE_DIR}/third_party/champsim/lib)
# Add our include directories
include_directories(${CMAKE_SOURCE_DIR}/src)
include_directories(${CMAKE_SOURCE_DIR}/include)
# Find required packages
find_package(fmt REQUIRED)
find_package(Catch2 REQUIRED)
# Find RISC-V toolchain
find_program(RISCV_GCC riscv64-unknown-elf-gcc)
find_program(RISCV_AS riscv64-unknown-elf-as)
# Add subdirectories
add_subdirectory(src)
add_subdirectory(examples)
# Main library
add_library(rvpin SHARED
src/core/engine.cpp
src/core/decoder.cpp
src/core/instruction.cpp
src/api/instrumentation.cpp
)
# Example tools
add_executable(instruction_counter
examples/instruction_counter.cpp
)
add_executable(syscall_tracer
examples/syscall_tracer.cpp
)
add_executable(champsim_example
examples/champsim_example.cpp
)
target_link_libraries(instruction_counter PRIVATE rvpin)
target_link_libraries(syscall_tracer PRIVATE rvpin)
target_link_libraries(champsim_example fmt::fmt)
# Test program
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/hello
COMMAND ${RISCV_AS} -o ${CMAKE_BINARY_DIR}/hello ${CMAKE_SOURCE_DIR}/test/hello.S
DEPENDS ${CMAKE_SOURCE_DIR}/test/hello.S
COMMENT "Building RISC-V hello world program"
)
add_custom_target(hello ALL DEPENDS ${CMAKE_BINARY_DIR}/hello)
# Installation
install(TARGETS rvpin
LIBRARY DESTINATION lib
PUBLIC_HEADER DESTINATION include/rvpin
)