-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
117 lines (99 loc) · 4.07 KB
/
Copy pathCMakeLists.txt
File metadata and controls
117 lines (99 loc) · 4.07 KB
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
# Minimum CMake version required
cmake_minimum_required(VERSION 3.10)
# Name of the main project
project(TreesAndGraphs)
# Set the C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# Common include directory
set(COMMON_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/inc")
include_directories(${COMMON_INCLUDE_DIR})
# List of tree modules and their corresponding file prefixes
set(TREE_MODULES_AND_FILES
Trees/BinarySearchTrees binary_search_tree
Trees/AVLTrees avl_tree
Trees/BTrees b_tree
Trees/BPTrees b_plus_tree
Trees/CompleteBinaryTrees complete_binary_tree
Trees/FullBinaryTrees full_binary_tree
Trees/PerfectBinaryTrees perfect_binary_tree
Trees/FenwickTrees fenwick_tree
Trees/SegmentTrees segment_tree
Trees/SplayTrees splay_tree
Trees/Treaps treap
)
# List of graph modules and their corresponding file prefixes
set(GRAPH_MODULES_AND_FILES
Graphs/UndirectedGraphs undirected_graph
Graphs/DirectedGraphs directed_graph
Graphs/DFSGraphs dfs_graph
Graphs/BFSGraphs bfs_graph
Graphs/DirectedAcyclicGraphs directed_acyclic_graph
# Graphs/AdjacencyListGraphs adjacency_list_graph
# Graphs/AdjacencyMatrixGraphs adjacency_matrix_graph
# Graphs/BipartiteGraphs bipartite_graph
# Graphs/Hypergraphs hypergraph
# Graphs/PlanarGraphs planar_graph
# Graphs/Multigraphs multigraph
# Graphs/TreeGraphs tree_graph
# Graphs/WeightedGraphs weighted_graph
)
# Helper function to collect sources and headers for a tree module
macro(add_tree_executable MODULE_NAME FILE_PREFIX)
# Add debug message
message(STATUS "Adding executable for tree module: ${MODULE_NAME}, file prefix: ${FILE_PREFIX}")
# Add executable for the tree module
add_executable(${FILE_PREFIX}
${MODULE_NAME}/examples/${FILE_PREFIX}_example.cpp
${MODULE_NAME}/include/${FILE_PREFIX}.h
${MODULE_NAME}/source/${FILE_PREFIX}.tpp
)
# Include source and common include directories
target_include_directories(${FILE_PREFIX} PRIVATE
${CMAKE_SOURCE_DIR}/${MODULE_NAME}/include
${COMMON_INCLUDE_DIR}
)
endmacro()
# Helper function to collect sources and headers for a graph module
macro(add_graph_executable MODULE_NAME FILE_PREFIX)
# Add debug message
message(STATUS "Adding executable for graph module: ${MODULE_NAME}, file prefix: ${FILE_PREFIX}")
# Add executable for the graph module
add_executable(${FILE_PREFIX}
${MODULE_NAME}/examples/${FILE_PREFIX}_example.cpp
${MODULE_NAME}/include/${FILE_PREFIX}.h
${MODULE_NAME}/source/${FILE_PREFIX}.tpp
)
# Include source and common include directories
target_include_directories(${FILE_PREFIX} PRIVATE
${CMAKE_SOURCE_DIR}/${MODULE_NAME}/include
${COMMON_INCLUDE_DIR}
)
endmacro()
# Loop over all tree modules and add their executables
list(LENGTH TREE_MODULES_AND_FILES num_trees)
math(EXPR num_tree_modules "${num_trees} / 2 - 1")
foreach(idx RANGE 0 ${num_tree_modules})
math(EXPR module_idx "${idx} * 2")
math(EXPR file_idx "${module_idx} + 1")
list(GET TREE_MODULES_AND_FILES ${module_idx} MODULE_NAME)
list(GET TREE_MODULES_AND_FILES ${file_idx} FILE_PREFIX)
add_tree_executable(${MODULE_NAME} ${FILE_PREFIX})
endforeach()
# Loop over all graph modules and add their executables
list(LENGTH GRAPH_MODULES_AND_FILES num_graphs)
math(EXPR num_graph_modules "${num_graphs} / 2 - 1")
foreach(idx RANGE 0 ${num_graph_modules})
math(EXPR module_idx "${idx} * 2")
math(EXPR file_idx "${module_idx} + 1")
list(GET GRAPH_MODULES_AND_FILES ${module_idx} MODULE_NAME)
list(GET GRAPH_MODULES_AND_FILES ${file_idx} FILE_PREFIX)
add_graph_executable(${MODULE_NAME} ${FILE_PREFIX})
endforeach()
# Add include directories for Nodes
include_directories(
${CMAKE_SOURCE_DIR}/Nodes/defaultNodes
${CMAKE_SOURCE_DIR}/Nodes/BTreeNodes
${CMAKE_SOURCE_DIR}/Nodes/BPTreeNodes
${CMAKE_SOURCE_DIR}/Nodes/TreapNode
)