compiletest.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #ifndef CMAKE_IS_FUN
  2. #error Expect CMAKE_IS_FUN definition
  3. #endif
  4. #if CMAKE_IS != Fun
  5. #error Expect CMAKE_IS=Fun definition
  6. #endif
  7. template <bool test>
  8. struct CMakeStaticAssert;
  9. template <>
  10. struct CMakeStaticAssert<true>
  11. {
  12. };
  13. static const char fun_string[] = CMAKE_IS_;
  14. #ifndef NO_SPACES_IN_DEFINE_VALUES
  15. static const char very_fun_string[] = CMAKE_IS_REALLY;
  16. #endif
  17. enum
  18. {
  19. StringLiteralTest1 =
  20. sizeof(CMakeStaticAssert<sizeof(CMAKE_IS_) == sizeof("Fun")>),
  21. #ifndef NO_SPACES_IN_DEFINE_VALUES
  22. StringLiteralTest2 =
  23. sizeof(CMakeStaticAssert<sizeof(CMAKE_IS_REALLY) == sizeof("Very Fun")>),
  24. #endif
  25. #ifdef TEST_GENERATOR_EXPRESSIONS
  26. StringLiteralTest3 =
  27. sizeof(CMakeStaticAssert<sizeof(LETTER_LIST1) == sizeof("A,B,C,D")>),
  28. StringLiteralTest4 =
  29. sizeof(CMakeStaticAssert<sizeof(LETTER_LIST2) == sizeof("A,,B,,C,,D")>),
  30. StringLiteralTest5 =
  31. sizeof(CMakeStaticAssert<sizeof(LETTER_LIST3) == sizeof("A,-B,-C,-D")>),
  32. StringLiteralTest6 =
  33. sizeof(CMakeStaticAssert<sizeof(LETTER_LIST4) == sizeof("A-,-B-,-C-,-D")>),
  34. StringLiteralTest7 =
  35. sizeof(CMakeStaticAssert<sizeof(LETTER_LIST5) == sizeof("A-,B-,C-,D")>)
  36. #endif
  37. };
  38. #ifdef TEST_GENERATOR_EXPRESSIONS
  39. #ifndef CMAKE_IS_DECLARATIVE
  40. #error Expect declarative definition
  41. #endif
  42. #ifdef GE_NOT_DEFINED
  43. #error Expect not defined generator expression
  44. #endif
  45. #ifndef ARGUMENT
  46. #error Expected define expanded from list
  47. #endif
  48. #ifndef LIST
  49. #error Expected define expanded from list
  50. #endif
  51. #ifndef PREFIX_DEF1
  52. #error Expect PREFIX_DEF1
  53. #endif
  54. #ifndef PREFIX_DEF2
  55. #error Expect PREFIX_DEF2
  56. #endif
  57. #ifndef LINK_CXX_DEFINE
  58. #error Expected LINK_CXX_DEFINE
  59. #endif
  60. #ifndef LINK_LANGUAGE_IS_CXX
  61. #error Expected LINK_LANGUAGE_IS_CXX
  62. #endif
  63. #ifdef LINK_C_DEFINE
  64. #error Unexpected LINK_C_DEFINE
  65. #endif
  66. #ifdef LINK_LANGUAGE_IS_C
  67. #error Unexpected LINK_LANGUAGE_IS_C
  68. #endif
  69. // TEST_GENERATOR_EXPRESSIONS
  70. #endif
  71. #ifndef BUILD_IS_DEBUG
  72. #error "BUILD_IS_DEBUG not defined!"
  73. #endif
  74. #ifndef BUILD_IS_NOT_DEBUG
  75. #error "BUILD_IS_NOT_DEBUG not defined!"
  76. #endif
  77. // Check per-config definitions.
  78. #ifdef TEST_CONFIG_DEBUG
  79. #if !BUILD_IS_DEBUG
  80. #error "BUILD_IS_DEBUG false with TEST_CONFIG_DEBUG!"
  81. #endif
  82. #if BUILD_IS_NOT_DEBUG
  83. #error "BUILD_IS_NOT_DEBUG true with TEST_CONFIG_DEBUG!"
  84. #endif
  85. #else
  86. #if BUILD_IS_DEBUG
  87. #error "BUILD_IS_DEBUG true without TEST_CONFIG_DEBUG!"
  88. #endif
  89. #if !BUILD_IS_NOT_DEBUG
  90. #error "BUILD_IS_NOT_DEBUG false without TEST_CONFIG_DEBUG!"
  91. #endif
  92. #endif
  93. int main(int argc, char** argv)
  94. {
  95. return 0;
  96. }