-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
103 lines (87 loc) · 3.25 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
cmake_minimum_required(VERSION 3.22.1)
project(BESM-666
LANGUAGES ASM C CXX
VERSION 1.0.0
DESCRIPTION "Pet RISCV Simulator"
)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
add_compile_definitions(BESM666_HOOKS_ENABLED=1)
if(DEFINED BESM666_WITH_E2E_TESTS AND NOT DEFINED BESM666_RISCV_SYSROOT)
message(FATAL_ERROR "BESM666_RISCV_SYSROOT should be defined")
endif()
if(NOT DEFINED BESM666__PARENT_BUILD)
include(ExternalProject)
ExternalProject_Add(besm666_simulator
SOURCE_DIR ${CMAKE_SOURCE_DIR}
BINARY_DIR ${CMAKE_BINARY_DIR}/besm-666
CMAKE_CACHE_ARGS
-DBESM666__SIMULATOR_BUILD:BOOL=ON
-DBESM666__PARENT_BUILD:BOOL=ON
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
INSTALL_COMMAND ""
BUILD_ALWAYS ON
)
if(DEFINED BESM666_WITH_E2E_TESTS)
ExternalProject_Add(besm666_e2e
SOURCE_DIR ${CMAKE_SOURCE_DIR}
BINARY_DIR ${CMAKE_BINARY_DIR}/e2e
CMAKE_CACHE_ARGS
-DBESM666__PARENT_BUILD:BOOL=ON
-DBESM666__E2E_TESTS_BUILD:BOOL=ON
-DBESM666_RISCV_SYSROOT:FILEPATH=${BESM666_RISCV_SYSROOT}
-DCMAKE_TOOLCHAIN_FILE:FILEPATH=${CMAKE_SOURCE_DIR}/tools/riscv64-toolchain.make
INSTALL_COMMAND ""
BUILD_ALWAYS ON
)
endif()
return()
endif()
if(DEFINED BESM666__SIMULATOR_BUILD)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
find_package(Python3 REQUIRED)
find_package(Git REQUIRED)
message(STATUS "Fetching submodules")
#execute_process(
#COMMAND ${Git_EXECUTABLE} submodule update --init --recursive
#WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
#RESULT_VARIABLE GIT_SUBMODULE_UPDATE_RESULT
#)
#if(NOT GIT_SUBMODULE_UPDATE_RESULT EQUAL "0")
#message(FATAL_ERROR "Failed to fetch submodules")
#endif()
file(GLOB BESM666_RISCV_ISA_FILES
${CMAKE_SOURCE_DIR}/third_party/riscv-opcodes/rv64_*)
add_custom_command(
OUTPUT ${CMAKE_SOURCE_DIR}/include/besm-666/autogen
COMMAND mkdir -p ${CMAKE_SOURCE_DIR}/include/besm-666/autogen
COMMENT "Creating include/besm-666/autogen directory"
)
add_custom_command(
OUTPUT ${CMAKE_SOURCE_DIR}/include/besm-666/autogen/encoding.out.h
COMMAND ${Python3_EXECUTABLE}
${CMAKE_SOURCE_DIR}/third_party/riscv-opcodes/parse.py -c
${BESM666_RISCV_ISA_FILES}
DEPENDS ${CMAKE_SOURCE_DIR}/include/besm-666/autogen
DEPENDS ${CMAKE_SOURCE_DIR}/third_party/riscv-opcodes/parse.py
DEPENDS ${BESM666_RISCV_ISA_FILES}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/include/besm-666/autogen
COMMENT "Generating RICSV instruction encoding info."
)
add_custom_target(besm666_riscv_isa DEPENDS
${CMAKE_SOURCE_DIR}/include/besm-666/autogen/encoding.out.h)
add_subdirectory(src)
add_subdirectory(standalone)
add_subdirectory(third_party)
enable_testing()
if (DEFINED BESM666_TEST_WITH_VALGRIND)
include (CTest)
set(CMAKE_CTEST_ARGUMENTS --test-action memcheck)
endif()
#add_subdirectory(unit_test)
endif()
if (DEFINED BESM666__E2E_TESTS_BUILD)
enable_testing()
add_subdirectory(e2e_test)
endif()