Files
transmission/cmake/FindICONV.cmake
Mike Gelfand bc380511db Modernize CMake code (ongoing refactoring) (#4507)
* Reformat CMake code

* Bump minimum CMake version to 3.12

* Add target sources separately via `target_source()`

* Make `tr_win32_app_info()` add target sources on its own

* Don't use `include_directories()`

* Don't use `add_definitions()`

* Limit use of `add_compile_options()`

* Move VDKQueue target declaration to a subdirectory

* Add `tr_disable_source_files_compile()` helper

* Add `tr_target_glib_resources()` helper

* Add `tr_gettext_msgfmt()` helper

* Enable AUTOUIC for Qt client

* Enable AUTORCC for Qt client

* Remove AUTO{MOC,RCC,UIC} source group overrides

* Add `tr_target_idl_files()` helper

* Move source group setup to `tr_qt_add_translation()`

* Add `tr_target_xib_files()` helper

* Prefer `target_sources()` to intermediate variables

* Use explicit visibility versions of `target_*()` commands

* Prefer genexes to conditions in `target_*()` commands

* Add `tr_allow_compile_if()` helper

* Leave only top-level `project()`, remove the rest

* Minor fixups

* Fixup Mac QL plugin install

* Fixup IDE target folders and source groups
2023-01-01 19:49:48 +00:00

52 lines
1.4 KiB
CMake

# Grabbed from http://public.kitware.com/Bug/view.php?id=13517 and slightly modified.
find_path(ICONV_INCLUDE_DIR
NAMES 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(CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIRS})
set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES})
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
FAIL_REGEX "discards qualifiers in nested pointer types"
FAIL_REGEX "incompatible pointer type"
FAIL_REGEX "invalid conversion"
FAIL_REGEX "no matching function")
set(CMAKE_REQUIRED_INCLUDES)
set(CMAKE_REQUIRED_LIBRARIES)
endif()
mark_as_advanced(ICONV_INCLUDE_DIR ICONV_LIBRARY ICONV_SECOND_ARGUMENT_IS_CONST)