ConfigureChecks.cmake 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. include(CheckIncludeFile)
  2. include(CheckSymbolExists)
  3. include(CheckFunctionExists)
  4. include(CheckLibraryExists)
  5. include(CheckTypeSize)
  6. include(CheckCXXSourceCompiles)
  7. set(PACKAGE ${APPLICATION_NAME})
  8. set(VERSION ${APPLICATION_VERSION})
  9. set(DATADIR ${DATA_INSTALL_DIR})
  10. set(LIBDIR ${LIB_INSTALL_DIR})
  11. set(PLUGINDIR "${PLUGIN_INSTALL_DIR}-${LIBRARY_SOVERSION}")
  12. set(SYSCONFDIR ${SYSCONF_INSTALL_DIR})
  13. set(BINARYDIR ${CMAKE_BINARY_DIR})
  14. set(SOURCEDIR ${CMAKE_SOURCE_DIR})
  15. # HEADER FILES
  16. check_include_file(argp.h HAVE_ARGP_H)
  17. # FUNCTIONS
  18. if (NOT LINUX)
  19. # librt
  20. check_library_exists(rt nanosleep "" HAVE_LIBRT)
  21. set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} )
  22. endif (NOT LINUX)
  23. check_library_exists(rt clock_gettime "" HAVE_CLOCK_GETTIME)
  24. if (HAVE_LIBRT OR HAVE_CLOCK_GETTIME)
  25. set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} rt)
  26. endif (HAVE_LIBRT OR HAVE_CLOCK_GETTIME)
  27. check_library_exists(dl dlopen "" HAVE_LIBDL)
  28. if (HAVE_LIBDL)
  29. set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} dl)
  30. endif (HAVE_LIBDL)
  31. check_function_exists(asprintf HAVE_ASPRINTF)
  32. if(NOT HAVE_ASPRINTF)
  33. if(MINGW)
  34. add_definitions( -D__USE_MINGW_ANSI_STDIO=1 )
  35. endif()
  36. endif()
  37. check_function_exists(fnmatch HAVE_FNMATCH)
  38. if(NOT HAVE_FNMATCH AND WIN32)
  39. find_library(SHLWAPI_LIBRARY shlwapi)
  40. set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} shlwapi)
  41. endif()
  42. if(WIN32)
  43. set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} psapi kernel32)
  44. endif()
  45. check_function_exists(timegm HAVE_TIMEGM)
  46. check_function_exists(strerror_r HAVE_STRERROR_R)
  47. check_function_exists(utimes HAVE_UTIMES)
  48. check_function_exists(lstat HAVE_LSTAT)
  49. check_function_exists(asprintf HAVE_ASPRINTF)
  50. if (WIN32)
  51. check_function_exists(__mingw_asprintf HAVE___MINGW_ASPRINTF)
  52. endif(WIN32)
  53. if (UNIX AND HAVE_ASPRINTF)
  54. add_definitions(-D_GNU_SOURCE)
  55. endif (UNIX AND HAVE_ASPRINTF)
  56. if (WIN32)
  57. check_function_exists(__mingw_asprintf HAVE___MINGW_ASPRINTF)
  58. endif(WIN32)
  59. if (UNIT_TESTING)
  60. set(WITH_UNIT_TESTING ON)
  61. endif (UNIT_TESTING)
  62. set(CSYNC_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} CACHE INTERNAL "csync required system libraries")