-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
117 lines (90 loc) · 4.07 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
# root directory CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
project(Levenshtein)
# We use C++17 features.
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Ofast -Wall -pedantic -Wextra")
# Dynamic linking of shared libraries at runtime.
add_definitions("-DHAVE_DLOPEN")
# START CONFIGURATION
# Modify the following to set the buffer size to something other than the given
# default. Smaller is generally not faster. Make this twice your largest string.
# There is a hard max set at ~16KB. This is the wrong tool for the job if you
# are using it for strings that large.
set(BUFFER_SIZE 4096)
#set(BUFFER_SIZE 256)
# Select exactly one policy for handling negative max edit distance
add_compile_definitions(RETURN_ZERO_ON_BAD_MAX)
#add_compile_definitions(RETURN_NULL_ON_BAD_MAX)
# Select exactly one policy for handling strings that require a buffer size greater than the allocated buffer.
add_compile_definitions(TRUNCATE_ON_BUFFER_EXCEEDED) # Truncates the strings to fit within the buffer.
#add_compile_definitions(RETURN_ZERO_ON_BUFFER_EXCEEDED)
#add_compile_definitions(RETURN_NULL_ON_BUFFER_EXCEEDED)
# If you know the plugin directory of your MySQL installation, you can uncomment
# the following line and set it here. Otherwise, we attempt to get the path by
# executing `mysql_config --include`.
#set(MYSQL_PLUGIN_DIR "/opt/homebrew/opt/mysql/lib/plugin/")
# Likewise for the location of `mysql.h`, the MySQL include directory.
#set(MYSQL_INCLUDE "/opt/homebrew/include/mysql/")
# Use this file for a list of words for testing/benchmarking.
set(WORDS_FILE ${CMAKE_CURRENT_SOURCE_DIR}/tests/taxanames)
#set(WORDS_FILE "/usr/share/dict/words")
# END CONFIGURATION
# MySQL Include Directory
if(NOT DEFINED MYSQL_INCLUDE)
execute_process(COMMAND mysql_config --include
OUTPUT_VARIABLE MYSQL_INCLUDE
OUTPUT_STRIP_TRAILING_WHITESPACE)
# Fallback hail-Mary for Win64
if(WIN64 AND NOT DEFINED MYSQL_INCLUDE)
set(MYSQL_INCLUDE "-I C:/Program Files/MySQL/MySQL Server 8.0/include")
endif()
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MYSQL_INCLUDE}")
message(STATUS "CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
# Determine MYSQL_PLUGIN_DIR using mysql_config
if(NOT DEFINED MYSQL_PLUGIN_DIR)
if(INSTALL_PLUGINDIR)
set(MYSQL_PLUGIN_DIR ${INSTALL_PLUGINDIR})
else()
# Note: `mysql_config` must be in the PATH for this to work.
execute_process(COMMAND mysql_config --plugindir
OUTPUT_VARIABLE MYSQL_PLUGIN_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
# Fallback hail-Mary for Win64
if(WIN64 AND NOT DEFINED MYSQL_PLUGIN_DIR)
set(MYSQL_PLUGIN_DIR "C:\\Program Files\\MySQL\\MySQL Server 8.0\\lib\\plugin")
endif()
endif()
# Report configured values.
message(STATUS "Configured BUFFER_SIZE: ${BUFFER_SIZE}")
if(DEFINED MYSQL_PLUGIN_DIR)
message(STATUS "Configured MYSQL_PLUGIN_DIR: ${MYSQL_PLUGIN_DIR}")
else()
message(STATUS "MYSQL_PLUGIN_DIR is not set; installation will likely fail.")
endif()
if(DEFINED MYSQL_INCLUDE)
message(STATUS "Configured MYSQL_INCLUDE: ${MYSQL_INCLUDE}")
else()
message(STATUS "MYSQL_INCLUDE is not set; building will likely fail.")
endif()
message(STATUS "Configured WORDS_FILE for testing/benchmark: ${WORDS_FILE}")
# Report selected policies
if(RETURN_ZERO_ON_BAD_MAX)
message(STATUS "Policy for handling negative max edit distance: RETURN_ZERO_ON_BAD_MAX")
elseif(RETURN_NULL_ON_BAD_MAX)
message(STATUS "Policy for handling negative max edit distance: RETURN_NULL_ON_BAD_MAX")
endif()
if(TRUNCATE_ON_BUFFER_EXCEEDED)
message(STATUS "Policy for handling buffer size exceeded: TRUNCATE_ON_BUFFER_EXCEEDED")
elseif(RETURN_ZERO_ON_BUFFER_EXCEEDED)
message(STATUS "Policy for handling buffer size exceeded: RETURN_ZERO_ON_BUFFER_EXCEEDED")
elseif(RETURN_NULL_ON_BUFFER_EXCEEDED)
message(STATUS "Policy for handling buffer size exceeded: RETURN_NULL_ON_BUFFER_EXCEEDED")
endif()
# Add subdirectories
add_subdirectory(src)
add_subdirectory(tests)