Revision: 69959
          http://sourceforge.net/p/brlcad/code/69959
Author:   starseeker
Date:     2017-07-16 22:08:08 +0000 (Sun, 16 Jul 2017)
Log Message:
-----------
Further simplification of the timing logic.

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

Modified: brlcad/trunk/CMakeLists.txt
===================================================================
--- brlcad/trunk/CMakeLists.txt 2017-07-16 21:23:19 UTC (rev 69958)
+++ brlcad/trunk/CMakeLists.txt 2017-07-16 22:08:08 UTC (rev 69959)
@@ -138,49 +138,12 @@
 # Set up the necessary support for timing of the configuration and
 # build processes
 set_config_time()
-#generate_timer_exes()
+generate_timer_exes()
 
 #---------------------------------------------------------------------
-# Write out entries to populate a tm struct (will be used for time
-# delta calculations later)
-if(NOT BRLCAD_IS_SUBBUILD)
-  set(DELTA_START "${CMAKE_BINARY_DIR}/CMakeTmp/DELTA_START")
-  set(timedelta_start_src "
-#include <time.h>
-#include <stdio.h>
-int main(void) {
-  FILE *outfp = NULL;
-  time_t t;
-  struct tm *currenttime;
-  t = time(NULL);
-  currenttime = localtime(&t);
-  outfp = fopen(\"${DELTA_START}\", \"w\");
-  fprintf(outfp, \"%d/\", currenttime->tm_sec);         /* seconds after the 
minute [0-60] */
-  fprintf(outfp, \"%d/\", currenttime->tm_min);         /* minutes after the 
hour [0-59] */
-  fprintf(outfp, \"%d/\", currenttime->tm_hour);        /* hours since 
midnight [0-23] */
-  fprintf(outfp, \"%d/\", currenttime->tm_mday);        /* day of the month 
[1-31] */
-  fprintf(outfp, \"%d/\", currenttime->tm_mon);         /* months since 
January [0-11] */
-  fprintf(outfp, \"%d/\", currenttime->tm_year);        /* years since 1900 */
-  fprintf(outfp, \"%d/\", currenttime->tm_wday);        /* days since Sunday 
[0-6] */
-  fprintf(outfp, \"%d/\", currenttime->tm_yday);        /* days since January 
1 [0-365] */
-  fprintf(outfp, \"%d\", currenttime->tm_isdst);       /* Daylight Savings 
Time flag */
-  fclose(outfp);
-  return 0;
-}
-")
-  file(WRITE "${CMAKE_BINARY_DIR}/CMakeTmp/timedelta_start.c" 
"${timedelta_start_src}")
-  try_run(TIME_RESULT TIME_COMPILED
-    "${CMAKE_BINARY_DIR}/CMakeTmp"
-    "${CMAKE_BINARY_DIR}/CMakeTmp/timedelta_start.c"
-    OUTPUT_VARIABLE COMPILEMESSAGES)
-  file(REMOVE "${CMAKE_BINARY_DIR}/CMakeTmp/timedelta_start.c")
-endif(NOT BRLCAD_IS_SUBBUILD)
-
-
-#---------------------------------------------------------------------
 # Mark the time at which the configuration process began.
-#set(DELTA_START "${CMAKE_BINARY_DIR}/CMakeTmp/DELTA_START")
-#execute_process(COMMAND "${CMAKE_BINARY_DIR}/CMakeTmp/sstamp" 
"${DELTA_START}")
+set(CONFIG_DELTA_START "${CMAKE_BINARY_DIR}/CMakeTmp/CONFIG_DELTA_START")
+execute_process(COMMAND "${CMAKE_BINARY_DIR}/CMakeTmp/sstamp" 
"${CONFIG_DELTA_START}")
 
 #---------------------------------------------------------------------
 # Allow the BRLCAD_ROOT environment variable to set CMAKE_INSTALL_PREFIX
@@ -2786,193 +2749,20 @@
 if(NOT BRLCAD_IS_SUBBUILD)
 
   # Set up rules to print a timestamp string during build
-
-  
#################################################################################
-  # We need to stamp the start time in a format we can read back in later.
-  set(BUILD_DELTA_FILE "${CMAKE_BINARY_DIR}/CMakeTmp/BUILD_DELTA_FILE")
-  set(builddelta_start_src "
-#define _CRT_SECURE_NO_WARNINGS 1
-
-#include <time.h>
-#include <stdio.h>
-
-int main(void)
-{
-  FILE *outfp = NULL;
-  time_t t;
-  struct tm *currenttime;
-  t = time(NULL);
-  currenttime = localtime(&t);
-  outfp = fopen(\"${BUILD_DELTA_FILE}\", \"w\");
-  fprintf(outfp, \"%d/\", currenttime->tm_sec);         /* seconds after the 
minute [0-60] */
-  fprintf(outfp, \"%d/\", currenttime->tm_min);         /* minutes after the 
hour [0-59] */
-  fprintf(outfp, \"%d/\", currenttime->tm_hour);        /* hours since 
midnight [0-23] */
-  fprintf(outfp, \"%d/\", currenttime->tm_mday);        /* day of the month 
[1-31] */
-  fprintf(outfp, \"%d/\", currenttime->tm_mon);         /* months since 
January [0-11] */
-  fprintf(outfp, \"%d/\", currenttime->tm_year);        /* years since 1900 */
-  fprintf(outfp, \"%d/\", currenttime->tm_wday);        /* days since Sunday 
[0-6] */
-  fprintf(outfp, \"%d/\", currenttime->tm_yday);        /* days since January 
1 [0-365] */
-  fprintf(outfp, \"%d\", currenttime->tm_isdst);        /* Daylight Savings 
Time flag */
-  fclose(outfp);
-  return 0;
-}
-")
-  file(WRITE "${CMAKE_BINARY_DIR}/CMakeTmp/builddelta_start.c" 
"${builddelta_start_src}")
-  try_compile(bds_build ${CMAKE_BINARY_DIR}/CMakeTmp
-    "${CMAKE_BINARY_DIR}/CMakeTmp/builddelta_start.c"
-    COPY_FILE ${CMAKE_BINARY_DIR}/CMakeTmp/bds)
-  if(NOT bds_build)
-    message(FATAL_ERROR "Could not build timestamp initialization utility")
-  endif(NOT bds_build)
-
-  
#################################################################################
-  # The following code does most of the work to pretty-print the timing 
information
-
   set(BUILD_DELTA_START "${CMAKE_BINARY_DIR}/CMakeTmp/BUILD_DELTA_START")
 
-  # The install instructions at the end of the message are tool specific - key
-  # off of generators or build tools.
-  if("${CMAKE_GENERATOR}" MATCHES "Make")
-    set(INSTALL_LINE "Run 'make install' to begin installation into 
${CMAKE_INSTALL_PREFIX}")
-    set(BENCHMARK_LINE "Run 'make benchmark' to run the BRL-CAD Benchmark 
Suite")
-  endif("${CMAKE_GENERATOR}" MATCHES "Make")
-  if("${CMAKE_GENERATOR}" MATCHES "Ninja")
-    set(INSTALL_LINE "Run 'ninja install' to begin installation into 
${CMAKE_INSTALL_PREFIX}")
-    set(BENCHMARK_LINE "Run 'ninja benchmark' to run the BRL-CAD Benchmark 
Suite")
-  endif("${CMAKE_GENERATOR}" MATCHES "Ninja")
-  if("${CMAKE_GENERATOR}" MATCHES "Xcode")
-    set(INSTALL_LINE "Run 'xcodebuild -target install' to begin installation 
into ${CMAKE_INSTALL_PREFIX}")
-    set(BENCHMARK_LINE "Run 'xcodebuild -target benchmark' to run the BRL-CAD 
Benchmark Suite")
-  endif("${CMAKE_GENERATOR}" MATCHES "Xcode")
-  if(MSVC)
-    # slightly misuse the lines for MSVC, since we don't usually do the
-    # install/benchmark routine there. (Benchmarks aren't currently supported
-    # in MSVC anyway.)
-    set(INSTALL_LINE "To build, launch Visual Studio and open 
${CMAKE_BINARY_DIR}/BRLCAD.sln")
-    set(BENCHMARK_LINE "Build the ALL_BUILD target.  To create an NSIS 
installer, build the PACKAGE target")
-  endif(MSVC)
-
-  set(builddelta_end_srcs "
-#define _CRT_SECURE_NO_WARNINGS 1
-
-#include <time.h>
-#include <stdio.h>
-
-void printtime(int tdiff) {
-  int d_mins, d_hrs, d_days;
-  d_days = 0; d_hrs = 0; d_mins = 0;
-
-  /* get days */
-  if (tdiff > 86400) { d_days = tdiff / 86400; tdiff = tdiff % 86400; }
-  /* get hours */
-  if (tdiff > 3600) { d_hrs = tdiff / 3600; tdiff = tdiff % 3600; }
-  /* get minutes */
-  if (tdiff > 60) { d_mins = tdiff / 60; tdiff = tdiff % 60; }
-  /* print */
-  if (d_days > 0) { if (d_days == 1) { printf(\"%d day \", d_days); } else { 
printf(\"%d days \", d_days); } }
-  if (d_hrs > 0) { if (d_hrs == 1) { printf(\"%d hour \", d_hrs); } else { 
printf(\"%d hours \", d_hrs); } }
-  if (d_mins > 0) { if (d_mins == 1) { printf(\"%d minute \", d_mins); } else 
{ printf(\"%d minutes \", d_mins); } }
-  if (tdiff > 0) { if (tdiff == 1) { printf(\"%d second \", tdiff); } else { 
printf(\"%d seconds \", tdiff); } }
-  if (tdiff == 0 && d_mins == 0 && d_hrs == 0 && d_days == 0) { printf(\"0 
seconds \"); }
-}
-
-
-int
-main(void)
-{
-  FILE *infp = NULL;
-  time_t t, ts, te;
-  struct tm *ctm;
-  struct tm stm;
-  int tdiff;
-  double tdiff_tmp;
-
-  t = time(NULL);
-  ctm = localtime(&t);
-
-  infp = fopen(\"${BUILD_DELTA_START}\", \"r\");
-  if(!fscanf(infp, \"%d/%d/%d/%d/%d/%d/%d/%d/%d\", &(stm.tm_sec), 
&(stm.tm_min), &(stm.tm_hour), &(stm.tm_mday), &(stm.tm_mon), &(stm.tm_year), 
&(stm.tm_wday), &(stm.tm_yday), &(stm.tm_isdst)))
-    printf(\"scan error\\n\");
-  fclose(infp);
-
-  ts = mktime(&stm);
-  te = mktime(ctm);
-
-  printf(\"Done.\\n\\nBRL-CAD Release ${BRLCAD_VERSION}, Build 
${CONFIG_DATE}\\n\\nElapsed compilation time: \");
-
-  tdiff_tmp = difftime(te, ts);
-  tdiff = (int)tdiff_tmp; /* intentionally truncates */
-  printtime(tdiff);
-
-  printf(\"\\nElapsed time since configuration: \");
-
-  infp = fopen(\"${DELTA_START}\", \"r\");
-  if(!fscanf(infp, \"%d/%d/%d/%d/%d/%d/%d/%d/%d\", &(stm.tm_sec), 
&(stm.tm_min), &(stm.tm_hour), &(stm.tm_mday), &(stm.tm_mon), &(stm.tm_year), 
&(stm.tm_wday), &(stm.tm_yday), &(stm.tm_isdst)))
-    printf(\"scan error\\n\");
-  fclose(infp);
-
-  ts = mktime(&stm);
-  tdiff_tmp = difftime(te, ts);
-  tdiff = (int)tdiff_tmp; /* intentionally truncates */
-  printtime(tdiff);
-  printf(\"\\n---\\n${INSTALL_LINE}\\n${BENCHMARK_LINE}\\n\\n\");
-
-  return 0;
-}
-")
-
-  file(WRITE "${CMAKE_BINARY_DIR}/CMakeTmp/builddelta_end.c" 
"${builddelta_end_srcs}")
-  try_compile(bde_build ${CMAKE_BINARY_DIR}/CMakeTmp
-    "${CMAKE_BINARY_DIR}/CMakeTmp/builddelta_end.c"
-    COPY_FILE ${CMAKE_BINARY_DIR}/CMakeTmp/bde)
-  if(NOT bde_build)
-    message(FATAL_ERROR "Could not build timestamp pretty-printing utility")
-  endif(NOT bde_build)
-
-  
#################################################################################
-  # Print a basic time stamp
-
-  set(printtimestamp_src "
-#define _CRT_SECURE_NO_WARNINGS 1
-
-#include <time.h>
-#include <stdio.h>
-
-int main(void)
-{
-  time_t t;
-  struct tm *currenttime;
-  t = time(NULL);
-  currenttime = localtime(&t);
-  printf(\"\\nBuild Time: %s\\n\", 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)
-  if(NOT pts_build)
-    message(FATAL_ERROR "Could not build timestamp pretty-printing utility")
-  endif(NOT pts_build)
-
-  ##########################################################
-  # Having created the executables, define the build targets
-
   add_custom_command(
-    OUTPUT ${BUILD_DELTA_FILE}
-    COMMAND ${CMAKE_BINARY_DIR}/CMakeTmp/bds
+    OUTPUT ${BUILD_DELTA_START}
+    COMMAND ${CMAKE_BINARY_DIR}/CMakeTmp/sstamp "${BUILD_DELTA_START}"
     COMMENT ""
     )
   add_custom_target(timestamp ALL
-    COMMAND ${CMAKE_BINARY_DIR}/CMakeTmp/pts
-    COMMAND ${CMAKE_COMMAND} -E rename ${BUILD_DELTA_FILE} ${BUILD_DELTA_START}
-    DEPENDS ${BUILD_DELTA_FILE}
+    COMMAND ${CMAKE_BINARY_DIR}/CMakeTmp/pts "Build Time:  "
+    DEPENDS ${BUILD_DELTA_START}
     )
   set_target_properties(timestamp PROPERTIES FOLDER "Compilation Utilities")
   add_custom_target(buildtimedelta ALL
-    COMMAND ${CMAKE_BINARY_DIR}/CMakeTmp/bde
+    COMMAND ${CMAKE_BINARY_DIR}/CMakeTmp/dreport final ${BUILD_DELTA_START} 
${CONFIG_DELTA_START}
     COMMAND ${CMAKE_COMMAND} -E remove ${BUILD_DELTA_START}
     )
   set_target_properties(buildtimedelta PROPERTIES FOLDER "Compilation 
Utilities")
@@ -3359,59 +3149,7 @@
 
 #Done with all really time-consuming steps - do the configure time delta
 if(NOT BRLCAD_IS_SUBBUILD)
-  set(DELTA_END "${CMAKE_BINARY_DIR}/CMakeTmp/DELTA_END")
-  set(timedelta_end_src "
-#include <time.h>
-#include <stdio.h>
-int main(void) {
-  FILE *infp = NULL; FILE *outfp = NULL;
-  time_t t, ts, te;
-  struct tm *currenttime; struct tm starttime;
-  double tdiff_f;
-  int tdiff, d_mins, d_hrs, d_days;
-  t = time(NULL);
-  currenttime = localtime(&t);
-  infp = fopen(\"${DELTA_START}\", \"r\");
-  outfp = fopen(\"${DELTA_END}\", \"w\");
-  if(!fscanf(infp, \"%d/%d/%d/%d/%d/%d/%d/%d/%d\", &(starttime.tm_sec), 
&(starttime.tm_min), &(starttime.tm_hour), &(starttime.tm_mday), 
&(starttime.tm_mon), &(starttime.tm_year), &(starttime.tm_wday), 
&(starttime.tm_yday), &(starttime.tm_isdst)))
-    printf(\"scan error\\n\");
-  fclose(infp);
-
-  ts = mktime(&starttime); te = mktime(currenttime);
-  tdiff_f = difftime(te, ts); tdiff = (int)tdiff_f;
-  d_days = 0; d_hrs = 0; d_mins = 0;
-  /* get days */
-  if (tdiff > 86400) { d_days = tdiff / 86400; tdiff = tdiff % 86400; }
-  /* get hours */
-  if (tdiff > 3600) { d_hrs = tdiff / 3600; tdiff = tdiff % 3600; }
-  /* get minutes */
-  if (tdiff > 60) { d_mins = tdiff / 60; tdiff = tdiff % 60; }
-  /* print */
-  if (d_days > 0) { if (d_days == 1) { fprintf(outfp,\"%d day \", d_days); } 
else { fprintf(outfp,\"%d days \", d_days); } }
-  if (d_hrs> 0) { if (d_hrs == 1) { fprintf(outfp,\"%d hour \", d_hrs); } else 
{ fprintf(outfp,\"%d hours \", d_hrs); } }
-  if (d_mins > 0) { if (d_mins == 1) { fprintf(outfp,\"%d minute \", d_mins); 
} else { fprintf(outfp,\"%d minutes \", d_mins); } }
-  if (tdiff > 0) { if (tdiff == 1) { fprintf(outfp,\"%d second \", tdiff); } 
else { fprintf(outfp,\"%d seconds \", tdiff); } }
-  if (tdiff == 0 && d_mins == 0 && d_hrs == 0 && d_days == 0) { 
fprintf(outfp,\"0 seconds \"); }
-  fclose(outfp);
-  return 0;
-}
-")
-  file(WRITE "${CMAKE_BINARY_DIR}/CMakeTmp/timedelta_end.c" 
"${timedelta_end_src}")
-  try_run(TIME_RESULT TIME_COMPILED
-    "${CMAKE_BINARY_DIR}/CMakeTmp"
-    "${CMAKE_BINARY_DIR}/CMakeTmp/timedelta_end.c"
-    OUTPUT_VARIABLE COMPILEMESSAGES)
-  #file(REMOVE "${CMAKE_BINARY_DIR}/CMakeTmp/timedelta_end.c")
-  file(READ ${DELTA_END} CONFIG_TIME_MSG)
-  string(STRIP "${CONFIG_TIME_MSG}" CONFIG_TIME_MSG)
-  set(CONFIG_TIME_MSG_LABEL "Elapsed configuration time")
-  string(LENGTH "${CONFIG_TIME_MSG_LABEL}" CURRENTLENGTH)
-  while(${SETTINGLABELLENGTH} GREATER ${CURRENTLENGTH})
-    set(CONFIG_TIME_MSG_LABEL "${CONFIG_TIME_MSG_LABEL}.")
-    string(LENGTH "${CONFIG_TIME_MSG_LABEL}" CURRENTLENGTH)
-  endwhile(${SETTINGLABELLENGTH} GREATER ${CURRENTLENGTH})
-  message("${CONFIG_TIME_MSG_LABEL}..: ${CONFIG_TIME_MSG}")
-
+  execute_process(COMMAND "${CMAKE_BINARY_DIR}/CMakeTmp/dreport" "Elapsed 
configuration time: " "${CONFIG_DELTA_START}")
 endif(NOT BRLCAD_IS_SUBBUILD)
 
 # Write out the Doxygen feature list

Modified: brlcad/trunk/misc/CMake/BRLCAD_Util.cmake
===================================================================
--- brlcad/trunk/misc/CMake/BRLCAD_Util.cmake   2017-07-16 21:23:19 UTC (rev 
69958)
+++ brlcad/trunk/misc/CMake/BRLCAD_Util.cmake   2017-07-16 22:08:08 UTC (rev 
69959)
@@ -568,6 +568,157 @@
 
 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_timer_exes)
+
+  #########################################################################
+  # 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)
+  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")
+  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)
+
+  #########################################################################
+  # To report at the end what the actual deltas are, we need to read in the
+  # time stamps from the previous program and do some math.
+
+  # The install instructions at the end of the message are tool specific - key
+  # off of generators or build tools.
+  if("${CMAKE_GENERATOR}" MATCHES "Make")
+    set(INSTALL_LINE "Run 'make install' to begin installation into 
${CMAKE_INSTALL_PREFIX}")
+    set(BENCHMARK_LINE "Run 'make benchmark' to run the BRL-CAD Benchmark 
Suite")
+  endif("${CMAKE_GENERATOR}" MATCHES "Make")
+  if("${CMAKE_GENERATOR}" MATCHES "Ninja")
+    set(INSTALL_LINE "Run 'ninja install' to begin installation into 
${CMAKE_INSTALL_PREFIX}")
+    set(BENCHMARK_LINE "Run 'ninja benchmark' to run the BRL-CAD Benchmark 
Suite")
+  endif("${CMAKE_GENERATOR}" MATCHES "Ninja")
+  if("${CMAKE_GENERATOR}" MATCHES "Xcode")
+    set(INSTALL_LINE "Run 'xcodebuild -target install' to begin installation 
into ${CMAKE_INSTALL_PREFIX}")
+    set(BENCHMARK_LINE "Run 'xcodebuild -target benchmark' to run the BRL-CAD 
Benchmark Suite")
+  endif("${CMAKE_GENERATOR}" MATCHES "Xcode")
+  if(MSVC)
+    # slightly misuse the lines for MSVC, since we don't usually do the
+    # install/benchmark routine there. (Benchmarks aren't currently supported
+    # in MSVC anyway.)
+    set(INSTALL_LINE "To build, launch Visual Studio and open 
${CMAKE_BINARY_DIR}/BRLCAD.sln")
+    set(BENCHMARK_LINE "Build the ALL_BUILD target.  To create an NSIS 
installer, build the PACKAGE target")
+  endif(MSVC)
+
+  set(dreport_src "
+#define _CRT_SECURE_NO_WARNINGS 1
+
+#include <time.h>
+#include <stdio.h>
+#include <string.h>
+
+void printtime(long tdiff) {
+  long d_mins, d_hrs, d_days;
+  d_days = 0; d_hrs = 0; d_mins = 0;
+  if (tdiff > 86400) { d_days = tdiff / 86400; tdiff = tdiff % 86400; }
+  if (tdiff > 3600) { d_hrs = tdiff / 3600; tdiff = tdiff % 3600; }
+  if (tdiff > 60) { d_mins = tdiff / 60; tdiff = tdiff % 60; }
+  if (d_days > 0) { if (d_days == 1) { printf(\"%ld day \", d_days); } else { 
printf(\"%ld days \", d_days); } }
+  if (d_hrs > 0) { if (d_hrs == 1) { printf(\"%ld hour \", d_hrs); } else { 
printf(\"%ld hours \", d_hrs); } }
+  if (d_mins > 0) { if (d_mins == 1) { printf(\"%ld minute \", d_mins); } else 
{ printf(\"%ld minutes \", d_mins); } }
+  if (tdiff > 0) { if (tdiff == 1) { printf(\"%ld second \", tdiff); } else { 
printf(\"%ld seconds \", tdiff); } }
+  if (tdiff == 0 && d_mins == 0 && d_hrs == 0 && d_days == 0) { printf(\"0 
seconds \"); }
+}
+
+int main(int argc, const char **argv) {
+
+  FILE *infp = NULL; time_t t = time(NULL); long stime;
+  if (argc < 3) return 1;
+  if (strncmp(argv[1], \"final\", 5) == 0) {
+    if (argc < 4) return 1;
+    printf(\"Done.\\n\\nBRL-CAD Release ${BRLCAD_VERSION}, Build 
${CONFIG_DATE}\\n\\nElapsed compilation time: \");
+    infp = fopen(argv[2], \"r\"); (void)fscanf(infp, \"%ld\", &stime); ; 
fclose(infp); printtime(((long)t) - stime);
+    printf(\"\\nElapsed time since configuration: \");
+    infp = fopen(argv[3], \"r\"); (void)fscanf(infp, \"%ld\", &stime); ; 
fclose(infp); printtime(((long)t) - stime);
+    printf(\"\\n---\\n${INSTALL_LINE}\\n${BENCHMARK_LINE}\\n\\n\");
+    return 0;
+  }
+  printf(\"%s\", argv[1]);
+  infp = fopen(argv[2], \"r\"); (void)fscanf(infp, \"%ld\", &stime); ; 
fclose(infp); printtime(((long)t) - stime);
+  printf(\"\\n\");
+  return 0;
+}
+")
+
+  # Build the code so we can run it
+  file(WRITE "${CMAKE_BINARY_DIR}/CMakeTmp/dreport.c" "${dreport_src}")
+  try_compile(dreport_build "${CMAKE_BINARY_DIR}/CMakeTmp"
+    SOURCES "${CMAKE_BINARY_DIR}/CMakeTmp/dreport.c"
+    OUTPUT_VARIABLE FREPORT_BUILD_INFO
+    COPY_FILE "${CMAKE_BINARY_DIR}/CMakeTmp/dreport")
+  if(NOT dreport_build)
+    message(FATAL_ERROR "Could not build time delta reporting utility: 
${FREPORT_BUILD_INFO}")
+  endif(NOT dreport_build)
+  file(REMOVE "${CMAKE_BINARY_DIR}/CMakeTmp/dreport.c")
+  if(COMMAND distclean)
+    distclean("${CMAKE_BINARY_DIR}/CMakeTmp/dreport")
+  endif(COMMAND distclean)
+
+endfunction(generate_timer_exes)
+
 # Local Variables:
 # tab-width: 8
 # mode: cmake

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
BRL-CAD Source Commits mailing list
brlcad-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to