-
Notifications
You must be signed in to change notification settings - Fork 8
/
CMakeLists.txt
112 lines (90 loc) · 2.93 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
cmake_minimum_required(VERSION 3.15)
project(is_utf8
DESCRIPTION "Fast UTF-8 Validation"
LANGUAGES CXX
VERSION 1.4.1
)
include(GNUInstallDirs)
include(CTest)
option(IS_UTF8_SANITIZE "Sanitize addresses" OFF)
if (NOT CMAKE_BUILD_TYPE)
message(STATUS "No build type selected, default to Release")
if(IS_UTF8_SANITIZE)
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
else()
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
endif()
endif()
# We compile tools, tests, etc. with C++ 11. Override yourself if you need on a
# target.
set(IS_UTF8_CXX_STANDARD 11 CACHE STRING "the C++ standard to use for is_utf8")
set(CMAKE_CXX_STANDARD ${IS_UTF8_CXX_STANDARD})
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_MACOSX_RPATH OFF)
set(IS_UTF8_LIB_VERSION "1.4.1" CACHE STRING "is_utf8 library version")
set(IS_UTF8_LIB_SOVERSION "1" CACHE STRING "is_utf8 library soversion")
set(IS_UTF8_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
add_subdirectory(src)
if (BUILD_TESTING)
message(STATUS "The tests are enabled.")
add_subdirectory(tests)
else()
message(STATUS "The tests are disabled.")
endif(BUILD_TESTING)
add_subdirectory(benchmarks)
message(STATUS "Compiling using the C++ standard:" ${CMAKE_CXX_STANDARD})
# ---- Install rules ----
add_library(is_utf8::is_utf8 ALIAS is_utf8)
set_target_properties(
is_utf8 PROPERTIES
VERSION "${IS_UTF8_LIB_VERSION}"
SOVERSION "${IS_UTF8_LIB_SOVERSION}"
WINDOWS_EXPORT_ALL_SYMBOLS YES
)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
install(
FILES include/is_utf8.h
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
COMPONENT is_utf8_Development
)
install(
TARGETS is_utf8
EXPORT is_utf8Targets
RUNTIME COMPONENT is_utf8_Runtime
LIBRARY COMPONENT is_utf8_Runtime
NAMELINK_COMPONENT is_utf8_Development
ARCHIVE COMPONENT is_utf8_Development
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
configure_file(cmake/is_utf8-config.cmake.in is_utf8-config.cmake @ONLY)
write_basic_package_version_file(
is_utf8-config-version.cmake
COMPATIBILITY SameMinorVersion
)
set(
IS_UTF8_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/is_utf8"
CACHE STRING "CMake package config location relative to the install prefix"
)
mark_as_advanced(IS_UTF8_INSTALL_CMAKEDIR)
install(
FILES
"${PROJECT_BINARY_DIR}/is_utf8-config.cmake"
"${PROJECT_BINARY_DIR}/is_utf8-config-version.cmake"
DESTINATION "${IS_UTF8_INSTALL_CMAKEDIR}"
COMPONENT is_utf8_Development
)
#
# CPack
#
if(is_top_project)
set(CPACK_PACKAGE_VENDOR "Daniel Lemire")
set(CPACK_PACKAGE_CONTACT "[email protected]")
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE-MIT")
set(CPACK_RPM_PACKAGE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE-MIT")
set(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README.md")
set(CPACK_SOURCE_GENERATOR "TGZ;ZIP")
include(CPack)
endif()
# ----