-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
122 lines (97 loc) · 2.92 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
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
project(step-writer LANGUAGES CXX C)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g")
option(USE_BUNDLED_LIBS "Use bundled libraries instead of external" ON)
option(BUILD_TESTS "Build test executable" ON)
include(FetchContent)
if(USE_BUNDLED_LIBS)
# Fetch and include FTXUI
FetchContent_Declare(
ftxui
GIT_REPOSITORY https://github.com/ArthurSonzogni/ftxui
GIT_TAG v5.0.0
)
FetchContent_MakeAvailable(ftxui)
set(TS_LIB ts-lib)
set(TS_CPP ts-cpp)
# Add Tree-sitter C++ grammar
add_library(${TS_CPP} STATIC
third-party/tree-sitter-cpp/src/parser.c
third-party/tree-sitter-cpp/src/scanner.c
)
# Include directories for Tree-sitter C++ grammar
target_include_directories(${TS_CPP} PUBLIC
third-party/tree-sitter-cpp/src
)
# Add Tree-sitter library
add_library(${TS_LIB} STATIC
third-party/tree-sitter/lib/src/lib.c
)
# Include directories for Tree-sitter
target_include_directories(${TS_LIB} PUBLIC
third-party/tree-sitter/lib/include
third-party/tree-sitter/lib/src
)
else(USE_BUNDLED_LIBS)
set(TS_LIB tree-sitter)
set(TS_CPP tree-sitter-cpp)
find_package(PkgConfig REQUIRED)
find_package(ftxui REQUIRED)
pkg_check_modules(TREESITTER REQUIRED ${TS_LIB})
pkg_check_modules(TREESITTER REQUIRED ${TS_CPP})
endif(USE_BUNDLED_LIBS)
if(BUILD_TESTS)
# Fetch and include GoogleTest
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
endif(BUILD_TESTS)
# Define the main executable
add_executable(step-writer
src/main.cpp
src/Editor.cpp
src/Document.cpp
src/Row.cpp
src/TextFileViewer.cpp
src/DataFile.cpp
src/DirectoryFile.cpp
)
target_include_directories(step-writer PRIVATE include)
# Link libraries to the main executable
target_link_libraries(step-writer
PRIVATE ftxui::screen
PRIVATE ftxui::dom
PRIVATE ftxui::component
PRIVATE ${TS_LIB}
PRIVATE ${TS_CPP}
)
if(BUILD_TESTS)
# Enable testing
enable_testing()
# Define the test executable
add_executable(all-test
tests/RowTest.cpp
tests/DocumentTest.cpp
src/Row.cpp
src/Document.cpp
)
target_include_directories(all-test PRIVATE include)
# Link libraries to the test executable
target_link_libraries(all-test PRIVATE GTest::gtest_main
PRIVATE ftxui::component
PRIVATE ${TS_LIB}
PRIVATE ${TS_CPP})
# Include GoogleTest CMake functions
include(GoogleTest)
gtest_discover_tests(all-test)
endif(BUILD_TESTS)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif()