Skip to content

Commit 47dc666

Browse files
authored
CDRIVER-4668 add utf8proc library and update CMake configuration (#1319)
1 parent 9e7bf88 commit 47dc666

File tree

11 files changed

+18615
-1
lines changed

11 files changed

+18615
-1
lines changed

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ mongo_setting(ENABLE_ZSTD "Enable zstd compression support"
8585
mongo_setting(ENABLE_ZLIB "Enable zlib compression support"
8686
OPTIONS BUNDLED SYSTEM OFF
8787
DEFAULT VALUE BUNDLED)
88+
mongo_bool_setting(USE_BUNDLED_UTF8PROC "Enable building with utf8proc. Needed for SCRAM-SHA-256 authentication with non-ASCII passwords"
89+
ADVANCED)
8890
mongo_setting(
8991
ENABLE_SSL [[Enable TLS connection and SCRAM authentication.]]
9092
OPTIONS WINDOWS DARWIN OPENSSL LIBRESSL OFF AUTO
@@ -448,6 +450,10 @@ if (ENABLE_MONGOC)
448450

449451
set (SOURCE_DIR "${PROJECT_SOURCE_DIR}/")
450452

453+
set (UTF8PROC_SOURCES
454+
${SOURCE_DIR}/src/utf8proc-2.8.0/utf8proc.c
455+
)
456+
451457
set (ZLIB_SOURCES
452458
${SOURCE_DIR}/src/zlib-1.2.13/adler32.c
453459
${SOURCE_DIR}/src/zlib-1.2.13/crc32.c

THIRD_PARTY_NOTICES

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,33 @@ freely, subject to the following restrictions:
128128

129129
L. Peter Deutsch
130130
131+
132+
License notice for utf8proc
133+
-------------------------------------------------------------------------------
134+
135+
**utf8proc** is a software package originally developed
136+
by Jan Behrens and the rest of the Public Software Group, who
137+
deserve nearly all of the credit for this library, that is now maintained by the Julia-language developers. Like the original utf8proc,
138+
whose copyright and license statements are reproduced below, all new
139+
work on the utf8proc library is licensed under the [MIT "expat"
140+
license](http://opensource.org/licenses/MIT):
141+
142+
*Copyright © 2014-2021 by Steven G. Johnson, Jiahao Chen, Tony Kelman, Jonas Fonseca, and other contributors listed in the git history.*
143+
144+
Permission is hereby granted, free of charge, to any person obtaining a
145+
copy of this software and associated documentation files (the "Software"),
146+
to deal in the Software without restriction, including without limitation
147+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
148+
and/or sell copies of the Software, and to permit persons to whom the
149+
Software is furnished to do so, subject to the following conditions:
150+
151+
The above copyright notice and this permission notice shall be included in
152+
all copies or substantial portions of the Software.
153+
154+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
155+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
156+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
157+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
158+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
159+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
160+
DEALINGS IN THE SOFTWARE.

build/cmake/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ set (build_cmake_MODULES
77
FindSASL2.cmake
88
FindSnappy.cmake
99
FindSphinx.cmake
10+
FindUtf8Proc.cmake
1011
LoadVersion.cmake
1112
MongoCPackage.cmake
1213
MongoPlatform.cmake

build/cmake/FindUtf8Proc.cmake

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
if(USE_BUNDLED_UTF8PROC)
2+
message (STATUS "Enabling utf8proc (bundled)")
3+
add_library (utf8proc_obj OBJECT "${UTF8PROC_SOURCES}")
4+
set_property (TARGET utf8proc_obj PROPERTY POSITION_INDEPENDENT_CODE TRUE)
5+
target_compile_definitions (utf8proc_obj PUBLIC UTF8PROC_STATIC)
6+
else ()
7+
message (STATUS "Searching for utf8proc on system")
8+
find_package(PkgConfig)
9+
pkg_check_modules(PC_UTF8PROC REQUIRED libutf8proc IMPORTED_TARGET)
10+
add_library(utf8proc ALIAS PkgConfig::PC_UTF8PROC)
11+
endif()

src/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ set (src_zlib_DIST
1818
src/zlib-1.2.13/zlib.h
1919
src/zlib-1.2.13/zutil.h
2020
)
21+
22+
set (src_utf8proc_DIST
23+
src/utf8proc-2.8.0/utf8proc.h
24+
src/utf8proc-2.8.0/utf8proc.c
25+
src/utf8proc-2.8.0/utf8proc_data.c
26+
)
2127
# Strip leading directory components to make the paths relative for MakeDist.
2228
# The ZLIB_SOURCES list is set in the top-level CMakeLists.txt.
2329
foreach (zlib_src IN LISTS ZLIB_SOURCES)
@@ -38,6 +44,7 @@ set (src_DIST
3844
${src_zlib_DIST}
3945
${src_common_DIST}
4046
${src_kms_message_DIST}
47+
${src_utf8proc_DIST}
4148
PARENT_SCOPE
4249
)
4350

src/libmongoc/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ else ()
110110
message (STATUS "Disabling zlib compression")
111111
endif ()
112112

113-
114113
if (NOT ENABLE_ZSTD STREQUAL OFF)
115114
message (STATUS "Searching for compression library zstd")
116115
find_package(PkgConfig)
@@ -707,6 +706,14 @@ target_link_libraries(_mongoc-dependencies INTERFACE mongo::detail::c_platform)
707706
install(TARGETS _mongoc-dependencies EXPORT mongoc-targets)
708707
set_property(TARGET _mongoc-dependencies PROPERTY EXPORT_NAME detail::c_dependencies)
709708

709+
# utf8proc configuration
710+
find_package(Utf8Proc REQUIRED)
711+
if (USE_BUNDLED_UTF8PROC)
712+
list(APPEND SOURCES $<TARGET_OBJECTS:utf8proc_obj>)
713+
else()
714+
target_link_libraries(_mongoc-dependencies INTERFACE utf8proc)
715+
endif()
716+
710717
if(ENABLE_SRV)
711718
# Interface target defined by ResSearch.cmake:
712719
if(NOT TARGET mongo::detail::c_resolve)

src/libmongoc/src/mongoc-config.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
11
include(CMakeFindDependencyMacro)
22
find_dependency(bson-1.0 @MONGOC_MAJOR_VERSION@.@MONGOC_MINOR_VERSION@.@MONGOC_MICRO_VERSION@)
33
include("${CMAKE_CURRENT_LIST_DIR}/mongoc-targets.cmake")
4+
5+
set(_mongoc_built_with_bundled_utf8proc "@USE_BUNDLED_UTF8PROC@")
6+
if(NOT _mongoc_built_with_bundled_utf8proc AND NOT TARGET PkgConfig::PC_UTF8PROC)
7+
# libmongoc was compiled against an external utf8proc and links against a
8+
# FindPkgConfig-generated IMPORTED target. Find that package and generate that
9+
# imported target here:
10+
find_dependency(PkgConfig)
11+
pkg_check_modules(PC_UTF8PROC REQUIRED libutf8proc IMPORTED_TARGET GLOBAL)
12+
endif()

src/utf8proc-2.8.0/LICENSE.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
## utf8proc license ##
2+
3+
**utf8proc** is a software package originally developed
4+
by Jan Behrens and the rest of the Public Software Group, who
5+
deserve nearly all of the credit for this library, that is now maintained by the Julia-language developers. Like the original utf8proc,
6+
whose copyright and license statements are reproduced below, all new
7+
work on the utf8proc library is licensed under the [MIT "expat"
8+
license](http://opensource.org/licenses/MIT):
9+
10+
*Copyright &copy; 2014-2021 by Steven G. Johnson, Jiahao Chen, Tony Kelman, Jonas Fonseca, and other contributors listed in the git history.*
11+
12+
Permission is hereby granted, free of charge, to any person obtaining a
13+
copy of this software and associated documentation files (the "Software"),
14+
to deal in the Software without restriction, including without limitation
15+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
16+
and/or sell copies of the Software, and to permit persons to whom the
17+
Software is furnished to do so, subject to the following conditions:
18+
19+
The above copyright notice and this permission notice shall be included in
20+
all copies or substantial portions of the Software.
21+
22+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28+
DEALINGS IN THE SOFTWARE.
29+
30+
## Original utf8proc license ##
31+
32+
*Copyright (c) 2009, 2013 Public Software Group e. V., Berlin, Germany*
33+
34+
Permission is hereby granted, free of charge, to any person obtaining a
35+
copy of this software and associated documentation files (the "Software"),
36+
to deal in the Software without restriction, including without limitation
37+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
38+
and/or sell copies of the Software, and to permit persons to whom the
39+
Software is furnished to do so, subject to the following conditions:
40+
41+
The above copyright notice and this permission notice shall be included in
42+
all copies or substantial portions of the Software.
43+
44+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
45+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
46+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
47+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
48+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
49+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
50+
DEALINGS IN THE SOFTWARE.
51+
52+
## Unicode data license ##
53+
54+
This software contains data (`utf8proc_data.c`) derived from processing
55+
the Unicode data files. The following license applies to that data:
56+
57+
**COPYRIGHT AND PERMISSION NOTICE**
58+
59+
*Copyright (c) 1991-2007 Unicode, Inc. All rights reserved. Distributed
60+
under the Terms of Use in http://www.unicode.org/copyright.html.*
61+
62+
Permission is hereby granted, free of charge, to any person obtaining a
63+
copy of the Unicode data files and any associated documentation (the "Data
64+
Files") or Unicode software and any associated documentation (the
65+
"Software") to deal in the Data Files or Software without restriction,
66+
including without limitation the rights to use, copy, modify, merge,
67+
publish, distribute, and/or sell copies of the Data Files or Software, and
68+
to permit persons to whom the Data Files or Software are furnished to do
69+
so, provided that (a) the above copyright notice(s) and this permission
70+
notice appear with all copies of the Data Files or Software, (b) both the
71+
above copyright notice(s) and this permission notice appear in associated
72+
documentation, and (c) there is clear notice in each modified Data File or
73+
in the Software as well as in the documentation associated with the Data
74+
File(s) or Software that the data or software has been modified.
75+
76+
THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
77+
KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
78+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
79+
THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
80+
INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR
81+
CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
82+
USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
83+
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
84+
PERFORMANCE OF THE DATA FILES OR SOFTWARE.
85+
86+
Except as contained in this notice, the name of a copyright holder shall
87+
not be used in advertising or otherwise to promote the sale, use or other
88+
dealings in these Data Files or Software without prior written
89+
authorization of the copyright holder.
90+
91+
Unicode and the Unicode logo are trademarks of Unicode, Inc., and may be
92+
registered in some jurisdictions. All other trademarks and registered
93+
trademarks mentioned herein are the property of their respective owners.

0 commit comments

Comments
 (0)