Configure.cmake 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. ################################################################################
  2. #
  3. # configure
  4. #
  5. ################################################################################
  6. ########################################
  7. # FUNCTION check_includes
  8. ########################################
  9. function(check_includes files)
  10. foreach(F ${${files}})
  11. set(name ${F})
  12. string(REPLACE "-" "_" name ${name})
  13. string(REPLACE "." "_" name ${name})
  14. string(REPLACE "/" "_" name ${name})
  15. string(TOUPPER ${name} name)
  16. check_include_files(${F} HAVE_${name})
  17. file(APPEND ${AUTOCONFIG_SRC} "/* Define to 1 if you have the <${F}> header file. */\n")
  18. file(APPEND ${AUTOCONFIG_SRC} "#cmakedefine HAVE_${name} 1\n")
  19. file(APPEND ${AUTOCONFIG_SRC} "\n")
  20. endforeach()
  21. endfunction(check_includes)
  22. ########################################
  23. # FUNCTION check_functions
  24. ########################################
  25. function(check_functions functions)
  26. foreach(F ${${functions}})
  27. set(name ${F})
  28. string(TOUPPER ${name} name)
  29. check_function_exists(${F} HAVE_${name})
  30. file(APPEND ${AUTOCONFIG_SRC} "/* Define to 1 if you have the `${F}' function. */\n")
  31. file(APPEND ${AUTOCONFIG_SRC} "#cmakedefine HAVE_${name} 1\n")
  32. file(APPEND ${AUTOCONFIG_SRC} "\n")
  33. endforeach()
  34. endfunction(check_functions)
  35. ########################################
  36. file(WRITE ${AUTOCONFIG_SRC})
  37. include(CheckCSourceCompiles)
  38. include(CheckCSourceRuns)
  39. include(CheckCXXSourceCompiles)
  40. include(CheckCXXSourceRuns)
  41. include(CheckFunctionExists)
  42. include(CheckIncludeFiles)
  43. include(CheckLibraryExists)
  44. include(CheckPrototypeDefinition)
  45. include(CheckStructHasMember)
  46. include(CheckSymbolExists)
  47. include(CheckTypeSize)
  48. include(TestBigEndian)
  49. set(include_files_list
  50. dlfcn.h
  51. inttypes.h
  52. memory.h
  53. stdint.h
  54. stdlib.h
  55. strings.h
  56. string.h
  57. sys/stat.h
  58. sys/types.h
  59. unistd.h
  60. )
  61. check_includes(include_files_list)
  62. set(functions_list
  63. fmemopen
  64. fstatat
  65. )
  66. check_functions(functions_list)
  67. test_big_endian(BIG_ENDIAN)
  68. if(BIG_ENDIAN)
  69. set(ENDIANNESS L_BIG_ENDIAN)
  70. else()
  71. set(ENDIANNESS L_LITTLE_ENDIAN)
  72. endif()
  73. set(APPLE_UNIVERSAL_BUILD "defined (__APPLE_CC__)")
  74. configure_file(
  75. ${PROJECT_SOURCE_DIR}/src/endianness.h.in
  76. ${PROJECT_BINARY_DIR}/src/endianness.h
  77. @ONLY)
  78. if (GIF_FOUND)
  79. set(HAVE_LIBGIF 1)
  80. endif()
  81. if (JPEG_FOUND)
  82. set(HAVE_LIBJPEG 1)
  83. endif()
  84. if (OPENJPEG_SUPPORT)
  85. set(HAVE_LIBJP2K 1)
  86. endif()
  87. if (PNG_FOUND)
  88. set(HAVE_LIBPNG 1)
  89. endif()
  90. if (TIFF_FOUND)
  91. set(HAVE_LIBTIFF 1)
  92. endif()
  93. if (LIBWEBP_SUPPORT)
  94. set(HAVE_LIBWEBP 1)
  95. set(HAVE_LIBWEBP_ANIM 1)
  96. endif()
  97. if (ZLIB_FOUND)
  98. set(HAVE_LIBZ 1)
  99. endif()
  100. file(APPEND ${AUTOCONFIG_SRC} "
  101. /* Define to 1 if you have giflib. */
  102. #cmakedefine HAVE_LIBGIF 1
  103. /* Define to 1 if you have libopenjp2. */
  104. #cmakedefine HAVE_LIBJP2K 1
  105. /* Define to 1 if you have jpeg. */
  106. #cmakedefine HAVE_LIBJPEG 1
  107. /* Define to 1 if you have libpng. */
  108. #cmakedefine HAVE_LIBPNG 1
  109. /* Define to 1 if you have libtiff. */
  110. #cmakedefine HAVE_LIBTIFF 1
  111. /* Define to 1 if you have libwebp. */
  112. #cmakedefine HAVE_LIBWEBP 1
  113. /* Define to 1 if you have libwebpmux. */
  114. #cmakedefine HAVE_LIBWEBP_ANIM 1
  115. /* Define to 1 if you have zlib. */
  116. #cmakedefine HAVE_LIBZ 1
  117. ")
  118. ########################################
  119. ################################################################################