generated from saji/ecp5-template
108 lines
2.5 KiB
CMake
108 lines
2.5 KiB
CMake
cmake_minimum_required(VERSION 3.20)
|
|
|
|
include(FetchContent)
|
|
|
|
project(groovylight-sim)
|
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
set(CMAKE_C_STANDARD 11)
|
|
|
|
FetchContent_Declare(
|
|
dear_imgui
|
|
GIT_REPOSITORY https://github.com/ocornut/imgui.git
|
|
GIT_TAG 231cbee0fc4f59dbe5b8b853a11b08dc84e57c65 # version 1.90.5
|
|
CONFIGURE_COMMAND ""
|
|
BUILD_COMMAND ""
|
|
)
|
|
|
|
FetchContent_Declare(
|
|
sokol
|
|
GIT_REPOSITORY https://github.com/floooh/sokol.git
|
|
GIT_TAG 55bc9cf3fa4051d485d10412c75c893c3135e885
|
|
CONFIGURE_COMMAND ""
|
|
BUILD_COMMAND ""
|
|
)
|
|
|
|
FetchContent_Declare(
|
|
Catch2
|
|
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
|
|
GIT_TAG v3.4.0 # or a later release
|
|
)
|
|
|
|
FetchContent_MakeAvailable(sokol dear_imgui Catch2)
|
|
|
|
# imgui
|
|
add_library(imgui INTERFACE)
|
|
target_sources(imgui INTERFACE
|
|
${dear_imgui_SOURCE_DIR}/imgui.cpp
|
|
${dear_imgui_SOURCE_DIR}/imgui_draw.cpp
|
|
${dear_imgui_SOURCE_DIR}/imgui_tables.cpp
|
|
${dear_imgui_SOURCE_DIR}/imgui_widgets.cpp
|
|
${dear_imgui_SOURCE_DIR}/imgui_widgets.cpp
|
|
${dear_imgui_SOURCE_DIR}/imgui_demo.cpp
|
|
)
|
|
target_include_directories(imgui INTERFACE
|
|
${dear_imgui_SOURCE_DIR}
|
|
${dear_imgui_SOURCE_DIR}/backends/
|
|
)
|
|
# target_compile_options(imgui PRIVATE -Wno-unused-but-set-variable -Wno-type-limits -Wno-missing-field-initializers)
|
|
|
|
|
|
# sokol
|
|
add_library(sokol INTERFACE)
|
|
target_include_directories(sokol INTERFACE ${sokol_SOURCE_DIR})
|
|
|
|
|
|
# Catch2 setup
|
|
list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras) # needed for the catch_discover_tests function
|
|
|
|
|
|
# Verilator
|
|
list(APPEND VSOURCES ../verilog/hub75e.sv ../verilog/lineram.v)
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
|
|
|
|
find_package(verilator HINTS $ENV{VERILATOR_ROOT})
|
|
|
|
|
|
# OpenGL
|
|
find_package(OpenGL REQUIRED)
|
|
find_package(X11 REQUIRED)
|
|
|
|
# SIM
|
|
add_executable(sim)
|
|
|
|
target_sources(sim PRIVATE
|
|
src/main.cpp
|
|
src/sokol.cpp
|
|
)
|
|
|
|
target_include_directories(sim PRIVATE inc/)
|
|
target_compile_options(sim PRIVATE -DSOKOL_GLCORE33)
|
|
|
|
verilate(sim SOURCES ${VSOURCES} TRACE VERILATOR_ARGS -Wno-MULTITOP)
|
|
|
|
target_link_libraries(sim PUBLIC OpenGL::GL X11 Xi Xcursor dl pthread m)
|
|
target_link_libraries(sim PUBLIC sokol)
|
|
target_link_libraries(sim PUBLIC imgui)
|
|
|
|
|
|
|
|
# SIM TEST
|
|
add_executable(sim_test)
|
|
target_sources(sim_test PRIVATE
|
|
test/hub75.cpp
|
|
)
|
|
|
|
target_include_directories(sim_test PRIVATE inc/)
|
|
|
|
target_link_libraries(sim_test PRIVATE sokol)
|
|
|
|
verilate(sim_test SOURCES ${VSOURCES} TRACE VERILATOR_ARGS -Wno-MULTITOP)
|
|
|
|
target_link_libraries(sim_test PRIVATE Catch2::Catch2WithMain)
|
|
|
|
include(CTest)
|
|
include(Catch)
|
|
catch_discover_tests(sim_test)
|