Skip to content
Permalink
Browse files

Refactored config check of iconv

It was messing since on Darwin, FreeBSD there are two versions of
iconv available - 'library' one and 'builtin' one, and they were
confused between configuration and building.
  • Loading branch information
klirichek committed Nov 9, 2017
1 parent cd9bd48 commit 262c3fe04a82fcdfe93825b1fe5654f1bc22ed00
Showing with 32 additions and 2 deletions.
  1. +1 −0 CMakeLists.txt
  2. +31 −2 cmake/FindICONV.cmake
@@ -373,6 +373,7 @@ else ( WIN32 )
if ( WITH_EXPAT )
option_menu ( ICONV "compile with iconv support" USE_LIBICONV EXTRA_LIBRARIES )
mark_as_advanced ( WITH_ICONV )
memcfgvalues ( USE_LIBICONV )
endif ( WITH_EXPAT )

# test for MYSQL
@@ -28,11 +28,40 @@
find_path ( ICONV_INCLUDE_DIRS iconv.h )

include ( helpers )
ac_search_libs ( "iconv;libiconv" "iconv" HAVE_LIBICONV LIBICONV_LIBRARY )

set ( _CHECK_ICONVC "
#include <iconv.h>
#include <stdio.h>
int main()
{
iconv_t pDesc = iconv_open ( \"UTF-16\", \"UTF-8\" );
}" )


get_property ( dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES )
SET (CMAKE_REQUIRED_INCLUDES "${dirs}")
CHECK_CXX_SOURCE_COMPILES ( "${_CHECK_ICONVC}" HAVE_LIBICONV )

if ( NOT HAVE_LIBICONV )
foreach ( LIB iconv libiconv )
UNSET ( _LIB_PATH CACHE )
find_library ( _LIB_PATH NAMES ${LIB} )
SET ( CMAKE_REQUIRED_LIBRARIES "${_LIB_PATH}")
UNSET ( HAVE_LIBICONV CACHE )
CHECK_CXX_SOURCE_COMPILES ( "${_CHECK_ICONVC}" HAVE_LIBICONV )
if ( HAVE_LIBICONV )
message ( STATUS "iconv found as is ${_LIB_PATH}" )
set ( LIBICONV_LIBRARY "${_LIB_PATH}" )
break ()
endif ()
endforeach ( LIB )
endif ()

mark_as_advanced(_LIB_PATH)

if ( HAVE_LIBICONV )
set ( _CHECK_ICONV "#include <iconv.h>
#include <stdio.h>
#include <stdio.h>
int main()
{

0 comments on commit 262c3fe

Please sign in to comment.
You can’t perform that action at this time.