-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
151 lines (124 loc) · 5.94 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
cmake_minimum_required(VERSION 3.16)
project(ChampSim_pt)
set(CPPFLAGS "-Iinc -MMD -MP -Ofast")
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_FLAGS "${CPPFLAGS} -Wall")
set(CMAKE_C_FLAGS_RELEASE "${CPPFLAGS} -Wall -O3 -g")
set(CMAKE_CXX_FLAGS "${CPPFLAGS} -Wall")
set(CMAKE_CXX_FLAGS_RELEASE "${CPPFLAGS} -Wall -O3 -g")
include_directories(inc)
# change these lines according to the xed kits path
# if (APPLE)
# message("Platform: macOS")
# include_directories(/usr/local/include/public)
# link_directories(/usr/local/lib)
# elseif (UNIX)
# message("Platform: Linux")
# include_directories(/home/isaachyw/xed/kits/xed-install-base-2021-06-05-lin-x86-64/include/public)
# link_directories(/home/isaachyw/xed/obj)
# else ()
# message("Platform: Windows")
include_directories(/mnt/storage/isaachyw/gdata-verify/artifacts/xed/kits/xed-install-base-2023-05-25-lin-x86-64/include)
link_directories(/mnt/storage/isaachyw/gdata-verify/artifacts/xed/kits/xed-install-base-2023-05-25-lin-x86-64/lib)
# endif ()
find_package(XED QUIET)
if(XED_INCLUDE_DIRS)
message("Found built xed")
message("${XED_INCLUDE_DIRS}")
message("${XED_LIBRARY_DIR}")
include_directories("${XED_INCLUDE_DIRS}")
link_directories("${XED_LIBRARY_DIR}")
else()
message("Use system xed")
endif()
set(BOOST_VERSION_REQUIRED "1.74.0")
set(CMAKE_PREFIX_PATH "/usr/local/include/boost/" ${CMAKE_PREFIX_PATH})
find_package(Boost ${BOOST_VERSION_REQUIRED} EXACT COMPONENTS system filesystem iostreams program_options REQUIRED)
# find_package(Boost COMPONENTS system filesystem iostreams program_options REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
function(generate_from_template root_directory generate_directory)
file(GLOB settings "${root_directory}/*.cmake")
file(GLOB sources "${root_directory}/*.cc" "${root_directory}/*.h")
get_filename_component(template_name ${root_directory} NAME_WLE)
foreach(setting ${settings})
get_filename_component(setting_name ${setting} NAME_WLE)
include(${setting})
foreach(source ${sources})
get_filename_component(source_name ${source} NAME)
set(output_path ${CMAKE_CURRENT_SOURCE_DIR}/${generate_directory}/${template_name}_${setting_name}/${source_name})
configure_file(${source} ${output_path} @ONLY)
endforeach()
endforeach()
endfunction()
function(copy_files source_directory dest_directory pattern)
file(GLOB sources "${source_directory}/${pattern}")
foreach(source ${sources})
get_filename_component(source_name ${source} NAME)
set(output_path ${CMAKE_CURRENT_SOURCE_DIR}/${dest_directory}/${source_name})
configure_file(${source} ${output_path} COPYONLY)
endforeach()
endfunction()
generate_from_template(btb/approx_btb.template btb-generated)
generate_from_template(btb/prob_btb.template btb-generated)
generate_from_template(btb/srrip_friendly_btb.template btb-generated)
generate_from_template(btb/srrip_second_btb.template btb-generated)
generate_from_template(btb/reuse_predict_btb.template btb-generated)
generate_from_template(btb/hot_warm_cold_btb.template btb-generated)
generate_from_template(btb/hwc_btb.template btb-generated)
generate_from_template(btb/hot_warm_cold_shotgun_btb.template btb-generated)
generate_from_template(btb/hot_warm_cold_predecoder_btb.template btb-generated)
generate_from_template(btb/multi_level_hwc_btb.template btb-generated)
copy_files(btb btb-generated "*.h")
file(GLOB SOURCE_FILES "src/*.cc")
file(GLOB CMAKE_TARGETS ${MY_TARGET})
# foreach (CMAKE_TARGET ${CMAKE_TARGETS})
# get_filename_component(TARGET_NAME ${CMAKE_TARGET} NAME_WLE)
# include(${CMAKE_TARGET})
# add_executable(ChampSim_${TARGET_NAME} ${SOURCE_FILES})
# target_link_libraries(ChampSim_${TARGET_NAME} ${MODULES} ${Boost_LIBRARIES} xed z)
# endforeach ()
function(add_module MODULE CONFIG_NAME)
set(MODULE_NAME lib_${CONFIG_NAME}_${MODULE})
if(TARGET ${MODULE_NAME})
return()
endif()
string(REPLACE "_" ";" MODULE_SPLIT ${MODULE})
list(GET MODULE_SPLIT 0 MODULE_ROOT_DIRECTORY)
list(REMOVE_AT MODULE_SPLIT 0)
list(JOIN MODULE_SPLIT "_" MODULE_SRC_DIRECTORY)
message("${MODULE_ROOT_DIRECTORY}/${MODULE_SRC_DIRECTORY}/*.cc")
file(GLOB MODULE_SRC_FILES "${MODULE_ROOT_DIRECTORY}/${MODULE_SRC_DIRECTORY}/*.cc")
add_library(${MODULE_NAME} ${MODULE_SRC_FILES})
set(CONFIG_HEADER_DIR ${PROJECT_BINARY_DIR}/${CONFIG_NAME})
target_include_directories(${MODULE_NAME} PRIVATE ${CONFIG_HEADER_DIR})
endfunction()
file(GLOB CMAKE_CONFIGS ${MY_CONFIG})
foreach(CMAKE_CONFIG ${CMAKE_CONFIGS})
get_filename_component(CONFIG_NAME ${CMAKE_CONFIG} NAME_WLE)
include(default_config.cmake)
include(${CMAKE_CONFIG})
set(CONFIG_HEADER_DIR ${PROJECT_BINARY_DIR}/${CONFIG_NAME})
configure_file(templates/champsim_constants.h ${CONFIG_HEADER_DIR}/champsim_constants.h @ONLY)
# print out the output file name
foreach(CMAKE_TARGET ${CMAKE_TARGETS})
get_filename_component(TARGET_NAME ${CMAKE_TARGET} NAME_WLE)
set(EXECUTABLE_NAME ChampSim_${CONFIG_NAME}_${TARGET_NAME})
include(${CMAKE_TARGET})
add_executable(${EXECUTABLE_NAME} ${SOURCE_FILES})
target_include_directories(${EXECUTABLE_NAME} PRIVATE ${CONFIG_HEADER_DIR})
message("Generating ${CONFIG_HEADER_DIR}")
target_link_libraries(${EXECUTABLE_NAME} ${Boost_LIBRARIES} xed z)
foreach(MODULE ${MODULES})
add_module(${MODULE} ${CONFIG_NAME})
set(MODULE_NAME lib_${CONFIG_NAME}_${MODULE})
target_link_libraries(${EXECUTABLE_NAME} ${MODULE_NAME})
endforeach()
endforeach()
endforeach()
add_executable(pt_trace_parser pt_trace_parser/main.cpp pt_trace_parser/trace_reader.h)
target_link_libraries(pt_trace_parser ${Boost_LIBRARIES} xed z)
file(GLOB_RECURSE PAGER_SOURCES CONFIGURE_DEPENDS ${CMAKE_CURRENT_LIST_DIR}/src/*.cc)
add_library(redu ${PAGER_SOURCES})
include_directories(${CMAKE_CURRENT_LIST_DIR}/inc)