Mercurial > thymian
comparison 3rdparty/vmime/cmake/FindIconv.cmake @ 0:a4671277546c tip
created the repository for the thymian project
| author | ferencd |
|---|---|
| date | Tue, 17 Aug 2021 11:19:54 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:a4671277546c |
|---|---|
| 1 # - Try to find Iconv | |
| 2 # Once done this will define | |
| 3 # | |
| 4 # ICONV_FOUND - system has Iconv | |
| 5 # ICONV_INCLUDE_DIR - the Iconv include directory | |
| 6 # ICONV_LIBRARIES - Link these to use Iconv | |
| 7 # ICONV_SECOND_ARGUMENT_IS_CONST - the second argument for iconv() is const | |
| 8 # | |
| 9 include(CheckCXXSourceCompiles) | |
| 10 | |
| 11 IF (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) | |
| 12 # Already in cache, be silent | |
| 13 SET(ICONV_FIND_QUIETLY TRUE) | |
| 14 ENDIF (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) | |
| 15 | |
| 16 FIND_PATH(ICONV_INCLUDE_DIR iconv.h) | |
| 17 | |
| 18 IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") | |
| 19 FIND_LIBRARY(ICONV_LIBRARIES NAMES iconv libiconv libiconv-2 c HINTS "/opt/local/lib") | |
| 20 ELSE() | |
| 21 FIND_LIBRARY(ICONV_LIBRARIES NAMES iconv libiconv libiconv-2 c) | |
| 22 ENDIF() | |
| 23 | |
| 24 IF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) | |
| 25 SET(ICONV_FOUND TRUE) | |
| 26 ENDIF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) | |
| 27 | |
| 28 set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR}) | |
| 29 set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES}) | |
| 30 IF(ICONV_FOUND) | |
| 31 check_cxx_source_compiles(" | |
| 32 #include <iconv.h> | |
| 33 int main(){ | |
| 34 iconv_t conv = 0; | |
| 35 const char* in = 0; | |
| 36 size_t ilen = 0; | |
| 37 char* out = 0; | |
| 38 size_t olen = 0; | |
| 39 iconv(conv, &in, &ilen, &out, &olen); | |
| 40 return 0; | |
| 41 } | |
| 42 " ICONV_SECOND_ARGUMENT_IS_CONST ) | |
| 43 ENDIF(ICONV_FOUND) | |
| 44 set(CMAKE_REQUIRED_INCLUDES) | |
| 45 set(CMAKE_REQUIRED_LIBRARIES) | |
| 46 | |
| 47 IF(ICONV_FOUND) | |
| 48 IF(NOT ICONV_FIND_QUIETLY) | |
| 49 MESSAGE(STATUS "Found Iconv: ${ICONV_LIBRARIES}") | |
| 50 ENDIF(NOT ICONV_FIND_QUIETLY) | |
| 51 ELSE(ICONV_FOUND) | |
| 52 IF(Iconv_FIND_REQUIRED) | |
| 53 MESSAGE(FATAL_ERROR "Could not find Iconv") | |
| 54 ENDIF(Iconv_FIND_REQUIRED) | |
| 55 ENDIF(ICONV_FOUND) | |
| 56 | |
| 57 MARK_AS_ADVANCED( | |
| 58 ICONV_INCLUDE_DIR | |
| 59 ICONV_LIBRARIES | |
| 60 ICONV_SECOND_ARGUMENT_IS_CONST | |
| 61 ) |
