This repository has been archived by the owner on Dec 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
93 lines (77 loc) · 2.88 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
81
82
83
84
85
86
87
88
89
90
91
92
93
cmake_minimum_required(VERSION 3.1.2)
project(inspect)
include(FindPkgConfig)
include_directories(
src
thirdparty/googletest/include
)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/generated)
add_custom_command(
COMMAND ragel ${CMAKE_CURRENT_SOURCE_DIR}/src/address.rl -o ${CMAKE_CURRENT_BINARY_DIR}/generated/address.cpp
DEPENDS src/address.rl ${CMAKE_CURRENT_BINARY_DIR}/generated
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/generated/address.cpp
)
add_custom_command(
COMMAND ragel ${CMAKE_CURRENT_SOURCE_DIR}/src/console.rl -o ${CMAKE_CURRENT_BINARY_DIR}/generated/console.cpp
DEPENDS src/console.rl ${CMAKE_CURRENT_BINARY_DIR}/generated
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/generated/console.cpp
)
add_custom_command(
COMMAND ragel ${CMAKE_CURRENT_SOURCE_DIR}/src/formula.rl -o ${CMAKE_CURRENT_BINARY_DIR}/generated/formula.cpp
DEPENDS src/formula.rl ${CMAKE_CURRENT_BINARY_DIR}/generated
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/generated/formula.cpp
)
# Copy parser.y to build directory
add_custom_command(
COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/src/parser.y ${CMAKE_CURRENT_BINARY_DIR}/generated/parser.y
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/parser.y ${CMAKE_CURRENT_BINARY_DIR}/generated
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/generated/parser.y
)
# Copy parser.h to build directory
add_custom_command(
COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/src/parser.h ${CMAKE_CURRENT_BINARY_DIR}/generated/parser.h
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/parser.h ${CMAKE_CURRENT_BINARY_DIR}/generated
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/generated/parser.h
)
# Copy lempar.c template into build directory
add_custom_command(
COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/etc/lempar.c ${CMAKE_CURRENT_BINARY_DIR}/generated/lempar.c
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/etc/lempar.c
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/generated/lempar.c
)
# Generate a parser from parser.y
add_custom_command(
COMMAND lemon -m -q ${CMAKE_CURRENT_BINARY_DIR}/generated/parser.y
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/generated/parser.y ${CMAKE_CURRENT_BINARY_DIR}/generated/parser.h
${CMAKE_CURRENT_BINARY_DIR}/generated/lempar.c
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/generated/parser.c
)
# Inspect library
add_library(inspect
${CMAKE_CURRENT_BINARY_DIR}/generated/address.cpp
${CMAKE_CURRENT_BINARY_DIR}/generated/formula.cpp
${CMAKE_CURRENT_BINARY_DIR}/generated/parser.c
src/ast.cpp
src/sheet.cpp
)
# Unit tests executable
add_executable(inspect_tests
test/address_test.cpp
test/sheet_test.cpp
)
# Build local gtest
set(gtest_force_shared_crt ON)
option(BUILD_GMOCK FALSE)
option(INSTALL_GTEST FALSE)
add_subdirectory(thirdparty/googletest)
target_link_libraries(inspect_tests
gtest
gtest_main
inspect
)
add_executable(inspect_console
${CMAKE_CURRENT_BINARY_DIR}/generated/console.cpp
)
target_link_libraries(inspect_console
inspect
)