-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
59 lines (54 loc) · 1.68 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
# Set minimum required version of CMake
cmake_minimum_required(VERSION 3.12)
# Set name of project (as PROJECT_NAME) and C/C++ standards
project(x1algol VERSION 0.1 DESCRIPTION "X1 Algol Simulator")
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
add_compile_options(-Wall -Werror -Wshadow)
# Enable cppcheck by default
find_program(Cppcheck NAMES cppcheck)
if(NOT (Cppcheck MATCHES "NOTFOUND"))
message(STATUS "Found Cppcheck: ${Cppcheck}")
set(CMAKE_CXX_CPPCHECK "${Cppcheck}"
"--std=c++17"
"--enable=style"
"--error-exitcode=1" # Fail on any issues
"--inline-suppr" # Enable inline control like // cppcheck-suppress "id"
"--quiet" # No progress report messages
"--suppress=*:*/_deps/*" # Ignore issues in Googletest
"--library=${CMAKE_SOURCE_DIR}/tests/googletest.xml" # Parse TEST() macro properly
)
if(APPLE)
list(APPEND CMAKE_CXX_CPPCHECK "--check-level=exhaustive")
endif()
endif()
# Get git commit hash and revision count
execute_process(
COMMAND git log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE GIT_HASH
)
execute_process(
COMMAND git rev-list HEAD --count
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE GIT_REVCOUNT
)
#
# Download GoogleTest
#
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.15.2
EXCLUDE_FROM_ALL
)
FetchContent_MakeAvailable(googletest)
include(GoogleTest)
enable_testing()
add_subdirectory(compiler)
add_subdirectory(simulator)
add_subdirectory(library)
add_subdirectory(tests)