Revision: 77475
          http://sourceforge.net/p/brlcad/code/77475
Author:   starseeker
Date:     2020-10-17 16:41:45 +0000 (Sat, 17 Oct 2020)
Log Message:
-----------
Pull the timestamping updates from thirdparty_rework back up into trunk.

Modified Paths:
--------------
    brlcad/trunk/CMakeLists.txt
    brlcad/trunk/misc/CMake/BRLCAD_Util.cmake
    brlcad/trunk/misc/CMake/CMakeLists.txt

Added Paths:
-----------
    brlcad/trunk/misc/CMake/scripts/
    brlcad/trunk/misc/CMake/scripts/printtime.cmake
    brlcad/trunk/misc/CMake/scripts/timestamp.cmake

Modified: brlcad/trunk/CMakeLists.txt
===================================================================
--- brlcad/trunk/CMakeLists.txt 2020-10-17 16:24:12 UTC (rev 77474)
+++ brlcad/trunk/CMakeLists.txt 2020-10-17 16:41:45 UTC (rev 77475)
@@ -146,13 +146,14 @@
 #---------------------------------------------------------------------
 # Set up the necessary support for timing of the configuration and
 # build processes
-set_config_time()
-generate_sstamp()
+string(TIMESTAMP CONFIG_DATE "%Y%m%d")
+string(TIMESTAMP CONFIG_DATESTAMP "%a, %d %b %Y %H:%M:%S UTC" UTC)
 
 #---------------------------------------------------------------------
 # Mark the time at which the configuration process began.
+
 set(CONFIG_DELTA_START "${CMAKE_BINARY_DIR}/CMakeTmp/CONFIG_DELTA_START")
-execute_process(COMMAND "${CMAKE_BINARY_DIR}/CMakeTmp/sstamp${EXE_EXT}" 
"${CONFIG_DELTA_START}")
+execute_process(COMMAND "${CMAKE_COMMAND}" -DSTAMP_FILE=${CONFIG_DELTA_START} 
-P "${BRLCAD_CMAKE_DIR}/scripts/timestamp.cmake")
 
 #------------------------------------------------------------------------------
 # The SuperBuild (https://blog.kitware.com/cmake-superbuilds-git-submodules/)
@@ -3208,28 +3209,23 @@
 # *******************************************************************
 # ***                      Timestamp Rules                        ***
 # *******************************************************************
-# TODO - As of CMake 2.8.11, the string command has a TIMESTAMP option
-# that may be able to simplify some of the current timestamp system.
-# We would need to be able to require 2.8.11 or newer, so there will
-# be a bit of a wait, but it's something to look into.
-
 # Set up rules to print a timestamp string during build
 set(BUILD_DELTA_START "${CMAKE_BINARY_DIR}/CMakeTmp/BUILD_DELTA_START")
 
 add_custom_command(
-  OUTPUT ${BUILD_DELTA_START}
-  COMMAND ${CMAKE_BINARY_DIR}/CMakeTmp/sstamp${EXE_EXT} "${BUILD_DELTA_START}"
-  COMMENT ""
-  )
+    OUTPUT ${BUILD_DELTA_START}
+    COMMAND "${CMAKE_COMMAND}" -DSTAMP_FILE=${BUILD_DELTA_START} -P 
"${BRLCAD_CMAKE_DIR}/scripts/timestamp.cmake"
+    COMMENT ""
+    )
 add_custom_target(timestamp ALL
-  COMMAND ${CMAKE_BINARY_DIR}/CMakeTmp/pts${EXE_EXT} \"Build Time:  \"
-  DEPENDS ${BUILD_DELTA_START}
-  )
+    COMMAND "${CMAKE_COMMAND}" -DMSG=\"Build Time:\" -P 
"${BRLCAD_CMAKE_DIR}/scripts/printtime.cmake"
+    DEPENDS ${BUILD_DELTA_START}
+    )
 set_target_properties(timestamp PROPERTIES FOLDER "Compilation Utilities")
 add_custom_target(buildtimedelta ALL
-  COMMAND ${CMAKE_BINARY_DIR}/CMakeTmp/dreport${EXE_EXT} final 
${BUILD_DELTA_START} ${CONFIG_DELTA_START}
-  COMMAND ${CMAKE_COMMAND} -E remove ${BUILD_DELTA_START}
-  )
+    COMMAND ${CMAKE_BINARY_DIR}/CMakeTmp/dreport${EXE_EXT} final 
${BUILD_DELTA_START} ${CONFIG_DELTA_START}
+    COMMAND ${CMAKE_COMMAND} -E remove ${BUILD_DELTA_START}
+    )
 set_target_properties(buildtimedelta PROPERTIES FOLDER "Compilation Utilities")
 
 #------------------------------------------------------------------------------

