summaryrefslogtreecommitdiffstats
path: root/Modules/CMakeCXXCompilerId.cpp.in
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2008-08-07 13:09:45 (GMT)
committerBrad King <brad.king@kitware.com>2008-08-07 13:09:45 (GMT)
commitb8fc8b324d2e1b892d0b41cf3581226c210131d0 (patch)
tree5e36ef6e4586c5304ad69acc64e26779b426c842 /Modules/CMakeCXXCompilerId.cpp.in
parente58fab841fff0570d686200b916439cabe4deb83 (diff)
downloadCMake-b8fc8b324d2e1b892d0b41cf3581226c210131d0.zip
CMake-b8fc8b324d2e1b892d0b41cf3581226c210131d0.tar.gz
CMake-b8fc8b324d2e1b892d0b41cf3581226c210131d0.tar.bz2
ENH: Improve robustness of compiler INFO strings
Compiler INFO strings built at preprocessing time encode information that must appear as a string literal in the resulting binary. We must make sure the strings appear in the final binary no matter what compiler and flags are used. The previous implementation worked in most places but failed with the GNU linker's --gc-sections option which managed to discard the string. Instead we make the program return value depend on an element of the string indexed by a runtime program parameter, which absolutely requires the string to be present.
Diffstat (limited to 'Modules/CMakeCXXCompilerId.cpp.in')
-rw-r--r--Modules/CMakeCXXCompilerId.cpp.in14
1 files changed, 11 insertions, 3 deletions
diff --git a/Modules/CMakeCXXCompilerId.cpp.in b/Modules/CMakeCXXCompilerId.cpp.in
index 060c7e9..fa2178c 100644
--- a/Modules/CMakeCXXCompilerId.cpp.in
+++ b/Modules/CMakeCXXCompilerId.cpp.in
@@ -5,9 +5,6 @@
# error "A C compiler has been selected for C++."
#endif
-/* Provide main() so the program can link. */
-int main() { return 0; }
-
#if defined(__COMO__)
# define COMPILER_ID "Comeau"
@@ -70,3 +67,14 @@ int main() { return 0; }
char* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";
@CMAKE_CXX_COMPILER_ID_PLATFORM_CONTENT@
+
+/*--------------------------------------------------------------------------*/
+
+int main(int argc, char* argv[])
+{
+ int require = 0;
+ require += info_compiler[argc];
+ require += info_platform[argc];
+ (void)argv;
+ return require;
+}