ysyx-workbench/npc/CMakeLists.txt
xinyangli 64aee9ae21
Some checks failed
Run CTests within npc / npc-test (flow) (push) Failing after 8s
Build abstract machine with nix / build-packages (abstract-machine) (push) Failing after 14s
Build abstract machine with nix / build-packages (nemu) (push) Successful in 41s
Build abstract machine with nix / build-packages (nemu-lib) (push) Successful in 9s
Build abstract machine with nix / build-packages (rv32Cross.abstract-machine) (push) Successful in 8s
Run CTests within npc / npc-test (flow-simlib) (push) Failing after 7s
npc,ci: add npc to nix packages
2024-08-14 17:01:37 +08:00

83 lines
2.5 KiB
CMake

cmake_minimum_required(VERSION 3.26)
project(flow)
set(CMAKE_CXX_STANDARD 17)
cmake_policy(SET CMP0144 NEW)
include(CMakeDependentOption)
include(CTest)
include(GNUInstallDirs)
enable_testing()
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
# -- Build options
option(BUILD_CHISEL_EMIT_TARGET "Emit verilog file with chisel" ON)
option(BUILD_USE_BLOOP "Whether to use bloop to speed up elaborate" OFF)
option(BUILD_SIM_TARGET "Whether to build verilator simulation binary" ON)
cmake_dependent_option(
BUILD_SIM_NVBOARD_TARGET "Whether to build nvboard target" OFF
"BUILD_SIM_TARGET" OFF)
option(ENABLE_YSYX_GIT_TRACKER "Ysyx tracker support" ON)
set(TOPMODULE
"Flow"
CACHE STRING "Topmodule name in chisel")
set(DIFFTEST_LIB
""
CACHE FILEPATH "Dynamic library file used as difftest reference")
set(DIFFTEST_RESOURCE_DIR
""
CACHE PATH "Dynamic library file used as difftest reference")
# -- Ysyx tracker, configure
if(ENABLE_YSYX_GIT_TRACKER)
execute_process(COMMAND ${CMAKE_SOURCE_DIR}/../git_commit.sh "configure(npc)"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/..)
endif()
# -- Check dependencies
if(BUILD_SIM_TARGET)
find_package(verilator REQUIRED)
endif()
if(BUILD_SIM_NVBOARD_TARGET)
find_package(SDL2 REQUIRED)
find_package(SDL2_image REQUIRED)
endif()
find_package(CLI11 CONFIG REQUIRED)
find_package(spdlog REQUIRED)
option(ENABLE_SDB "Enable simple debugger" OFF)
find_library(NVBOARD_LIBRARY NAMES nvboard)
find_path(NVBOARD_INCLUDE_DIR NAMES nvboard.h)
if(BUILD_CHISEL_EMIT_TARGET)
# FIXME: all scala source file are tracked here, cause all files to rebuild
# after a source update.
set(SCALA_CORE "${CMAKE_CURRENT_SOURCE_DIR}/core")
set(CHISEL_MODULE_CLASS "${CMAKE_PROJECT_NAME}.${TOPMODULE}")
set(CHISEL_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/${TOPMODULE}/vsrc)
set(CHISEL_OUTPUT_VERILATOR_CONF ${CHISEL_OUTPUT_DIR}/conf.vlt)
set(CHISEL_OUTPUT_TOPMODULE ${CHISEL_OUTPUT_DIR}/${TOPMODULE}.sv)
set(CHISEL_EMIT_ARGS "--target-dir ${CHISEL_OUTPUT_DIR}")
endif()
# -- Build NVBoard executable
if(BUILD_SIM_NVBOARD_TARGET)
add_subdirectory(csrc_nvboard)
endif()
# -- Build Verilator executable and add to test
add_subdirectory(utils)
add_subdirectory(csrc)
# -- Add build tracking
if(ENABLE_YSYX_GIT_TRACKER)
add_custom_target(
ysyx_git_tracer ALL
COMMAND ${CMAKE_SOURCE_DIR}/../git_commit.sh
"build_${CMAKE_PROJECT_NAME}_V${TOPMODULE}"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/..)
endif()