-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
98 lines (75 loc) · 2.99 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
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
project(liblevenshtein
VERSION 4.0.0
DESCRIPTION "A library for generating Finite State Transducers based on Levenshtein Automata."
HOMEPAGE_URL "https://github.com/universal-automata/liblevenshtein-cpp"
LANGUAGES CXX)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(NOT MSVC)
SET(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
SET(CMAKE_C_FLAGS_DEBUG "-g -O0")
endif()
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
set(CMAKE_COMPILE_WARNING_AS_ERROR ON)
set(CMAKE_VERBOSE_MAKEFILE ON)
include(GNUInstallDirs)
option(BUILD_BASELINE_METRICS "Builds baseline distance metrics for validation" OFF)
option(BUILD_TESTS "Build liblevenshtein testing suite" OFF)
option(ENABLE_TEST_COVERAGE "Generate test coverage report" OFF)
option(ENABLE_LINTING "Enables the source code linter" OFF)
option(GENERATE_DOCS "Whether to generate the documentation" OFF)
if(ENABLE_LINTING)
find_program(CLANGXX_PATH clang++)
find_program(CLANG_TIDY_PATH clang-tidy)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_COMPILER "${CLANGXX_PATH}")
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_PATH}")
endif()
if(NOT BUILD_BASELINE_METRICS AND BUILD_TESTS)
message(WARNING "Building baseline metrics because they are required by the tests.")
SET(BUILD_BASELINE_METRICS ON)
endif()
add_subdirectory(proto)
add_subdirectory(third-party)
add_subdirectory(src)
set_target_properties(levenshtein PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR})
install(TARGETS levenshtein
EXPORT "${PROJECT_NAME}-targets"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
install(EXPORT "${PROJECT_NAME}-targets"
FILE "${PROJECT_NAME}-targets.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
include(CMakePackageConfigHelpers)
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}"
COMPATIBILITY AnyNewerVersion)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
if(BUILD_TESTS)
add_subdirectory(test)
endif()
if(GENERATE_DOCS)
find_package(Doxygen
REQUIRED dot
OPTIONAL_COMPONENTS mscgen dia)
set(DOXYFILE_PATH "${CMAKE_BINARY_DIR}/Doxyfile")
configure_file("${CMAKE_CURRENT_LIST_DIR}/Doxyfile.in" "${DOXYFILE_PATH}")
doxygen_add_docs(doxygen ALL
CONFIG_FILE "${DOXYFILE_PATH}"
)
endif()