Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
9feaa6be
Commit
9feaa6be
authored
Nov 17, 2021
by
Sergei Krivonos
Committed by
Sergei Krivonos
Dec 04, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve LibFMT detection
Signed-off-by:
Sergei Krivonos
<
sergei.krivonos@mariadb.com
>
parent
467c7b2b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
10 deletions
+45
-10
.gitignore
.gitignore
+1
-1
cmake/libfmt.cmake
cmake/libfmt.cmake
+27
-3
sql/CMakeLists.txt
sql/CMakeLists.txt
+2
-1
sql/item_strfunc.cc
sql/item_strfunc.cc
+15
-5
No files found.
.gitignore
View file @
9feaa6be
...
...
@@ -238,7 +238,6 @@ storage/perfschema/pfs_config.h
storage/rocksdb/ldb
storage/rocksdb/myrocks_hotbackup
storage/rocksdb/mysql_ldb
storage/rocksdb/myrocks_hotbackup
storage/rocksdb/rdb_source_revision.h
storage/rocksdb/sst_dump
strings/conf_to_src
...
...
@@ -619,3 +618,4 @@ tests/mariadb-client-test
versioninfo_dll.rc
versioninfo_exe.rc
win/packaging/ca/symlinks.cc
/_Deparsed_XSubs.pm
cmake/libfmt.cmake
View file @
9feaa6be
INCLUDE
(
CheckCXXSourceCompiles
)
INCLUDE
(
ExternalProject
)
SET
(
WITH_LIBFMT
"auto"
CACHE STRING
"Which libfmt to use (possible values are 'bundled', 'system', or 'auto')"
)
...
...
@@ -12,6 +10,7 @@ MACRO(BUNDLE_LIBFMT)
SET
(
fmt_byproducts BUILD_BYPRODUCTS
${
LIBFMT_INCLUDE_DIR
}
/fmt/format-inl.h
)
ENDIF
()
INCLUDE
(
ExternalProject
)
ExternalProject_Add
(
libfmt
PREFIX
"
${
dir
}
"
...
...
@@ -26,17 +25,42 @@ ENDMACRO()
MACRO
(
CHECK_LIBFMT
)
IF
(
WITH_LIBFMT STREQUAL
"system"
OR WITH_LIBFMT STREQUAL
"auto"
)
FIND_PACKAGE
(
fmt
)
IF
(
fmt_FOUND
)
set
(
HAVE_SYSTEM_LIBFMT
${
fmt_FOUND
}
)
ENDIF
()
FIND_LIBRARY
(
FMT_LIB_FOUND fmt
)
IF
(
FMT_LIB_FOUND
)
set
(
FMT_LIBRARIES fmt CACHE STRING
"LibFormat libraries"
FORCE
)
ADD_DEFINITIONS
(
-DLINK_SYSTEM_LIBFMT
)
ELSE
(
FMT_LIB_FOUND
)
set
(
FMT_HEADER_ONLY
"#define FMT_HEADER_ONLY 1"
)
set
(
FMT_LIBRARIES
""
CACHE STRING
"LibFormat libraries"
FORCE
)
ENDIF
(
FMT_LIB_FOUND
)
INCLUDE
(
CheckCXXSourceCompiles
)
CHECK_CXX_SOURCE_COMPILES
(
"#define FMT_STATIC_THOUSANDS_SEPARATOR ','
#define FMT_HEADER_ONLY 1
${
FMT_HEADER_ONLY
}
#include <fmt/format-inl.h>
#include <iostream>
#include <string>
#if FMT_VERSION < 70000
using namespace ::fmt::internal;
#else
using namespace ::fmt::detail;
#endif
int main() {
fmt::format_args::format_arg arg=
fmt::detail::make_arg<fmt::format_context>(42);
std::cout << fmt::vformat(
\"
The answer is {}.
\"
,
fmt::format_args(&arg, 1));
return 0;
}"
HAVE_SYSTEM_LIBFMT
)
IF
(
HAVE_SYSTEM_LIBFMT
)
ADD_DEFINITIONS
(
-DHAVE_SYSTEM_LIBFMT
)
ENDIF
()
ENDIF
()
IF
(
NOT HAVE_SYSTEM_LIBFMT OR WITH_LIBFMT STREQUAL
"bundled"
)
IF
(
WITH_LIBFMT STREQUAL
"system"
)
...
...
sql/CMakeLists.txt
View file @
9feaa6be
...
...
@@ -208,6 +208,7 @@ MAYBE_DISABLE_IPO(sql)
DTRACE_INSTRUMENT
(
sql
)
TARGET_LINK_LIBRARIES
(
sql
mysys mysys_ssl dbug strings vio pcre2-8
${
FMT_LIBRARIES
}
tpool
${
LIBWRAP
}
${
LIBCRYPT
}
${
CMAKE_DL_LIBS
}
${
CMAKE_THREAD_LIBS_INIT
}
${
SSL_LIBRARIES
}
...
...
@@ -277,7 +278,7 @@ IF(MSVC OR CMAKE_SYSTEM_NAME MATCHES AIX)
ENDIF
()
ADD_LIBRARY
(
sql_builtins STATIC
${
CMAKE_CURRENT_BINARY_DIR
}
/sql_builtin.cc
)
TARGET_LINK_LIBRARIES
(
sql_builtins
${
MYSQLD_STATIC_PLUGIN_LIBS
}
)
TARGET_LINK_LIBRARIES
(
sql_builtins
PUBLIC
${
MYSQLD_STATIC_PLUGIN_LIBS
}
)
MYSQL_ADD_EXECUTABLE
(
mariadbd
${
MYSQLD_SOURCE
}
DESTINATION
${
INSTALL_SBINDIR
}
COMPONENT Server
)
...
...
sql/item_strfunc.cc
View file @
9feaa6be
...
...
@@ -57,8 +57,18 @@ C_MODE_END
/* fmtlib include (https://fmt.dev/). */
#define FMT_STATIC_THOUSANDS_SEPARATOR ','
#if !defined(HAVE_SYSTEM_LIBFMT) && !defined(LINK_SYSTEM_LIBFMT)
#define FMT_HEADER_ONLY 1
#include "fmt/format-inl.h"
#endif
#include <fmt/format-inl.h>
#if FMT_VERSION < 70000
using
namespace
::
fmt
::
internal
;
#else
using
namespace
::
fmt
::
detail
;
#endif
size_t
username_char_length
=
USERNAME_CHAR_LENGTH
;
...
...
@@ -1393,14 +1403,14 @@ String *Item_func_sformat::val_str(String *res)
switch
(
args
[
carg
]
->
result_type
())
{
case
INT_RESULT
:
vargs
[
carg
-
1
]
=
fmt
::
detail
::
make_arg
<
ctx
>
(
args
[
carg
]
->
val_int
());
vargs
[
carg
-
1
]
=
make_arg
<
ctx
>
(
args
[
carg
]
->
val_int
());
break
;
case
DECIMAL_RESULT
:
// TODO
case
REAL_RESULT
:
if
(
args
[
carg
]
->
field_type
()
==
MYSQL_TYPE_FLOAT
)
vargs
[
carg
-
1
]
=
fmt
::
detail
::
make_arg
<
ctx
>
((
float
)
args
[
carg
]
->
val_real
());
vargs
[
carg
-
1
]
=
make_arg
<
ctx
>
((
float
)
args
[
carg
]
->
val_real
());
else
vargs
[
carg
-
1
]
=
fmt
::
detail
::
make_arg
<
ctx
>
(
args
[
carg
]
->
val_real
());
vargs
[
carg
-
1
]
=
make_arg
<
ctx
>
(
args
[
carg
]
->
val_real
());
break
;
case
STRING_RESULT
:
if
(
!
(
parg
=
args
[
carg
]
->
val_str
(
&
val_arg
[
carg
-
1
])))
...
...
@@ -1408,7 +1418,7 @@ String *Item_func_sformat::val_str(String *res)
delete
[]
vargs
;
return
NULL
;
}
vargs
[
carg
-
1
]
=
fmt
::
detail
::
make_arg
<
ctx
>
(
*
parg
);
vargs
[
carg
-
1
]
=
make_arg
<
ctx
>
(
*
parg
);
break
;
case
TIME_RESULT
:
// TODO
case
ROW_RESULT
:
// TODO
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment