Configure.cmake 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. # Licensed under the Apache License, Version 2.0 (the "License");
  2. # you may not use this file except in compliance with the License.
  3. # You may obtain a copy of the License at
  4. # http://www.apache.org/licenses/LICENSE-2.0
  5. # Unless required by applicable law or agreed to in writing, software
  6. # distributed under the License is distributed on an "AS IS" BASIS,
  7. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  8. # See the License for the specific language governing permissions and
  9. # limitations under the License.
  10. ################################################################################
  11. #
  12. # configure
  13. #
  14. ################################################################################
  15. ########################################
  16. # FUNCTION check_includes
  17. ########################################
  18. function(check_includes files)
  19. foreach(F ${${files}})
  20. set(name ${F})
  21. string(REPLACE "-" "_" name ${name})
  22. string(REPLACE "." "_" name ${name})
  23. string(REPLACE "/" "_" name ${name})
  24. string(TOUPPER ${name} name)
  25. check_include_files(${F} HAVE_${name})
  26. file(APPEND ${AUTOCONFIG_SRC} "/* Define to 1 if you have the <${F}> header file. */\n")
  27. file(APPEND ${AUTOCONFIG_SRC} "#cmakedefine HAVE_${name} 1\n")
  28. file(APPEND ${AUTOCONFIG_SRC} "\n")
  29. endforeach()
  30. endfunction(check_includes)
  31. ########################################
  32. # FUNCTION check_functions
  33. ########################################
  34. function(check_functions functions)
  35. foreach(F ${${functions}})
  36. set(name ${F})
  37. string(TOUPPER ${name} name)
  38. check_function_exists(${F} HAVE_${name})
  39. file(APPEND ${AUTOCONFIG_SRC} "/* Define to 1 if you have the `${F}' function. */\n")
  40. file(APPEND ${AUTOCONFIG_SRC} "#cmakedefine HAVE_${name} 1\n")
  41. file(APPEND ${AUTOCONFIG_SRC} "\n")
  42. endforeach()
  43. endfunction(check_functions)
  44. ########################################
  45. # FUNCTION check_types
  46. ########################################
  47. function(check_types types)
  48. foreach(T ${${types}})
  49. set(name ${T})
  50. string(REPLACE " " "_" name ${name})
  51. string(REPLACE "-" "_" name ${name})
  52. string(REPLACE "." "_" name ${name})
  53. string(REPLACE "/" "_" name ${name})
  54. string(TOUPPER ${name} name)
  55. check_type_size(${T} HAVE_${name})
  56. file(APPEND ${AUTOCONFIG_SRC} "/* Define to 1 if the system has the type `${T}'. */\n")
  57. file(APPEND ${AUTOCONFIG_SRC} "#cmakedefine HAVE_${name} 1\n")
  58. file(APPEND ${AUTOCONFIG_SRC} "\n")
  59. endforeach()
  60. endfunction(check_types)
  61. ########################################
  62. file(WRITE ${AUTOCONFIG_SRC})
  63. include(CheckCSourceCompiles)
  64. include(CheckCSourceRuns)
  65. include(CheckCXXSourceCompiles)
  66. include(CheckCXXSourceRuns)
  67. include(CheckFunctionExists)
  68. include(CheckIncludeFiles)
  69. include(CheckLibraryExists)
  70. include(CheckPrototypeDefinition)
  71. include(CheckStructHasMember)
  72. include(CheckSymbolExists)
  73. include(CheckTypeSize)
  74. include(TestBigEndian)
  75. set(include_files_list
  76. dlfcn.h
  77. inttypes.h
  78. memory.h
  79. stdint.h
  80. stdlib.h
  81. string.h
  82. sys/stat.h
  83. sys/types.h
  84. unistd.h
  85. cairo/cairo-version.h
  86. pango-1.0/pango/pango-features.h
  87. unicode/uchar.h
  88. )
  89. # check_includes(include_files_list)
  90. set(types_list
  91. "long long int"
  92. wchar_t
  93. )
  94. # check_types(types_list)
  95. list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
  96. list(APPEND CMAKE_REQUIRED_LIBRARIES -lm)
  97. set(functions_list
  98. feenableexcept
  99. )
  100. check_functions(functions_list)
  101. file(APPEND ${AUTOCONFIG_SRC} "
  102. /* Version number */
  103. #cmakedefine PACKAGE_VERSION \"${PACKAGE_VERSION}\"
  104. #cmakedefine GRAPHICS_DISABLED ${GRAPHICS_DISABLED}
  105. #cmakedefine FAST_FLOAT ${FAST_FLOAT}
  106. #cmakedefine DISABLED_LEGACY_ENGINE ${DISABLED_LEGACY_ENGINE}
  107. #cmakedefine HAVE_TIFFIO_H ${HAVE_TIFFIO_H}
  108. #cmakedefine HAVE_NEON ${HAVE_NEON}
  109. #cmakedefine HAVE_LIBARCHIVE ${HAVE_LIBARCHIVE}
  110. #cmakedefine HAVE_LIBCURL ${HAVE_LIBCURL}
  111. ")
  112. if(TESSDATA_PREFIX)
  113. file(APPEND ${AUTOCONFIG_SRC} "
  114. #cmakedefine TESSDATA_PREFIX \"${TESSDATA_PREFIX}\"
  115. ")
  116. endif()
  117. ########################################
  118. ################################################################################