cmake/Tests/CompileDefinitions/compiletest.cpp

113 lines
2.5 KiB
C++
Raw Normal View History

2013-03-16 19:13:01 +02:00
#ifndef CMAKE_IS_FUN
2018-08-09 18:06:22 +02:00
# error Expect CMAKE_IS_FUN definition
2013-03-16 19:13:01 +02:00
#endif
#if CMAKE_IS != Fun
2018-08-09 18:06:22 +02:00
# error Expect CMAKE_IS=Fun definition
2013-03-16 19:13:01 +02:00
#endif
2016-07-09 11:21:54 +02:00
template <bool test>
2013-03-16 19:13:01 +02:00
struct CMakeStaticAssert;
2016-07-09 11:21:54 +02:00
template <>
struct CMakeStaticAssert<true>
{
};
2013-03-16 19:13:01 +02:00
static const char fun_string[] = CMAKE_IS_;
#ifndef NO_SPACES_IN_DEFINE_VALUES
static const char very_fun_string[] = CMAKE_IS_REALLY;
#endif
2016-07-09 11:21:54 +02:00
enum
{
StringLiteralTest1 =
sizeof(CMakeStaticAssert<sizeof(CMAKE_IS_) == sizeof("Fun")>),
2013-03-16 19:13:01 +02:00
#ifndef NO_SPACES_IN_DEFINE_VALUES
2016-07-09 11:21:54 +02:00
StringLiteralTest2 =
sizeof(CMakeStaticAssert<sizeof(CMAKE_IS_REALLY) == sizeof("Very Fun")>),
2013-11-03 12:27:13 +02:00
#endif
#ifdef TEST_GENERATOR_EXPRESSIONS
2016-07-09 11:21:54 +02:00
StringLiteralTest3 =
sizeof(CMakeStaticAssert<sizeof(LETTER_LIST1) == sizeof("A,B,C,D")>),
StringLiteralTest4 =
sizeof(CMakeStaticAssert<sizeof(LETTER_LIST2) == sizeof("A,,B,,C,,D")>),
StringLiteralTest5 =
sizeof(CMakeStaticAssert<sizeof(LETTER_LIST3) == sizeof("A,-B,-C,-D")>),
StringLiteralTest6 =
sizeof(CMakeStaticAssert<sizeof(LETTER_LIST4) == sizeof("A-,-B-,-C-,-D")>),
StringLiteralTest7 =
sizeof(CMakeStaticAssert<sizeof(LETTER_LIST5) == sizeof("A-,B-,C-,D")>)
2013-03-16 19:13:01 +02:00
#endif
};
#ifdef TEST_GENERATOR_EXPRESSIONS
2018-08-09 18:06:22 +02:00
# ifndef CMAKE_IS_DECLARATIVE
# error Expect declarative definition
# endif
# ifdef GE_NOT_DEFINED
# error Expect not defined generator expression
# endif
# ifndef ARGUMENT
# error Expected define expanded from list
# endif
# ifndef LIST
# error Expected define expanded from list
# endif
# ifndef PREFIX_DEF1
# error Expect PREFIX_DEF1
# endif
# ifndef PREFIX_DEF2
# error Expect PREFIX_DEF2
# endif
# ifndef LINK_CXX_DEFINE
# error Expected LINK_CXX_DEFINE
# endif
# ifndef LINK_LANGUAGE_IS_CXX
# error Expected LINK_LANGUAGE_IS_CXX
# endif
# ifdef LINK_C_DEFINE
# error Unexpected LINK_C_DEFINE
# endif
# ifdef LINK_LANGUAGE_IS_C
# error Unexpected LINK_LANGUAGE_IS_C
# endif
2013-11-03 12:27:13 +02:00
2013-03-16 19:13:01 +02:00
// TEST_GENERATOR_EXPRESSIONS
#endif
2013-04-21 10:33:41 +03:00
#ifndef BUILD_IS_DEBUG
2018-08-09 18:06:22 +02:00
# error "BUILD_IS_DEBUG not defined!"
2013-04-21 10:33:41 +03:00
#endif
#ifndef BUILD_IS_NOT_DEBUG
2018-08-09 18:06:22 +02:00
# error "BUILD_IS_NOT_DEBUG not defined!"
2013-04-21 10:33:41 +03:00
#endif
// Check per-config definitions.
#ifdef TEST_CONFIG_DEBUG
2018-08-09 18:06:22 +02:00
# if !BUILD_IS_DEBUG
# error "BUILD_IS_DEBUG false with TEST_CONFIG_DEBUG!"
# endif
# if BUILD_IS_NOT_DEBUG
# error "BUILD_IS_NOT_DEBUG true with TEST_CONFIG_DEBUG!"
# endif
2013-04-21 10:33:41 +03:00
#else
2018-08-09 18:06:22 +02:00
# if BUILD_IS_DEBUG
# error "BUILD_IS_DEBUG true without TEST_CONFIG_DEBUG!"
# endif
# if !BUILD_IS_NOT_DEBUG
# error "BUILD_IS_NOT_DEBUG false without TEST_CONFIG_DEBUG!"
# endif
2013-04-21 10:33:41 +03:00
#endif
2016-07-09 11:21:54 +02:00
int main(int argc, char** argv)
2013-03-16 19:13:01 +02:00
{
return 0;
}