1
0

compiletest.cpp 2.4 KB

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