Merge branch 'master' of git.gromacs.org:gromacs
[gromacs/qmmm-gamess-us.git] / cmake / gmxCheckBuildUserTime.cmake
blob2e81d5d771d4de32863f5fa92b17183bdbe9ef68
1 # - Check the username performing the build, as well as date and time
3 # GMX_CHECK_BUILD_USER_TIME(BUILD_TIME BUILD_USER BUILD_MACHINE)
5 # The macro variables will be set to the user/machine used for configuration,
6 # or anonymous/unknown if it cannot be detected (windows)
8 # BUILD_TIME
9 # BUILD_USER 
10 # BUILD_MACHINE
12 macro(gmx_check_build_user_time BUILD_TIME BUILD_USER BUILD_MACHINE)
13     IF(NOT DEFINED ${BUILD_USER})
15     message(STATUS "Setting build user & time")
16     if(CMAKE_HOST_UNIX)
17         execute_process( COMMAND date     OUTPUT_VARIABLE ${TMP_TIME}    OUTPUT_STRIP_TRAILING_WHITESPACE)
18         execute_process( COMMAND whoami   OUTPUT_VARIABLE TMP_USER       OUTPUT_STRIP_TRAILING_WHITESPACE)
19         execute_process( COMMAND hostname OUTPUT_VARIABLE TMP_HOSTNAME   OUTPUT_STRIP_TRAILING_WHITESPACE)
20         set(${BUILD_USER}    "@TMP_USER@\@@TMP_HOSTNAME@ [CMAKE]" CACHE INTERNAL "Build user")
21         set(${BUILD_TIME}    "@TMP_TIME@" CACHE INTERNAL "Build date & time")
22         execute_process( COMMAND uname -srm OUTPUT_VARIABLE ${TMP_MACHINE} OUTPUT_STRIP_TRAILING_WHITESPACE)
23         set(${BUILD_MACHINE} "@TMP_MACHINE@" CACHE INTERNAL "Build host & architecture")
24         message(STATUS "Setting build user & time - OK")
25     else(CMAKE_HOST_UNIX)
26         set(${BUILD_USER}    "Anonymous@unknown [CMAKE]" CACHE INTERNAL "Build user")
27         set(${BUILD_TIME}    "Unknown date" CACHE INTERNAL "Build date & time")
28         set(${BUILD_MACHINE} "@CMAKE_HOST_SYSTEM@ @CMAKE_HOST_SYSTEM_PROCESSOR@" CACHE INTERNAL "Build host & architecture") 
29         message(STATUS "Setting build user & time - not on Unix, using anonymous")
30     endif(CMAKE_HOST_UNIX)
32     ENDIF(NOT DEFINED ${BUILD_USER})
33 endmacro(gmx_check_build_user_time BUILD_TIME BUILD_USER BUILD_MACHINE)