Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
CMake
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mattias Ellert
CMake
Commits
01e9922d
Verified
Commit
01e9922d
authored
4 years ago
by
Sibi Siddharthan
Browse files
Options
Downloads
Patches
Plain Diff
FindIconv: Add version support
Issue: #21857
parent
ec5f7675
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Help/release/dev/FindIconv-version.rst
+4
-0
4 additions, 0 deletions
Help/release/dev/FindIconv-version.rst
Modules/FindIconv.cmake
+43
-1
43 additions, 1 deletion
Modules/FindIconv.cmake
with
47 additions
and
1 deletion
Help/release/dev/FindIconv-version.rst
0 → 100644
+
4
−
0
View file @
01e9922d
FindIconv-version
-----------------
* The :module:`FindIconv` module now has version support.
This diff is collapsed.
Click to expand it.
Modules/FindIconv.cmake
+
43
−
1
View file @
01e9922d
...
...
@@ -25,6 +25,24 @@ The following variables are provided to indicate iconv support:
The iconv libraries to be linked.
.. variable:: Iconv_VERSION
.. versionadded:: 3.21
The version of iconv found (x.y)
.. variable:: Iconv_VERSION_MAJOR
.. versionadded:: 3.21
The major version of iconv
.. variable:: Iconv_VERSION_MINOR
.. versionadded:: 3.21
The minor version of iconv
.. variable:: Iconv_IS_BUILT_IN
A variable indicating whether iconv support is stemming from the
...
...
@@ -51,6 +69,10 @@ The following cache variables may also be set:
On POSIX platforms, iconv might be part of the C library and the cache
variables ``Iconv_INCLUDE_DIR`` and ``Iconv_LIBRARY`` might be empty.
.. note::
Some libiconv implementations don't embed the version number in their header files.
In this case the variables ``Iconv_VERSION*`` will be empty.
#]=======================================================================]
include
(
${
CMAKE_CURRENT_LIST_DIR
}
/CMakePushCheckState.cmake
)
...
...
@@ -118,9 +140,29 @@ find_library(Iconv_LIBRARY
mark_as_advanced
(
Iconv_INCLUDE_DIR
)
mark_as_advanced
(
Iconv_LIBRARY
)
# NOTE: glibc's iconv.h does not define _LIBICONV_VERSION
if
(
Iconv_INCLUDE_DIR AND NOT Iconv_IS_BUILT_IN
)
file
(
STRINGS
${
Iconv_INCLUDE_DIR
}
/iconv.h Iconv_VERSION_DEFINE REGEX
"_LIBICONV_VERSION (.*)"
)
if
(
Iconv_VERSION_DEFINE MATCHES
"(0x[A-Fa-f0-9]+)"
)
set
(
Iconv_VERSION_NUMBER
"
${
CMAKE_MATCH_1
}
"
)
# encoding -> version number: (major<<8) + minor
math
(
EXPR Iconv_VERSION_MAJOR
"
${
Iconv_VERSION_NUMBER
}
>> 8"
OUTPUT_FORMAT HEXADECIMAL
)
math
(
EXPR Iconv_VERSION_MINOR
"
${
Iconv_VERSION_NUMBER
}
- (
${
Iconv_VERSION_MAJOR
}
<< 8)"
OUTPUT_FORMAT HEXADECIMAL
)
math
(
EXPR Iconv_VERSION_MAJOR
"
${
Iconv_VERSION_MAJOR
}
"
OUTPUT_FORMAT DECIMAL
)
math
(
EXPR Iconv_VERSION_MINOR
"
${
Iconv_VERSION_MINOR
}
"
OUTPUT_FORMAT DECIMAL
)
set
(
Iconv_VERSION
"
${
Iconv_VERSION_MAJOR
}
.
${
Iconv_VERSION_MINOR
}
"
)
endif
()
unset
(
Iconv_VERSION_DEFINE
)
unset
(
Iconv_VERSION_NUMBER
)
endif
()
include
(
${
CMAKE_CURRENT_LIST_DIR
}
/FindPackageHandleStandardArgs.cmake
)
if
(
NOT Iconv_IS_BUILT_IN
)
find_package_handle_standard_args
(
Iconv REQUIRED_VARS Iconv_LIBRARY Iconv_INCLUDE_DIR
)
find_package_handle_standard_args
(
Iconv REQUIRED_VARS Iconv_LIBRARY Iconv_INCLUDE_DIR
VERSION_VAR Iconv_VERSION
)
else
()
find_package_handle_standard_args
(
Iconv REQUIRED_VARS Iconv_LIBRARY
)
endif
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment