Revision: 77346
http://sourceforge.net/p/brlcad/code/77346
Author: starseeker
Date: 2020-10-06 18:33:20 +0000 (Tue, 06 Oct 2020)
Log Message:
-----------
CMake version required is new enough now... significant simplification of the
timing code used by BRL-CAD's CMake build system.
Modified Paths:
--------------
brlcad/branches/thirdparty_rework/CMakeLists.txt
brlcad/branches/thirdparty_rework/misc/CMake/BRLCAD_Util.cmake
Added Paths:
-----------
brlcad/branches/thirdparty_rework/misc/CMake/scripts/printtime.cmake
brlcad/branches/thirdparty_rework/misc/CMake/scripts/timestamp.cmake
Modified: brlcad/branches/thirdparty_rework/CMakeLists.txt
===================================================================
--- brlcad/branches/thirdparty_rework/CMakeLists.txt 2020-10-06 17:24:56 UTC
(rev 77345)
+++ brlcad/branches/thirdparty_rework/CMakeLists.txt 2020-10-06 18:33:20 UTC
(rev 77346)
@@ -81,14 +81,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")
#---------------------------------------------------------------------
# Options controlling user level features. These may impact which
@@ -2236,18 +2236,14 @@
# *******************************************************************
# *** 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.
-if (NOT DEFINED SUBBUILD)
+# Set up rules to print a timestamp string during build
+if(NOT BRLCAD_IS_SUBBUILD)
- # 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}"
+ COMMAND "${CMAKE_COMMAND}" -DSTAMP_FILE="${BUILD_DELTA_START}" -P
"${BRLCAD_CMAKE_DIR}/scripts/timestamp.cmake"
COMMENT ""
)
add_custom_target(timestamp ALL
@@ -2260,12 +2256,46 @@
COMMAND ${CMAKE_COMMAND} -E remove ${BUILD_DELTA_START}
)
set_target_properties(buildtimedelta PROPERTIES FOLDER "Compilation
Utilities")
-endif (NOT DEFINED SUBBUILD)
-# In a superbuild configuration, we're primarily concerned with
-# ExternalProject_Add targets.
-if (NOT DEFINED SUBBUILD)
+ # We want the timestamp to come first, so make ALL targets, depend on
+ # timestamp. Similarly, buildtimedelta needs to depend on every target
+ # not excluded from the default build list.
+ # Libraries and executables are fairly straightforward
+ get_property(CMAKE_LIBRARY_TARGET_LIST GLOBAL PROPERTY
CMAKE_LIBRARY_TARGET_LIST)
+ get_property(CMAKE_EXEC_TARGET_LIST GLOBAL PROPERTY CMAKE_EXEC_TARGET_LIST)
+ mark_as_advanced(CMAKE_LIBRARY_TARGET_LIST)
+ mark_as_advanced(CMAKE_EXEC_TARGET_LIST)
+ list(REMOVE_DUPLICATES CMAKE_LIBRARY_TARGET_LIST)
+ list(REMOVE_DUPLICATES CMAKE_EXEC_TARGET_LIST)
+ foreach(ctarget ${CMAKE_LIBRARY_TARGET_LIST} ${CMAKE_EXEC_TARGET_LIST})
+ if(TARGET ${ctarget})
+ add_dependencies(${ctarget} timestamp)
+ get_target_property(not_in_all ${ctarget} EXCLUDE_FROM_ALL)
+ get_target_property(not_in_default ${ctarget} EXCLUDE_FROM_DEFAULT_BUILD)
+ if(NOT not_in_all AND NOT not_in_default)
+ add_dependencies(buildtimedelta ${ctarget})
+ endif(NOT not_in_all AND NOT not_in_default)
+ endif(TARGET ${ctarget})
+ endforeach(ctarget ${CMAKE_LIBRARY_TARGET_LIST} ${CMAKE_EXEC_TARGET_LIST})
+
+ # For the custom targets, we need to avoid circular dependencies
+ get_property(CMAKE_CUSTOM_TARGET_LIST GLOBAL PROPERTY
CMAKE_CUSTOM_TARGET_LIST)
+ mark_as_advanced(CMAKE_CUSTOM_TARGET_LIST)
+ list(REMOVE_DUPLICATES CMAKE_CUSTOM_TARGET_LIST)
+ foreach(custtarget ${CMAKE_CUSTOM_TARGET_LIST})
+ if(NOT ${custtarget} MATCHES "timestamp")
+ add_dependencies(${custtarget} timestamp)
+ endif(NOT ${custtarget} MATCHES "timestamp")
+ if(NOT ${custtarget} MATCHES "buildtimedelta")
+ get_target_property(not_in_all ${custtarget} EXCLUDE_FROM_ALL)
+ get_target_property(not_in_default ${custtarget}
EXCLUDE_FROM_DEFAULT_BUILD)
+ if(NOT not_in_all AND NOT not_in_default)
+ add_dependencies(buildtimedelta ${custtarget})
+ endif(NOT not_in_all AND NOT not_in_default)
+ endif(NOT ${custtarget} MATCHES "buildtimedelta")
+ endforeach(custtarget ${CMAKE_CUSTOM_TARGET_LIST})
+
# Theoretical logic to handle external targets - not currently in use
get_property(CMAKE_EXTERNAL_TARGET_LIST GLOBAL PROPERTY
CMAKE_EXTERNAL_TARGET_LIST)
mark_as_advanced(CMAKE_EXTERNAL_TARGET_LIST)
@@ -2280,11 +2310,9 @@
endif(target_confcmd)
endforeach(externaltarget ${CMAKE_EXTERNAL_TARGET_LIST})
-endif (NOT DEFINED SUBBUILD)
+endif(NOT BRLCAD_IS_SUBBUILD)
-# TODO - the below logic will have to be rethought in a superbuild setup...
-
# To set correct install paths for CMake at build time, rather than CMake
# time, some rather special logic is necessary - a build target that needs
# to be run when the current build type changes, and introspective scripting
Modified: brlcad/branches/thirdparty_rework/misc/CMake/BRLCAD_Util.cmake
===================================================================
--- brlcad/branches/thirdparty_rework/misc/CMake/BRLCAD_Util.cmake
2020-10-06 17:24:56 UTC (rev 77345)
+++ brlcad/branches/thirdparty_rework/misc/CMake/BRLCAD_Util.cmake
2020-10-06 18:33:20 UTC (rev 77346)
@@ -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)
#########################################################################
Added: brlcad/branches/thirdparty_rework/misc/CMake/scripts/printtime.cmake
===================================================================
--- brlcad/branches/thirdparty_rework/misc/CMake/scripts/printtime.cmake
(rev 0)
+++ brlcad/branches/thirdparty_rework/misc/CMake/scripts/printtime.cmake
2020-10-06 18:33:20 UTC (rev 77346)
@@ -0,0 +1,3 @@
+string(TIMESTAMP CTIME "%a %b %d %H:%M:%S %Y")
+message("\n${MSG} ${CTIME}")
+
Property changes on:
brlcad/branches/thirdparty_rework/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/branches/thirdparty_rework/misc/CMake/scripts/timestamp.cmake
===================================================================
--- brlcad/branches/thirdparty_rework/misc/CMake/scripts/timestamp.cmake
(rev 0)
+++ brlcad/branches/thirdparty_rework/misc/CMake/scripts/timestamp.cmake
2020-10-06 18:33:20 UTC (rev 77346)
@@ -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/branches/thirdparty_rework/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