forked from Nick-Nuon/simdutf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
145 lines (121 loc) · 4.17 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
cmake_minimum_required(VERSION 3.15)
project(simdutf
DESCRIPTION "Fast Unicode validation, transcoding and processing"
LANGUAGES CXX
VERSION 3.2.7
)
include (TestBigEndian)
TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
if(IS_BIG_ENDIAN)
message(STATUS "Big-endian system detected.")
endif()
include(GNUInstallDirs)
# The following requires CMake 3.21.
# if(PROJECT_IS_TOP_LEVEL)
# message(STATUS "Building simdutf as a top-level project.")
# include(CTest)
#else()
# message(STATUS "Building simdutf as a subproject.")
#endif(PROJECT_IS_TOP_LEVEL)
include(CTest)
include(cmake/simdutf-flags.cmake)
set(SIMDUTF_LIB_VERSION "3.2.14" CACHE STRING "simdutf library version")
set(SIMDUTF_LIB_SOVERSION "4" CACHE STRING "simdutf library soversion")
option(SIMDUTF_TESTS "Whether the tests are included as part of the CMake Build." ON)
option(SIMDUTF_BENCHMARKS "Whether the benchmarks are included as part of the CMake Build." ON)
option(SIMDUTF_TOOLS "Whether the tools are included as part of the CMake build." ON)
option(SIMDUTF_ICONV "Whether to use iconv as part of the CMake build if available." ON)
set(SIMDUTF_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
add_subdirectory(src)
add_subdirectory(singleheader)
if (SIMDUTF_TESTS)
message(STATUS "The tests are enabled.")
add_subdirectory(tests)
else(SIMDUTF_TESTS)
message(STATUS "The tests are disabled.")
endif(SIMDUTF_TESTS)
if (SIMDUTF_TOOLS)
if(CMAKE_CXX_COMPILER_ID MATCHES GNU AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0)
message(STATUS "The benchmark tool requires GCC 8.0 or better.")
else()
add_subdirectory(tools)
endif()
endif()
if (SIMDUTF_BENCHMARKS)
if(NOT SIMDUTF_TESTS)
message(STATUS "You have enabled the benchmarks, but not the tests. We don't allow running the benchmarks without the tests.")
elif((CMAKE_CXX_COMPILER_ID MATCHES GNU) AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.0"))
message(STATUS "The benchmark tool requires GCC 8.0 or better.")
else()
message(STATUS "The benchmarks can be disabled by setting SIMDUTF_BENCHMARKS, e.g., -D SIMDUTF_BENCHMARKS=OFF.")
add_subdirectory(benchmarks)
endif()
else()
message(STATUS "The benchmarks can be enabled by setting SIMDUTF_BENCHMARKS, e.g., -D SIMDUTF_BENCHMARKS=ON.")
endif()
message(STATUS "Compiling using the C++ standard:" ${CMAKE_CXX_STANDARD})
# ---- Install rules ----
add_library(simdutf::simdutf ALIAS simdutf)
set_target_properties(
simdutf PROPERTIES
VERSION "${SIMDUTF_LIB_VERSION}"
SOVERSION "${SIMDUTF_LIB_SOVERSION}"
WINDOWS_EXPORT_ALL_SYMBOLS YES
)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
install(
FILES include/simdutf.h
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
COMPONENT simdutf_Development
)
install(
DIRECTORY include/simdutf
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
COMPONENT simdutf_Development
)
install(
TARGETS simdutf
EXPORT simdutfTargets
RUNTIME COMPONENT simdutf_Runtime
LIBRARY COMPONENT simdutf_Runtime
NAMELINK_COMPONENT simdutf_Development
ARCHIVE COMPONENT simdutf_Development
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
configure_file(cmake/simdutf-config.cmake.in simdutf-config.cmake @ONLY)
write_basic_package_version_file(
simdutf-config-version.cmake
COMPATIBILITY SameMinorVersion
)
set(
SIMDUTF_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/simdutf"
CACHE STRING "CMake package config location relative to the install prefix"
)
mark_as_advanced(SIMDUTF_INSTALL_CMAKEDIR)
install(
FILES
"${PROJECT_BINARY_DIR}/simdutf-config.cmake"
"${PROJECT_BINARY_DIR}/simdutf-config-version.cmake"
DESTINATION "${SIMDUTF_INSTALL_CMAKEDIR}"
COMPONENT simdutf_Development
)
install(
EXPORT simdutfTargets
NAMESPACE simdutf::
DESTINATION "${SIMDUTF_INSTALL_CMAKEDIR}"
COMPONENT example_Development
)
#
# CPack
#
if(is_top_project)
set(CPACK_PACKAGE_VENDOR "Daniel Lemire")
set(CPACK_PACKAGE_CONTACT "lemire@gmail.com")
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()
# ----