compiletest.cpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. // TEST_GENERATOR_EXPRESSIONS
  48. #endif
  49. #ifndef BUILD_IS_DEBUG
  50. # error "BUILD_IS_DEBUG not defined!"
  51. #endif
  52. #ifndef BUILD_IS_NOT_DEBUG
  53. # error "BUILD_IS_NOT_DEBUG not defined!"
  54. #endif
  55. // Check per-config definitions.
  56. #ifdef TEST_CONFIG_DEBUG
  57. # if !BUILD_IS_DEBUG
  58. # error "BUILD_IS_DEBUG false with TEST_CONFIG_DEBUG!"
  59. # endif
  60. # if BUILD_IS_NOT_DEBUG
  61. # error "BUILD_IS_NOT_DEBUG true with TEST_CONFIG_DEBUG!"
  62. # endif
  63. #else
  64. # if BUILD_IS_DEBUG
  65. # error "BUILD_IS_DEBUG true without TEST_CONFIG_DEBUG!"
  66. # endif
  67. # if !BUILD_IS_NOT_DEBUG
  68. # error "BUILD_IS_NOT_DEBUG false without TEST_CONFIG_DEBUG!"
  69. # endif
  70. #endif
  71. int main(int argc, char **argv)
  72. {
  73. return 0;
  74. }