diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b2af5c..9214e66 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,22 +36,11 @@ check_include_file("gsf/gsf-input-stdio.h" HAVE_GSF_GSFINPUTSTDIO_H) include(CheckFunctionExists) include(CheckLibraryExists) -# Check for iconv -if(HAVE_ICONV_H) - # First check if iconv is in libc - check_function_exists(iconv ICONV_IN_LIBC) - - if(NOT ICONV_IN_LIBC) - # Check if iconv is in a separate library - check_library_exists(iconv iconv "" HAVE_ICONV_LIB) - if(HAVE_ICONV_LIB) - set(ICONV_LIBRARIES iconv) - endif() - endif() - - if(ICONV_IN_LIBC OR HAVE_ICONV_LIB) - set(HAVE_ICONV 1) - endif() +# Check for iconv via CMake's modern Iconv module (CMake 3.11+) +find_package(Iconv) +if(Iconv_FOUND) + set(HAVE_ICONV 1) + set(ICONV_LIBRARIES Iconv::Iconv) endif() # Endianess