Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

FindIconv.cmake 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # From: http://gitorious.org/gammu/mainline/blobs/master/cmake/FindIconv.cmake
  2. # - Try to find Iconv
  3. # Once done this will define
  4. #
  5. # ICONV_FOUND - system has Iconv
  6. # ICONV_INCLUDE_DIR - the Iconv include directory
  7. # ICONV_LIBRARIES - Link these to use Iconv
  8. # ICONV_SECOND_ARGUMENT_IS_CONST - the second argument for iconv() is const
  9. #
  10. include(CheckCCompilerFlag)
  11. include(CheckCXXSourceCompiles)
  12. IF (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
  13. # Already in cache, be silent
  14. SET(ICONV_FIND_QUIETLY TRUE)
  15. ENDIF (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
  16. FIND_PATH(ICONV_INCLUDE_DIR iconv.h)
  17. FIND_LIBRARY(ICONV_LIBRARIES NAMES iconv libiconv c)
  18. IF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
  19. SET(ICONV_FOUND TRUE)
  20. ENDIF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
  21. set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR})
  22. set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES})
  23. IF(ICONV_FOUND)
  24. check_c_compiler_flag("-Werror" ICONV_HAVE_WERROR)
  25. set (CMAKE_C_FLAGS_BACKUP "${CMAKE_C_FLAGS}")
  26. if(ICONV_HAVE_WERROR)
  27. set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
  28. endif(ICONV_HAVE_WERROR)
  29. check_c_source_compiles("
  30. #include <iconv.h>
  31. int main(){
  32. iconv_t conv = 0;
  33. const char* in = 0;
  34. size_t ilen = 0;
  35. char* out = 0;
  36. size_t olen = 0;
  37. iconv(conv, &in, &ilen, &out, &olen);
  38. return 0;
  39. }
  40. " ICONV_SECOND_ARGUMENT_IS_CONST )
  41. set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS_BACKUP}")
  42. ENDIF(ICONV_FOUND)
  43. set(CMAKE_REQUIRED_INCLUDES)
  44. set(CMAKE_REQUIRED_LIBRARIES)
  45. IF(ICONV_FOUND)
  46. IF(NOT ICONV_FIND_QUIETLY)
  47. MESSAGE(STATUS "Found Iconv: ${ICONV_LIBRARIES}")
  48. ENDIF(NOT ICONV_FIND_QUIETLY)
  49. ELSE(ICONV_FOUND)
  50. IF(Iconv_FIND_REQUIRED)
  51. MESSAGE(FATAL_ERROR "Could not find Iconv")
  52. ENDIF(Iconv_FIND_REQUIRED)
  53. ENDIF(ICONV_FOUND)
  54. MARK_AS_ADVANCED(
  55. ICONV_INCLUDE_DIR
  56. ICONV_LIBRARIES
  57. ICONV_SECOND_ARGUMENT_IS_CONST
  58. )