Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
biboumi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
90
Issues
90
List
Boards
Labels
Service Desk
Milestones
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
louiz’
biboumi
Commits
ef014f7d
Commit
ef014f7d
authored
Nov 10, 2013
by
louiz’
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Properly detect iconv features to compile
parent
6a43d350
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
3 deletions
+68
-3
CMakeLists.txt
CMakeLists.txt
+4
-1
cmake/Modules/FindIconv.cmake
cmake/Modules/FindIconv.cmake
+57
-0
src/utils/encoding.cpp
src/utils/encoding.cpp
+7
-2
No files found.
CMakeLists.txt
View file @
ef014f7d
...
...
@@ -13,14 +13,16 @@ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og -fsanitize=address")
#
set
(
CMAKE_MODULE_PATH
${
CMAKE_MODULE_PATH
}
"
${
CMAKE_SOURCE_DIR
}
/cmake/Modules/"
)
find_package
(
Cryptopp REQUIRED
)
find_package
(
Iconv REQUIRED
)
include
(
FindEXPAT
)
find_package
(
EXPAT REQUIRED
)
include_directories
(
"src/"
)
include_directories
(
${
EXPAT_INCLUDE_DIRS
}
)
include_directories
(
${
ICONV_INCLUDE_DIR
}
)
# the SYSTEM flag tells the compiler that we don't care about warnings
# coming from these headers.
include_directories
(
SYSTEM
${
CRYPTO++_INCLUDE_DIR
}
)
include_directories
(
SYSTEM
${
EXPAT_INCLUDE_DIRS
}
)
#
## utils
...
...
@@ -28,6 +30,7 @@ include_directories(SYSTEM ${EXPAT_INCLUDE_DIRS})
file
(
GLOB source_utils
src/utils/*.[hc]pp
)
add_library
(
utils STATIC
${
source_utils
}
)
target_link_libraries
(
utils
${
ICONV_LIBRARIES
}
)
#
## network
...
...
cmake/Modules/FindIconv.cmake
0 → 100644
View file @
ef014f7d
# - Try to find Iconv
# Once done this will define
#
# ICONV_FOUND - system has Iconv
# ICONV_INCLUDE_DIR - the Iconv include directory
# ICONV_LIBRARIES - Link these to use Iconv
# ICONV_SECOND_ARGUMENT_IS_CONST - the second argument for iconv() is const
#
include
(
CheckCXXSourceCompiles
)
IF
(
ICONV_INCLUDE_DIR AND ICONV_LIBRARIES
)
# Already in cache, be silent
SET
(
ICONV_FIND_QUIETLY TRUE
)
ENDIF
(
ICONV_INCLUDE_DIR AND ICONV_LIBRARIES
)
FIND_PATH
(
ICONV_INCLUDE_DIR iconv.h
)
FIND_LIBRARY
(
ICONV_LIBRARIES NAMES iconv libiconv libiconv-2 c
)
IF
(
ICONV_INCLUDE_DIR AND ICONV_LIBRARIES
)
SET
(
ICONV_FOUND TRUE
)
ENDIF
(
ICONV_INCLUDE_DIR AND ICONV_LIBRARIES
)
set
(
CMAKE_REQUIRED_INCLUDES
${
ICONV_INCLUDE_DIR
}
)
set
(
CMAKE_REQUIRED_LIBRARIES
${
ICONV_LIBRARIES
}
)
IF
(
ICONV_FOUND
)
check_cxx_source_compiles
(
"
#include <iconv.h>
int main(){
iconv_t conv = 0;
const char* in = 0;
size_t ilen = 0;
char* out = 0;
size_t olen = 0;
iconv(conv, &in, &ilen, &out, &olen);
return 0;
}
"
ICONV_SECOND_ARGUMENT_IS_CONST
)
ENDIF
(
ICONV_FOUND
)
set
(
CMAKE_REQUIRED_INCLUDES
)
set
(
CMAKE_REQUIRED_LIBRARIES
)
IF
(
ICONV_FOUND
)
IF
(
NOT ICONV_FIND_QUIETLY
)
MESSAGE
(
STATUS
"Found Iconv:
${
ICONV_LIBRARIES
}
"
)
ENDIF
(
NOT ICONV_FIND_QUIETLY
)
ELSE
(
ICONV_FOUND
)
IF
(
Iconv_FIND_REQUIRED
)
MESSAGE
(
FATAL_ERROR
"Could not find Iconv"
)
ENDIF
(
Iconv_FIND_REQUIRED
)
ENDIF
(
ICONV_FOUND
)
MARK_AS_ADVANCED
(
ICONV_INCLUDE_DIR
ICONV_LIBRARIES
ICONV_SECOND_ARGUMENT_IS_CONST
)
\ No newline at end of file
src/utils/encoding.cpp
View file @
ef014f7d
...
...
@@ -75,10 +75,15 @@ namespace utils
// Make sure cd is always closed when we leave this function
ScopeGuard
sg
([
&
]{
iconv_close
(
cd
);
});
// iconv will not attempt to modify this buffer, but it still requires
// a char**.
size_t
inbytesleft
=
str
.
size
();
// iconv will not attempt to modify this buffer, but some plateform
// require a char** anyway
#ifdef ICONV_SECOND_ARGUMENT_IS_CONST
const
char
*
inbuf_ptr
=
str
.
c_str
();
#else
char
*
inbuf_ptr
=
const_cast
<
char
*>
(
str
.
c_str
());
#endif
size_t
outbytesleft
=
str
.
size
()
*
4
;
char
*
outbuf
=
new
char
[
outbytesleft
];
...
...
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