-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
73 lines (63 loc) · 2.4 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
cmake_minimum_required(VERSION 3.6)
option(IS_SWITCH "Is building switch programs" OFF)
option(ENABLE_EXP_DC "Enable building the micro-benchmarks of data collection" OFF)
if(${IS_SWITCH})
project(OmniWindow LANGUAGES)
message(STATUS "Building switch programs.")
else()
project(OmniWindow)
message(STATUS "Building host programs.")
endif()
if(NOT ${IS_SWITCH})
set(CMAKE_CXX_STANDARD 17)
add_compile_options(-mssse3 -fcommon -march=native)
include_directories(include)
add_subdirectory(lib)
add_subdirectory(tools)
endif()
function(add_p4 name source compile_flags py_script)
if(${IS_SWITCH})
make_directory("${CMAKE_CURRENT_BINARY_DIR}/${name}.build")
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${name}.sh"
# COMMAND rm -rf *
COMMAND cmake \"$ENV{SDE}/p4studio\"
-DCMAKE_INSTALL_PREFIX=\"$ENV{SDE_INSTALL}\"
-DCMAKE_MODULE_PATH=\"$ENV{SDE}/cmake\"
-DP4_NAME=\"omniwin-${name}\"
-DP4_PATH=\"${CMAKE_CURRENT_SOURCE_DIR}/${source}\"
${compile_flags}
COMMAND make
COMMAND make install
COMMAND echo \"\#\! /bin/bash -i\" >"${CMAKE_CURRENT_BINARY_DIR}/${name}.sh"
COMMAND echo \"
if \[\[ ! -a "${CMAKE_SOURCE_DIR}/switch-shell.txt" \]\]\; then
echo "Missing file ${CMAKE_SOURCE_DIR}/switch-shell.txt" \;
exit\;
fi\;
cd \\$$SDE\;
./run_switchd.sh -p "omniwin-${name}" -- --background &
./run_bfshell.sh -f "${CMAKE_SOURCE_DIR}/switch-shell.txt" \;
if \[\[ -a "${CMAKE_SOURCE_DIR}/switch-config.json" \]\]\; then
cp "${CMAKE_SOURCE_DIR}/switch-config.json" /tmp/OmniWindow-config.json\;
./run_bfshell.sh -i -b "${CMAKE_CURRENT_SOURCE_DIR}/${py_script}" \;
else
echo "Missing file ${CMAKE_SOURCE_DIR}/switch-config.json" \;
echo "Press Ctrl-C to quit..." \;
fi\;
fg
\" >>"${CMAKE_CURRENT_BINARY_DIR}/${name}.sh"
COMMAND chmod +x "${CMAKE_CURRENT_BINARY_DIR}/${name}.sh"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${name}.build"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${source}"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${py_script}"
)
add_custom_target(${name} ALL
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${name}.sh"
)
endif()
endfunction()
add_subdirectory(apps)
if(${ENABLE_EXP_DC})
add_subdirectory(Exp-dc)
endif()