diff options
author | Brad King <brad.king@kitware.com> | 2008-03-10 13:32:25 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2008-03-10 13:32:25 (GMT) |
commit | 70c2dc8a64505d2cb6b3914dff966ea008865028 (patch) | |
tree | 078224d3162904cb42a4165029be52cac29431dd | |
parent | d73d9eb0f0ee96c78d16a3ce14bc98482b4f4f63 (diff) | |
download | CMake-70c2dc8a64505d2cb6b3914dff966ea008865028.zip CMake-70c2dc8a64505d2cb6b3914dff966ea008865028.tar.gz CMake-70c2dc8a64505d2cb6b3914dff966ea008865028.tar.bz2 |
ENH: Make compiler id detection more robust
- Split INFO strings in source into multiple pieces
to make sure assembly or other listings produced
by the compiler are never matched by the regex
- Store INFO strings via pointer instead of array
to convince some compilers to store the string
literally in the binary
- This should help make it work for sdcc 2.8.0 RC1
-rw-r--r-- | Modules/CMakeCCompilerId.c.in | 6 | ||||
-rw-r--r-- | Modules/CMakeCXXCompilerId.cpp.in | 6 | ||||
-rw-r--r-- | Modules/CMakePlatformId.h.in | 6 |
3 files changed, 15 insertions, 3 deletions
diff --git a/Modules/CMakeCCompilerId.c.in b/Modules/CMakeCCompilerId.c.in index d5ae00a..ecbe431 100644 --- a/Modules/CMakeCCompilerId.c.in +++ b/Modules/CMakeCCompilerId.c.in @@ -75,6 +75,10 @@ int main() { return 0; } #endif -char info_compiler[] = "INFO:compiler[" COMPILER_ID "]"; +/* Construct the string literal in pieces to prevent the source from + getting matched. Store it in a pointer rather than an array + because some compilers will just produce instructions to fill the + array rather than assigning a pointer to a static array. */ +char* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]"; @CMAKE_C_COMPILER_ID_PLATFORM_CONTENT@ diff --git a/Modules/CMakeCXXCompilerId.cpp.in b/Modules/CMakeCXXCompilerId.cpp.in index 7bdb5e0..060c7e9 100644 --- a/Modules/CMakeCXXCompilerId.cpp.in +++ b/Modules/CMakeCXXCompilerId.cpp.in @@ -63,6 +63,10 @@ int main() { return 0; } #endif -char info_compiler[] = "INFO:compiler[" COMPILER_ID "]"; +/* Construct the string literal in pieces to prevent the source from + getting matched. Store it in a pointer rather than an array + because some compilers will just produce instructions to fill the + array rather than assigning a pointer to a static array. */ +char* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]"; @CMAKE_CXX_COMPILER_ID_PLATFORM_CONTENT@ diff --git a/Modules/CMakePlatformId.h.in b/Modules/CMakePlatformId.h.in index f62eb36..1f1fca6 100644 --- a/Modules/CMakePlatformId.h.in +++ b/Modules/CMakePlatformId.h.in @@ -76,4 +76,8 @@ #endif -char info_platform[] = "INFO:platform[" PLATFORM_ID "]"; +/* Construct the string literal in pieces to prevent the source from + getting matched. Store it in a pointer rather than an array + because some compilers will just produce instructions to fill the + array rather than assigning a pointer to a static array. */ +char* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]"; |