groovylight/sim/CMakeLists.txt

108 lines
2.5 KiB
CMake
Raw Permalink Normal View History

2024-05-19 05:15:53 +00:00
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 ""
2024-05-19 05:15:53 +00:00
)
FetchContent_Declare(
sokol
GIT_REPOSITORY https://github.com/floooh/sokol.git
GIT_TAG 55bc9cf3fa4051d485d10412c75c893c3135e885
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
2024-05-19 05:15:53 +00:00
)
2024-05-21 23:08:29 +00:00
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)
2024-05-26 13:48:38 +00:00
# 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})
2024-05-26 13:48:38 +00:00
# Catch2 setup
2024-05-21 23:08:29 +00:00
list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras) # needed for the catch_discover_tests function
2024-05-19 05:15:53 +00:00
2024-05-26 13:48:38 +00:00
# Verilator
list(APPEND VSOURCES ../verilog/hub75e.sv ../verilog/lineram.v)
2024-05-19 05:15:53 +00:00
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
find_package(verilator HINTS $ENV{VERILATOR_ROOT})
2024-05-26 13:48:38 +00:00
# OpenGL
find_package(OpenGL REQUIRED)
find_package(X11 REQUIRED)
# SIM
2024-05-19 05:15:53 +00:00
add_executable(sim)
target_sources(sim PRIVATE
src/main.cpp
2024-05-26 13:48:38 +00:00
src/sokol.cpp
2024-05-19 05:15:53 +00:00
)
target_include_directories(sim PRIVATE inc/)
2024-05-26 13:48:38 +00:00
target_compile_options(sim PRIVATE -DSOKOL_GLCORE33)
verilate(sim SOURCES ${VSOURCES} TRACE VERILATOR_ARGS -Wno-MULTITOP)
2024-05-21 23:08:29 +00:00
2024-05-26 13:48:38 +00:00
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)
2024-05-21 23:08:29 +00:00
2024-05-26 13:48:38 +00:00
# SIM TEST
add_executable(sim_test)
target_sources(sim_test PRIVATE
test/hub75.cpp
)
2024-05-19 05:15:53 +00:00
target_include_directories(sim_test PRIVATE inc/)
target_link_libraries(sim_test PRIVATE sokol)
verilate(sim_test SOURCES ${VSOURCES} TRACE VERILATOR_ARGS -Wno-MULTITOP)
2024-05-21 23:08:29 +00:00
target_link_libraries(sim_test PRIVATE Catch2::Catch2WithMain)
2024-05-21 23:08:29 +00:00
include(CTest)
include(Catch)
catch_discover_tests(sim_test)