|
Packit |
1c1d7e |
# vim:ts=4:sw=4:expandtab:autoindent:
|
|
Packit |
1c1d7e |
#
|
|
Packit |
1c1d7e |
# The MIT License
|
|
Packit |
1c1d7e |
#
|
|
Packit |
1c1d7e |
# Copyright (c) 2008, 2009 Flusspferd contributors (see "CONTRIBUTORS" or
|
|
Packit |
1c1d7e |
# http://flusspferd.org/contributors.txt)
|
|
Packit |
1c1d7e |
#
|
|
Packit |
1c1d7e |
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
Packit |
1c1d7e |
# of this software and associated documentation files (the "Software"), to deal
|
|
Packit |
1c1d7e |
# in the Software without restriction, including without limitation the rights
|
|
Packit |
1c1d7e |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
Packit |
1c1d7e |
# copies of the Software, and to permit persons to whom the Software is
|
|
Packit |
1c1d7e |
# furnished to do so, subject to the following conditions:
|
|
Packit |
1c1d7e |
#
|
|
Packit |
1c1d7e |
# The above copyright notice and this permission notice shall be included in
|
|
Packit |
1c1d7e |
# all copies or substantial portions of the Software.
|
|
Packit |
1c1d7e |
#
|
|
Packit |
1c1d7e |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
Packit |
1c1d7e |
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
Packit |
1c1d7e |
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
Packit |
1c1d7e |
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
Packit |
1c1d7e |
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
Packit |
1c1d7e |
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
Packit |
1c1d7e |
# THE SOFTWARE.
|
|
Packit |
1c1d7e |
#
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
Include(CheckFunctionExists)
|
|
Packit |
1c1d7e |
include(CheckCXXSourceCompiles)
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
if(ICONV_INCLUDE_DIR)
|
|
Packit |
1c1d7e |
set(ICONV_FIND_QUIETLY TRUE)
|
|
Packit |
1c1d7e |
endif()
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
find_path(ICONV_INCLUDE_DIR iconv.h
|
|
Packit |
1c1d7e |
HINTS
|
|
Packit |
1c1d7e |
${CMAKE_PREFIX_PATH}
|
|
Packit |
1c1d7e |
${ICONV_DIR}
|
|
Packit |
1c1d7e |
$ENV{ICONV_DIR}
|
|
Packit |
1c1d7e |
PATH_SUFFIXES include
|
|
Packit |
1c1d7e |
)
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
if(NOT ICONV_INCLUDE_DIR STREQUAL "ICONV_INCLUDE_DIR-NOTFOUND")
|
|
Packit |
1c1d7e |
set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR})
|
|
Packit |
1c1d7e |
check_function_exists(iconv_open ICONV_IN_GLIBC)
|
|
Packit |
1c1d7e |
endif()
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
if(NOT ICONV_IN_GLIBC)
|
|
Packit |
1c1d7e |
if (CMAKE_CL_64)
|
|
Packit |
1c1d7e |
find_library(ICONV_LIBRARY
|
|
Packit |
1c1d7e |
NAMES iconv64
|
|
Packit |
1c1d7e |
HINTS
|
|
Packit |
1c1d7e |
${CMAKE_PREFIX_PATH}
|
|
Packit |
1c1d7e |
${ICONV_DIR}
|
|
Packit |
1c1d7e |
$ENV{ICONV_DIR}
|
|
Packit |
1c1d7e |
PATH_SUFFIXES lib64 lib
|
|
Packit |
1c1d7e |
)
|
|
Packit |
1c1d7e |
else()
|
|
Packit |
1c1d7e |
find_library(ICONV_LIBRARY
|
|
Packit |
1c1d7e |
NAMES iconv
|
|
Packit |
1c1d7e |
HINTS
|
|
Packit |
1c1d7e |
${CMAKE_PREFIX_PATH}
|
|
Packit |
1c1d7e |
${ICONV_DIR}
|
|
Packit |
1c1d7e |
$ENV{ICONV_DIR}
|
|
Packit |
1c1d7e |
PATH_SUFFIXES lib64 lib
|
|
Packit |
1c1d7e |
)
|
|
Packit |
1c1d7e |
endif()
|
|
Packit |
1c1d7e |
set(ICONV_TEST ${ICONV_LIBRARY})
|
|
Packit |
1c1d7e |
else()
|
|
Packit |
1c1d7e |
set(ICONV_TEST "In glibc")
|
|
Packit |
1c1d7e |
endif()
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR})
|
|
Packit |
1c1d7e |
set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARY})
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
if(MSVC_VERSION GREATER 1800)
|
|
Packit |
1c1d7e |
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} legacy_stdio_definitions.lib)
|
|
Packit |
1c1d7e |
endif()
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
check_cxx_source_compiles(
|
|
Packit |
1c1d7e |
"#include <iconv.h>
|
|
Packit |
1c1d7e |
int main() {
|
|
Packit |
1c1d7e |
iconv(iconv_t(-1), 0, 0, 0, 0);
|
|
Packit |
1c1d7e |
}"
|
|
Packit |
1c1d7e |
ICONV_COMPILES)
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
include(FindPackageHandleStandardArgs)
|
|
Packit |
1c1d7e |
find_package_handle_standard_args(ICONV DEFAULT_MSG ICONV_TEST ICONV_INCLUDE_DIR ICONV_COMPILES)
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
if(ICONV_FOUND)
|
|
Packit |
1c1d7e |
set(ICONV_LIBRARIES ${ICONV_LIBRARY})
|
|
Packit |
1c1d7e |
else(ICONV_FOUND)
|
|
Packit |
1c1d7e |
set(ICONV_LIBRARIES)
|
|
Packit |
1c1d7e |
endif(ICONV_FOUND)
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
if(ICONV_FOUND)
|
|
Packit |
1c1d7e |
set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR})
|
|
Packit |
1c1d7e |
set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES})
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
if(MSVC_VERSION GREATER 1800)
|
|
Packit |
1c1d7e |
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} legacy_stdio_definitions.lib)
|
|
Packit |
1c1d7e |
endif()
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
if (NOT DEFINED ICONV_ACCEPTS_NONCONST_INPUT)
|
|
Packit |
1c1d7e |
# Display a useful message first time we come through here
|
|
Packit |
1c1d7e |
message(STATUS "One (and only one) of the ICONV_ACCEPTS_... tests must pass")
|
|
Packit |
1c1d7e |
endif()
|
|
Packit |
1c1d7e |
check_cxx_source_compiles(
|
|
Packit |
1c1d7e |
"#include <iconv.h>
|
|
Packit |
1c1d7e |
int main() {
|
|
Packit |
1c1d7e |
char *p = 0;
|
|
Packit |
1c1d7e |
iconv(iconv_t(-1), &p, 0, 0, 0);
|
|
Packit |
1c1d7e |
}"
|
|
Packit |
1c1d7e |
ICONV_ACCEPTS_NONCONST_INPUT)
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
check_cxx_source_compiles(
|
|
Packit |
1c1d7e |
"#include <iconv.h>
|
|
Packit |
1c1d7e |
int main() {
|
|
Packit |
1c1d7e |
char const *p = 0;
|
|
Packit |
1c1d7e |
iconv(iconv_t(-1), &p, 0, 0, 0);
|
|
Packit |
1c1d7e |
}"
|
|
Packit |
1c1d7e |
ICONV_ACCEPTS_CONST_INPUT)
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
if (ICONV_LIBRARY)
|
|
Packit |
1c1d7e |
list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARY})
|
|
Packit |
1c1d7e |
list(REMOVE_DUPLICATES CMAKE_REQUIRED_LIBRARIES)
|
|
Packit |
1c1d7e |
endif()
|
|
Packit |
1c1d7e |
endif()
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
if(NOT ICONV_ACCEPTS_CONST_INPUT AND NOT ICONV_ACCEPTS_NONCONST_INPUT)
|
|
Packit |
1c1d7e |
MESSAGE(FATAL_ERROR "Unable to determine iconv() signature")
|
|
Packit |
1c1d7e |
elseif(ICONV_ACCEPTS_CONST_INPUT AND ICONV_ACCEPTS_NONCONST_INPUT)
|
|
Packit |
1c1d7e |
MESSAGE(FATAL_ERROR "Unable to determine iconv() signature - both test cases passed!")
|
|
Packit |
1c1d7e |
endif()
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
mark_as_advanced(ICONV_LIBRARY ICONV_INCLUDE_DIR)
|