2014-12-01 19:55:22 +00:00
|
|
|
# Grabbed from http://public.kitware.com/Bug/view.php?id=13517 and slightly modified.
|
|
|
|
|
|
|
|
find_path(ICONV_INCLUDE_DIR iconv.h)
|
|
|
|
find_library(ICONV_LIBRARY NAMES iconv libiconv libiconv-2 c)
|
|
|
|
|
|
|
|
set(ICONV_INCLUDE_DIRS ${ICONV_INCLUDE_DIR})
|
|
|
|
set(ICONV_LIBRARIES ${ICONV_LIBRARY})
|
|
|
|
|
|
|
|
include(FindPackageHandleStandardArgs)
|
|
|
|
|
|
|
|
find_package_handle_standard_args(ICONV
|
|
|
|
REQUIRED_VARS
|
|
|
|
ICONV_LIBRARY
|
|
|
|
ICONV_INCLUDE_DIR
|
|
|
|
VERSION_VAR
|
|
|
|
ICONV_VERSION
|
|
|
|
)
|
|
|
|
|
|
|
|
if(ICONV_FOUND AND NOT DEFINED ICONV_SECOND_ARGUMENT_IS_CONST)
|
|
|
|
include(CheckCSourceCompiles)
|
|
|
|
|
|
|
|
set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIRS})
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES})
|
|
|
|
|
2016-02-23 05:07:43 +00:00
|
|
|
check_c_source_compiles("
|
2014-12-01 19:55:22 +00:00
|
|
|
#include <iconv.h>
|
2017-04-21 07:40:57 +00:00
|
|
|
int main()
|
2014-12-01 19:55:22 +00:00
|
|
|
{
|
|
|
|
iconv_t conv = 0;
|
|
|
|
const char * in = 0;
|
|
|
|
size_t ilen = 0;
|
|
|
|
char * out = 0;
|
|
|
|
size_t olen = 0;
|
2017-04-21 07:40:57 +00:00
|
|
|
iconv(conv, &in, &ilen, &out, &olen);
|
2014-12-01 19:55:22 +00:00
|
|
|
return 0;
|
2016-02-23 05:07:43 +00:00
|
|
|
}"
|
|
|
|
ICONV_SECOND_ARGUMENT_IS_CONST
|
|
|
|
FAIL_REGEX "incompatible pointer type"
|
|
|
|
FAIL_REGEX "discards qualifiers in nested pointer types")
|
2014-12-01 19:55:22 +00:00
|
|
|
|
|
|
|
set(CMAKE_REQUIRED_INCLUDES)
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
mark_as_advanced(ICONV_INCLUDE_DIR ICONV_LIBRARY ICONV_SECOND_ARGUMENT_IS_CONST)
|