This repository has been archived by the owner on Nov 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
146 lines (122 loc) · 4.13 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
## For this to work on windows the rust lib must be compiled
## with the toolchain
## stable-x86_64-pc-windows-gnu
## as a static lib with linked libraries listed by:
## cargo rustc --lib -- --print native-static-libs --crate-type staticlib
##
## base mingw from clion is ok for the compilation from within CLion
## no mingw is required in the main system due to rustup shipping it with component rust-mingw
cmake_minimum_required(VERSION 3.10)
project(toidb)
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
set(CMAKE_CXX_STANDARD 20)
# Windows must be built with rust stable-x86_64-pc-windows-gnu as target
if (WIN32)
# Windows needs dynamic libraries 100%
set(BUILD_SHARED_LIBS ON)
# We do want static libgcc tho
set(CMAKE_EXE_LINKER_FLAGS -static)
else()
# Unix doesn't
set(BUILD_SHARED_LIBS OFF)
endif(WIN32)
# Agregamos `googltest` para poder escribir pruebas del código
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.12.1
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
# Agregamos corrosion para compilar rust por default
FetchContent_Declare(
Corrosion
GIT_REPOSITORY https://github.com/corrosion-rs/corrosion.git
GIT_TAG v0.2.1
)
FetchContent_MakeAvailable(Corrosion)
# Agregamos libfort para poder imprimir tablas
FetchContent_Declare(
libfort
GIT_REPOSITORY https://github.com/seleznevae/libfort.git
GIT_TAG 41237162a9bd34a30a88069ee4e230584ae8d674
)
FetchContent_MakeAvailable(libfort)
# Agregamos `cxxopts` para poder parsear argumentos de la línea de comandos
FetchContent_Declare(
cxxopts
GIT_REPOSITORY https://github.com/jarro2783/cxxopts
GIT_TAG v3.0.0
)
FetchContent_MakeAvailable(cxxopts)
corrosion_import_crate(MANIFEST_PATH server/Cargo.toml)# PROFILE release)
corrosion_import_crate(MANIFEST_PATH fm/Cargo.toml)# PROFILE release)
corrosion_import_crate(MANIFEST_PATH serializer/Cargo.toml)# PROFILE release)
# Agregamos fmt, una libreria de formateo de strings moderna
FetchContent_Declare(
fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
GIT_TAG 9.1.0
)
FetchContent_MakeAvailable(fmt)
FetchContent_Declare(
Result
GIT_REPOSITORY https://github.com/bitwizeshift/result.git
GIT_TAG v1.0.0
)
FetchContent_MakeAvailable(Result)
# For profiling, disable when building the release
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g")
enable_testing()
set(LIBRARIES
src/lib/server.hpp
src/lib/database.cpp
src/lib/database.hpp
src/lib/table.cpp
src/lib/table.hpp
src/lib/fm.cpp
src/lib/fm.hpp
src/lib/analyzer/tokenizer.cpp
src/lib/analyzer/tokenizer.hpp
src/lib/analyzer/parser.cpp
src/lib/analyzer/parser.hpp
src/lib/analyzer.hpp
src/lib/analyzer/automata.cpp
src/lib/analyzer/automata.hpp
src/lib/logger.cpp
src/lib/logger.hpp
src/lib/linkedList.cpp
src/lib/linkedList.hpp
src/lib/serializer.cpp
src/lib/serializer.hpp
src/lib/columnInstance.hpp
src/lib/databases.hpp)
add_executable(toidb
src/main.cpp
${LIBRARIES}
)
add_executable(
proyecto-tests
tests/server.cc # Agregamos los tests
${LIBRARIES}
tests/database.cc
tests/table.cc
tests/fm.cc
tests/tokenizer..cc
tests/parser.cc
tests/automata.cc
tests/serializer.cc
)
target_link_libraries(proyecto-tests PRIVATE fort GTest::gtest_main fmt::fmt-header-only fm Result::Result serializer)
target_link_libraries(toidb PRIVATE fort PUBLIC tcpserver fmt::fmt-header-only fm Result::Result serializer cxxopts)
include(GoogleTest)
gtest_discover_tests(proyecto-tests)
add_custom_command(
TARGET toidb POST_BUILD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/toi/
COMMAND cargo install --path .
VERBATIM
)