Collection of DPF-based plugins for packaging
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

104 lines
2.7KB

  1. # Tests for various platform features and generates a header with the appropriate defines,
  2. # similar to the one created by autotools.
  3. include(CheckSymbolExists)
  4. include(CheckCXXSymbolExists)
  5. include(CheckFunctionExists)
  6. include(CheckIncludeFileCXX)
  7. include(CheckEnumValueExists)
  8. include(CheckIncludeFiles)
  9. include(EnableCFlagsIfSupported)
  10. add_compile_definitions(
  11. $<$<CONFIG:DEBUG>:DEBUG>
  12. )
  13. if(NOT MSVC)
  14. enable_cflags_if_supported(
  15. -Wall
  16. -Wchar-subscripts
  17. -Wformat-security
  18. -Wpointer-arith
  19. -Wshadow
  20. -Wsign-compare
  21. -Wtype-limits
  22. -fopenmp
  23. )
  24. enable_linker_flags_if_supported(
  25. -fopenmp
  26. )
  27. else()
  28. enable_cflags_if_supported(
  29. /W4
  30. /openmp
  31. )
  32. enable_linker_flags_if_supported(
  33. /openmp
  34. )
  35. endif()
  36. check_function_exists(aligned_alloc HAVE_ALIGNED_ALLOC)
  37. check_include_file_cxx("dlfcn.h" HAVE_DLFCN_H)
  38. check_include_file_cxx("fts.h" HAVE_FTS_H)
  39. check_include_file_cxx("GL/gl.h" HAVE_GL_GL_H)
  40. check_include_file_cxx("inttypes.h" HAVE_INTTYPES_H)
  41. check_include_file_cxx("memory.h" HAVE_MEMORY_H)
  42. check_function_exists(posix_memalign HAVE_POSIX_MEMALIGN)
  43. check_enum_value_exists("PTHREAD_PRIO_INHERIT" "pthread.h" HAVE_PTHREAD_PRIO_INHERIT)
  44. check_include_file_cxx("fts.h" HAVE_FTS_H)
  45. check_include_file_cxx("stdint.h" HAVE_STDINT_H)
  46. check_include_file_cxx("stdlib.h" HAVE_STDLIB_H)
  47. check_include_file_cxx("strings.h" HAVE_STRINGS_H)
  48. check_include_file_cxx("string.h" HAVE_STRING_H)
  49. check_include_file_cxx("sys/stat.h" HAVE_SYS_STAT_H)
  50. check_include_file_cxx("sys/types.h" HAVE_SYS_TYPES_H)
  51. check_include_file_cxx("unistd.h" HAVE_UNISTD_H)
  52. check_include_file_cxx("windows.h" HAVE_WINDOWS_H)
  53. set(_std_c_headers
  54. # C89/C90
  55. assert.h
  56. ctype.h
  57. errno.h
  58. float.h
  59. limits.h
  60. locale.h
  61. math.h
  62. setjmp.h
  63. signal.h
  64. stdarg.h
  65. stddef.h
  66. stdio.h
  67. stdlib.h
  68. string.h
  69. time.h
  70. # C95/NA1
  71. iso646.h
  72. wctype.h
  73. # C99
  74. complex.h
  75. fenv.h
  76. inttypes.h
  77. stdbool.h
  78. stdint.h
  79. tgmath.h
  80. )
  81. check_include_files("${_std_c_headers}" STDC_HEADERS LANGUAGE C)
  82. unset(_std_c_headers)
  83. # Create global configuration header
  84. file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/include")
  85. configure_file(config.h.cmake.in "${CMAKE_BINARY_DIR}/include/config.h")
  86. include_directories("${CMAKE_BINARY_DIR}/include")
  87. add_compile_definitions(HAVE_CONFIG_H)
  88. # Force-include the file in all targets
  89. if(MSVC)
  90. add_definitions(/FI"config.h")
  91. else()
  92. # GCC or Clang
  93. add_definitions(-include config.h)
  94. endif()