Modified: brlcad/trunk/misc/CMake/BRLCAD_Util.cmake
===================================================================
--- brlcad/trunk/misc/CMake/BRLCAD_Util.cmake   2020-10-17 16:24:12 UTC (rev 
77474)
+++ brlcad/trunk/misc/CMake/BRLCAD_Util.cmake   2020-10-17 16:41:45 UTC (rev 
77475)
@@ -477,152 +477,12 @@
   endif(TARGET ${tname})
 endfunction(ADD_TARGET_DEPS tname)
 
-#---------------------------------------------------------------------------
-# Set variables reporting time of configuration.  Sets CONFIG_DATE and
-# CONFIG_DATESTAMP in parent scope.
-#
-# Unfortunately, CMake doesn't give you variables with current day,
-# month, etc.  There are several possible approaches to this, but most
-# (e.g. the date command) are not cross platform. We build a small C
-# program which supplies the needed info.
-function(set_config_time)
 
-  # We don't want any parent C flags here - hopefully, the below code will
-  # "just work" in any environment we care about.  The gnu89 standard doesn't
-  # like the %z print specifier, but unless/until we hit a compiler that really
-  # can't deal with it don't worry about it.
-  set(CMAKE_C_FLAGS "")
-
-  set(rfc2822_src "
-/* RFC2822 timestamp and individual day, month and year files */
-
-#include <time.h>
-#include <stdio.h>
-#include <string.h>
-
-int main(int argc, const char **argv) {
-   time_t t = time(NULL);
-   struct tm *currenttime = localtime(&t);
-   if (argc <= 1) {
-      char rfc2822[200];
-      strftime(rfc2822, sizeof(rfc2822), \"%a, %d %b %Y %H:%M:%S %z\", 
currenttime);
-      printf(\"%s\", rfc2822);
-      return 0;
-   }
-   if (strncmp(argv[1], \"day\", 4) == 0) {
-      printf(\"%02d\", currenttime->tm_mday);
-   }
-   if (strncmp(argv[1], \"month\", 5) == 0) {
-      printf(\"%02d\", currenttime->tm_mon + 1);
-   }
-   if (strncmp(argv[1], \"year\", 4) == 0) {
-      printf(\"%d\", currenttime->tm_year + 1900);
-   }
-   return 0;
-}")
-
-  # Build the code so we can run it
-  file(WRITE "${CMAKE_BINARY_DIR}/CMakeTmp/rfc2822.c" "${rfc2822_src}")
-  try_compile(rfc2822_build "${CMAKE_BINARY_DIR}/CMakeTmp"
-    SOURCES "${CMAKE_BINARY_DIR}/CMakeTmp/rfc2822.c"
-    OUTPUT_VARIABLE RFC2822_BUILD_INFO
-    COPY_FILE "${CMAKE_BINARY_DIR}/CMakeTmp/rfc2822${EXE_EXT}")
-  if(NOT rfc2822_build)
-    message(FATAL_ERROR "Could not build rfc2822 timestamp pretty-printing 
utility: ${RFC2822_BUILD_INFO}")
-  endif(NOT rfc2822_build)
-  file(REMOVE "${CMAKE_BINARY_DIR}/CMakeTmp/rfc2822.c")
-
-  # Build up and set CONFIG_DATE
-  execute_process(COMMAND "${CMAKE_BINARY_DIR}/CMakeTmp/rfc2822" day 
OUTPUT_VARIABLE CONFIG_DAY)
-  string(STRIP ${CONFIG_DAY} CONFIG_DAY)
-  execute_process(COMMAND "${CMAKE_BINARY_DIR}/CMakeTmp/rfc2822" month 
OUTPUT_VARIABLE CONFIG_MONTH)
-  string(STRIP ${CONFIG_MONTH} CONFIG_MONTH)
-  execute_process(COMMAND "${CMAKE_BINARY_DIR}/CMakeTmp/rfc2822" year 
OUTPUT_VARIABLE CONFIG_YEAR)
-  string(STRIP ${CONFIG_YEAR} CONFIG_YEAR)
-  set(CONFIG_DATE "${CONFIG_YEAR}${CONFIG_MONTH}${CONFIG_DAY}" PARENT_SCOPE)
-
-  # Set DATESTAMP
-  execute_process(COMMAND "${CMAKE_BINARY_DIR}/CMakeTmp/rfc2822" 
OUTPUT_VARIABLE RFC2822_STRING)
-  string(STRIP ${RFC2822_STRING} RFC2822_STRING)
-  set(CONFIG_DATESTAMP "${RFC2822_STRING}" PARENT_SCOPE)
-
-  # Cleanup
-  file(REMOVE "${CMAKE_BINARY_DIR}/CMakeTmp/rfc2822")
-
-endfunction(set_config_time)
-
 #---------------------------------------------------------------------------
 # Code for timing configuration and building of BRL-CAD.  These executables
 # are used to define build targets for cross-platform reporting.  Run after
 # set_config_time.
-function(generate_sstamp)
 
-  #########################################################################
-  # Print a basic time stamp
-
-  set(printtimestamp_src "
-#define _CRT_SECURE_NO_WARNINGS 1
-
-#include <time.h>
-#include <stdio.h>
-
-int main(int argc, const char **argv)
-{
-  time_t t = time(NULL);
-  struct tm *currenttime = localtime(&t);
-  if (argc < 2) return 1;
-  printf(\"\\n%s%s\\n\", argv[1], asctime(currenttime));
-  return 0;
-}
-")
-
-  file(WRITE "${CMAKE_BINARY_DIR}/CMakeTmp/printtimestamp.c" 
"${printtimestamp_src}")
-  try_compile(pts_build ${CMAKE_BINARY_DIR}/CMakeTmp
-    "${CMAKE_BINARY_DIR}/CMakeTmp/printtimestamp.c"
-    COPY_FILE ${CMAKE_BINARY_DIR}/CMakeTmp/pts${EXE_EXT})
-  if(NOT pts_build)
-    message(FATAL_ERROR "Could not build timestamp pretty-printing utility")
-  endif(NOT pts_build)
-
-  #########################################################################
-  # We need some way to know at the end of the build when we kicked things
-  # off (both configuration and the build itself).  Create a simple program
-  # that can stash that info in a file
-
-  set(sstamp_src "
-#define _CRT_SECURE_NO_WARNINGS 1
-
-#include <time.h>
-#include <stdio.h>
-
-int main(int argc, const char **argv) {
-  FILE *outfp = NULL;
-  time_t t = time(NULL);
-  if (argc < 2) return 1;
-  outfp = fopen(argv[1], \"w\");
-  fprintf(outfp, \"%ld\", (long)t);
-  fclose(outfp);
-  return 0;
-}
-")
-
-  # Build the code so we can run it
-  file(WRITE "${CMAKE_BINARY_DIR}/CMakeTmp/sstamp.c" "${sstamp_src}")
-  try_compile(sstamp_build "${CMAKE_BINARY_DIR}/CMakeTmp"
-    SOURCES "${CMAKE_BINARY_DIR}/CMakeTmp/sstamp.c"
-    OUTPUT_VARIABLE SSTAMP_BUILD_INFO
-    COPY_FILE "${CMAKE_BINARY_DIR}/CMakeTmp/sstamp${EXE_EXT}")
-  if(NOT sstamp_build)
-    message(FATAL_ERROR "Could not build second timestamping utility: 
${SSTAMP_BUILD_INFO}")
-  endif(NOT sstamp_build)
-  file(REMOVE "${CMAKE_BINARY_DIR}/CMakeTmp/sstamp.c")
-  if(COMMAND distclean)
-    distclean("${CMAKE_BINARY_DIR}/CMakeTmp/sstamp")
-  endif(COMMAND distclean)
-
-endfunction(generate_sstamp)
-
-
 function(generate_dreport)
 
   #########################################################################

Modified: brlcad/trunk/misc/CMake/CMakeLists.txt
===================================================================
--- brlcad/trunk/misc/CMake/CMakeLists.txt      2020-10-17 16:24:12 UTC (rev 
77474)
+++ brlcad/trunk/misc/CMake/CMakeLists.txt      2020-10-17 16:41:45 UTC (rev 
77475)
@@ -95,6 +95,8 @@
   multiconfig_path_read.cmake.in
   source_archive_setup.cmake.in
   tcltest.tcl.in
+  scripts/timestamp.cmake
+  scripts/printtime.cmake
   )
 CMAKEFILES(${cmake_ignore_files})
 

Added: brlcad/trunk/misc/CMake/scripts/printtime.cmake
===================================================================
--- brlcad/trunk/misc/CMake/scripts/printtime.cmake                             
(rev 0)
+++ brlcad/trunk/misc/CMake/scripts/printtime.cmake     2020-10-17 16:41:45 UTC 
(rev 77475)
@@ -0,0 +1,3 @@
+string(TIMESTAMP CTIME "%a %b %d %H:%M:%S %Y")
+message("\n${MSG}  ${CTIME}\n")
+


Property changes on: brlcad/trunk/misc/CMake/scripts/printtime.cmake
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: brlcad/trunk/misc/CMake/scripts/timestamp.cmake
===================================================================
--- brlcad/trunk/misc/CMake/scripts/timestamp.cmake                             
(rev 0)
+++ brlcad/trunk/misc/CMake/scripts/timestamp.cmake     2020-10-17 16:41:45 UTC 
(rev 77475)
@@ -0,0 +1,12 @@
+string(TIMESTAMP CTIME "%s")
+if (NOT STAMP_FILE)
+  message(FATAL_ERROR "No stamp file specified")
+endif (NOT STAMP_FILE)
+file(WRITE "${STAMP_FILE}" "${CTIME}\n")
+
+# Local Variables:
+# tab-width: 8
+# mode: cmake
+# indent-tabs-mode: t
+# End:
+# ex: shiftwidth=2 tabstop=8


Property changes on: brlcad/trunk/misc/CMake/scripts/timestamp.cmake
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to