diff options
author | Brad King <brad.king@kitware.com> | 2008-01-14 14:20:58 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2008-01-14 14:20:58 (GMT) |
commit | 8262ccfd4efddd4928070c637ef7c414633b4b1e (patch) | |
tree | c276e3f4ec61422534586a008739bd668e1b9ce3 /Tests/Preprocess/preprocess.cxx | |
parent | 2c42f755225c0cb30f04f07c9f5bd23f65ad0bd2 (diff) | |
download | CMake-8262ccfd4efddd4928070c637ef7c414633b4b1e.zip CMake-8262ccfd4efddd4928070c637ef7c414633b4b1e.tar.gz CMake-8262ccfd4efddd4928070c637ef7c414633b4b1e.tar.bz2 |
ENH: Create COMPILE_DEFINITIONS property for targets and source files. Create <config>_COMPILE_DEFINITIONS property as per-configuration version. Add Preprocess test to test the feature. Document limitations on Xcode and VS6 generators.
Diffstat (limited to 'Tests/Preprocess/preprocess.cxx')
-rw-r--r-- | Tests/Preprocess/preprocess.cxx | 197 |
1 files changed, 197 insertions, 0 deletions
diff --git a/Tests/Preprocess/preprocess.cxx b/Tests/Preprocess/preprocess.cxx new file mode 100644 index 0000000..07b7183 --- /dev/null +++ b/Tests/Preprocess/preprocess.cxx @@ -0,0 +1,197 @@ +#include <preprocess.h> + +#include FILE_PATH +#include TARGET_PATH + +#include <string.h> +#include <stdio.h> + +extern "C" int check_defines_C(void); + +int check_defines_CXX() +{ + int result = 1; +#ifndef PREPROCESS_VS6 + if(strcmp(FILE_STRING, STRING_VALUE) != 0) + { + fprintf(stderr, + "FILE_STRING has wrong value in CXX [%s]\n", FILE_STRING); + result = 0; + } + if(strcmp(TARGET_STRING, STRING_VALUE) != 0) + { + fprintf(stderr, + "TARGET_STRING has wrong value in CXX [%s]\n", TARGET_STRING); + result = 0; + } + { + int x = 2; + int y = 3; + if((FILE_EXPR) != (EXPR)) + { + fprintf(stderr, "FILE_EXPR did not work in CXX [%s]\n", + TO_STRING(FILE_EXPR)); + result = 0; + } + if((TARGET_EXPR) != (EXPR)) + { + fprintf(stderr, "TARGET_EXPR did not work in CXX [%s]\n", + TO_STRING(FILE_EXPR)); + result = 0; + } + } +#endif +#ifdef NDEBUG +# ifdef FILE_DEF_DEBUG + { + fprintf(stderr, "FILE_DEF_DEBUG should not be defined in CXX\n"); + result = 0; + } +# endif +# ifdef TARGET_DEF_DEBUG + { + fprintf(stderr, "TARGET_DEF_DEBUG should not be defined in CXX\n"); + result = 0; + } +# endif +# ifndef FILE_DEF_RELEASE +# ifndef PREPROCESS_XCODE + { + fprintf(stderr, "FILE_DEF_RELEASE should be defined in CXX\n"); + result = 0; + } +# endif +# endif +# ifndef TARGET_DEF_RELEASE + { + fprintf(stderr, "TARGET_DEF_RELEASE should be defined in CXX\n"); + result = 0; + } +# endif +#endif +#ifdef PREPROCESS_DEBUG +# ifndef FILE_DEF_DEBUG +# ifndef PREPROCESS_XCODE + { + fprintf(stderr, "FILE_DEF_DEBUG should be defined in CXX\n"); + result = 0; + } +# endif +# endif +# ifndef TARGET_DEF_DEBUG + { + fprintf(stderr, "TARGET_DEF_DEBUG should be defined in CXX\n"); + result = 0; + } +# endif +# ifdef FILE_DEF_RELEASE + { + fprintf(stderr, "FILE_DEF_RELEASE should not be defined in CXX\n"); + result = 0; + } +# endif +# ifdef TARGET_DEF_RELEASE + { + fprintf(stderr, "TARGET_DEF_RELEASE should not be defined in CXX\n"); + result = 0; + } +# endif +#endif +#if defined(FILE_DEF_DEBUG) || defined(TARGET_DEF_DEBUG) +# if !defined(FILE_DEF_DEBUG) || !defined(TARGET_DEF_DEBUG) +# ifndef PREPROCESS_XCODE + { + fprintf(stderr, + "FILE_DEF_DEBUG and TARGET_DEF_DEBUG inconsistent in CXX\n"); + result = 0; + } +# endif +# endif +# if defined(FILE_DEF_RELEASE) || defined(TARGET_DEF_RELEASE) + { + fprintf(stderr, "DEBUG and RELEASE definitions inconsistent in CXX\n"); + result = 0; + } +# endif +#endif +#if defined(FILE_DEF_RELEASE) || defined(TARGET_DEF_RELEASE) +# if !defined(FILE_DEF_RELEASE) || !defined(TARGET_DEF_RELEASE) +# ifndef PREPROCESS_XCODE + { + fprintf(stderr, + "FILE_DEF_RELEASE and TARGET_DEF_RELEASE inconsistent in CXX\n"); + result = 0; + } +# endif +# endif +# if defined(FILE_DEF_DEBUG) || defined(TARGET_DEF_DEBUG) + { + fprintf(stderr, "RELEASE and DEBUG definitions inconsistent in CXX\n"); + result = 0; + } +# endif +#endif +#ifndef FILE_PATH_DEF + { + fprintf(stderr, "FILE_PATH_DEF not defined in CXX\n"); + result = 0; + } +#endif +#ifndef TARGET_PATH_DEF + { + fprintf(stderr, "TARGET_PATH_DEF not defined in CXX\n"); + result = 0; + } +#endif +#ifndef FILE_DEF + { + fprintf(stderr, "FILE_DEF not defined in CXX\n"); + result = 0; + } +#endif +#ifndef TARGET_DEF + { + fprintf(stderr, "TARGET_DEF not defined in CXX\n"); + result = 0; + } +#endif +#ifndef OLD_DEF + { + fprintf(stderr, "OLD_DEF not defined in CXX\n"); + result = 0; + } +#endif +#if !defined(OLD_EXPR) || OLD_EXPR != 2 + { + fprintf(stderr, "OLD_EXPR id not work in C [%s]\n", + TO_STRING(OLD_EXPR)); + result = 0; + } +#endif + return result; +} + +int main() +{ + int result = 1; + + if(!check_defines_C()) + { + result = 0; + } + + if(!check_defines_CXX()) + { + result = 0; + } + + if(result) + { + printf("All preprocessor definitions are correct.\n"); + return 0; + } + else + { + return 1; + } +} |