-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmakelists.txt
80 lines (65 loc) · 2.15 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
include(FetchContent)
cmake_minimum_required(VERSION 3.15)
project(FunVM VERSION 1.0)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
## Google Test ##
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.14.0
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
## SPDLOG ##
FetchContent_Declare(
spdlog
GIT_REPOSITORY https://github.com/gabime/spdlog.git
GIT_TAG v1.12.0
)
FetchContent_MakeAvailable(spdlog)
## ByteCode.h ##
add_custom_command(
OUTPUT ${CMAKE_SOURCE_DIR}/src/ByteCode.h
COMMAND python ${CMAKE_SOURCE_DIR}/scripts/generate_bytecode_header.py
DEPENDS ${CMAKE_SOURCE_DIR}/scripts/generate_bytecode_header.py
DEPENDS ${CMAKE_SOURCE_DIR}/src/bytecode.json
COMMENT "Generating ByteCode.h"
)
## FVMLib ##
add_library(FVMLib
src/main.cpp
src/FVM.cpp
src/ByteCode.h
src/lang/Lexer.cpp
src/lang/Compiler.cpp
src/lang/Parser.cpp
)
target_include_directories(FVMLib PUBLIC "${PROJECT_BINARY_DIR}/src")
target_include_directories(FVMLib PUBLIC "${PROJECT_BINARY_DIR}/src/lang")
target_link_libraries(FVMLib PRIVATE spdlog::spdlog $<$<BOOL:${MINGW}>:ws2_32>)
## FVM Executable ##
add_executable(FunVM src/main.cpp)
target_link_libraries(FunVM PRIVATE FVMLib spdlog::spdlog $<$<BOOL:${MINGW}>:ws2_32>)
# Compiler specific flags
if (MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /std:c++20 /W4 /WX)
else()
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Werror -pedantic)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
target_compile_options(${PROJECT_NAME} PRIVATE -fsanitize=address)
set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fsanitize=address")
endif()
endif()
# Testing
enable_testing()
add_executable(FVMTest
tests/FVMTestInstructions.cpp
tests/main.cpp
)
target_include_directories(FVMTest PRIVATE "${CMAKE_SOURCE_DIR}/src")
target_link_libraries(FVMTest PRIVATE FVMLib spdlog::spdlog GTest::gtest_main)
include(GoogleTest)
gtest_discover_tests(FVMTest)