added cmake warning when the cache generated on another host is reused
authorSzilard Pall <pszilard@cbr.su.se>
Wed, 23 Feb 2011 12:59:32 +0000 (13:59 +0100)
committerSzilard Pall <pszilard@cbr.su.se>
Wed, 23 Feb 2011 12:59:32 +0000 (13:59 +0100)
CMakeLists.txt

index 026b7a1849f54bfa13552c6db978247aa5a7a877..8a7c41ea6a9c38c210f9453f42d8240be63efb52 100644 (file)
@@ -52,6 +52,22 @@ set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/admin/InstallInfo.txt")
 #must come after all cpack settings!
 include(CPack)
 
+########################################################################
+# Check and warn if cache generated on a different host is being reused
+########################################################################
+if(CMAKE_HOST_UNIX)
+    execute_process(COMMAND hostname
+                    OUTPUT_VARIABLE TMP_HOSTNAME
+                    OUTPUT_STRIP_TRAILING_WHITESPACE)
+    if(GMX_BUILD_HOSTNAME AND NOT "${GMX_BUILD_HOSTNAME}" STREQUAL "${TMP_HOSTNAME}")
+        message(WARNING "
+            The CMake cache, probably generated on a different host (${GMX_BUILD_HOSTNAME}),
+            is being reused! This could lead to inconsitencies; therefore, it is
+            recommended to regenerate the cache!")
+    endif()
+    set(GMX_BUILD_HOSTNAME "${TMP_HOSTNAME}" CACHE INTERNAL
+            "Hostname of the machine where the cache was generated.")
+endif()
 
 ########################################################################
 # Fix stupid flags on MSVC