-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeList.txt
41 lines (33 loc) · 1.16 KB
/
CMakeList.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
cmake_minimum_required(VERSION 3.22)
project(PicoRV)
# Use C++20 and enable high optimization
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
# Fetch and include Google Test at configure time
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.10.0 # Use a stable release
)
FetchContent_MakeAvailable(googletest)
# Compiler Source Files
file(GLOB_RECURSE COMPILER_SOURCES
"${CMAKE_SOURCE_DIR}/src/compiler/lexer/*.cpp"
"${CMAKE_SOURCE_DIR}/src/compiler/lexer/*.h"
)
# Define the main compiler target
add_executable(riscv_compiler ${COMPILER_SOURCES})
# Test Source Files
file(GLOB_RECURSE TEST_SOURCES
"${CMAKE_SOURCE_DIR}/src/tests/*.cpp"
)
# Define the test executable
add_executable(riscv_compiler_tests ${TEST_SOURCES})
# Link the test executable with Google Test and Compiler Sources
target_link_libraries(riscv_compiler_tests PRIVATE gtest gtest_main)
target_link_libraries(riscv_compiler_tests PRIVATE riscv_compiler)
# Enable testing
enable_testing()
add_test(NAME riscv_compiler_tests COMMAND riscv_compiler_tests)