-
Notifications
You must be signed in to change notification settings - Fork 146
/
CMakeLists.txt
119 lines (102 loc) · 3.69 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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
cmake_minimum_required(VERSION 3.0.0)
project(dramsim3)
set(default_build_type "Release")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
add_library(inih INTERFACE)
target_include_directories(inih INTERFACE ext/headers)
add_library(format INTERFACE)
target_include_directories(format INTERFACE ext/fmt/include)
target_compile_definitions(format INTERFACE FMT_HEADER_ONLY=1)
# argparsing library, only used in main program not the library
add_library(args INTERFACE)
target_include_directories(args INTERFACE ext/headers)
add_library(json INTERFACE)
target_include_directories(json INTERFACE ext/headers)
# Main DRAMSim Lib
add_library(dramsim3 SHARED
src/bankstate.cc
src/channel_state.cc
src/command_queue.cc
src/common.cc
src/configuration.cc
src/controller.cc
src/dram_system.cc
src/hmc.cc
src/refresh.cc
src/simple_stats.cc
src/timing.cc
src/memory_system.cc
)
if (THERMAL)
# dependency check
# sudo apt-get install libatlas-base-dev on ubuntu
find_package(BLAS REQUIRED)
find_package(OpenMP REQUIRED)
# YOU need to build superlu on your own. Do the following:
# git submodule update --init
# cd ext/SuperLU_MT_3.1 && make lib
find_library(SUPERLU
NAME superlu_mt_OPENMP libsuperlu_mt_OPENMP
HINTS ${PROJECT_SOURCE_DIR}/ext/SuperLU_MT_3.1/lib/
)
target_link_libraries(dramsim3
PRIVATE ${SUPERLU} f77blas atlas m ${OpenMP_C_FLAGS}
)
target_sources(dramsim3
PRIVATE src/thermal.cc src/sp_ienv.c src/thermal_solver.c
)
target_compile_options(dramsim3 PRIVATE -DTHERMAL -D_LONGINT -DAdd_ ${OpenMP_C_FLAGS})
add_executable(thermalreplay src/thermal_replay.cc)
target_link_libraries(thermalreplay dramsim3 inih)
target_compile_options(thermalreplay PRIVATE -DTHERMAL -D_LONGINT -DAdd_ ${OpenMP_C_FLAGS})
endif (THERMAL)
if (CMD_TRACE)
target_compile_options(dramsim3 PRIVATE -DCMD_TRACE)
endif (CMD_TRACE)
if (ADDR_TRACE)
target_compile_options(dramsim3 PRIVATE -DADDR_TRACE)
endif (ADDR_TRACE)
target_include_directories(dramsim3 INTERFACE src)
target_compile_options(dramsim3 PRIVATE -Wall)
target_link_libraries(dramsim3 PRIVATE inih format)
set_target_properties(dramsim3 PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}
CXX_STANDARD 11
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
)
# trace CPU, .etc
add_executable(dramsim3main src/main.cc src/cpu.cc)
target_link_libraries(dramsim3main PRIVATE dramsim3 args)
target_compile_options(dramsim3main PRIVATE)
set_target_properties(dramsim3main PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
)
# Unit testing
add_library(Catch INTERFACE)
target_include_directories(Catch INTERFACE ext/headers)
add_executable(dramsim3test EXCLUDE_FROM_ALL
tests/test_config.cc
tests/test_dramsys.cc
tests/test_hmcsys.cc # IDK somehow this can literally crush your computer
)
target_link_libraries(dramsim3test Catch dramsim3)
target_include_directories(dramsim3test PRIVATE src/)
# We have to use this custome command because there's a bug in cmake
# that if you do `make test` it doesn't build your updated test files
# so we're stucking with `make dramsim3test` for now
add_custom_command(
TARGET dramsim3test POST_BUILD
COMMAND dramsim3test
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
DEPENDS dramsim3test dramsim3
)