Last active
August 18, 2016 19:20
-
-
Save nega0/c551351f93b04cbe97562e4a8b68278a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## This macro takes 2 arguments. The first, _d, is an "integer date" | |
## in the format of "YYYYmmdd". The second, _m, is a message that will | |
## be passed to message(WARNING ...) or message(FATAL_ERROR ...). A | |
## one line message is recomended. | |
## | |
## It is recomended that you provide some explanitory warning prior to | |
## calling this macro. | |
## An example follows ... | |
macro(deprecation_warning _d _m) | |
if(NOT APPLE) | |
execute_process(COMMAND "date" "+%s" "-d${_d}" | |
COMMAND tr -d \\n | |
OUTPUT_VARIABLE _hence) | |
execute_process(COMMAND "date" "-d" "@${_hence}" "+'%B %d, %Y'" | |
COMMAND tr -d \\n | |
OUTPUT_VARIABLE _fhence) | |
else() | |
execute_process(COMMAND "date" "-j" "-f" "'%Y%m%d %T'" "'${_d} 00:00:00'" "+%s" | |
COMMAND tr -d \\n | |
OUTPUT_VARIABLE _hence) | |
execute_process(COMMAND "date" "-j" "-r" "${_hence}" "+'%B %d, %Y'" | |
COMMAND tr -d \\n | |
OUTPUT_VARIABLE _fhence) | |
endif() | |
execute_process(COMMAND "date" "+%s" | |
COMMAND tr -d \\n | |
OUTPUT_VARIABLE _now) | |
if(_now LESS _hence) | |
message("***") | |
message("*** This will become a fatal error on ${_fhence}") | |
message("***") | |
message(WARNING "${_m}") | |
else() | |
message("***") | |
message(FATAL_ERROR "${_m}") | |
endif() | |
endmacro() | |
## ex. | |
## if(GCC_NUMERIC_VERSION LESS 40801) | |
## message("*** You're using a gcc version less than 4.8.1. This is no longer supported.") | |
## message("*** Upgrade your complier, or set the CC and CXX environment variables appropriately.") | |
## deprecation_warning(20160905 "Unsupported gcc version.") | |
## endif() | |
## | |
## will have the following output: | |
## | |
## *** You're using a gcc version less than 4.8.1. This is no longer supported. | |
## *** Upgrade your complier, or set the CC and CXX environment variables appropriately. | |
## *** | |
## *** This will become a fatal error on 'September 05, 2016' | |
## *** | |
## CMake Warning at CMakeLists.txt:47 (message): | |
## Unsupported gcc version. | |
## Call Stack (most recent call first): | |
## CMakeLists.txt:59 (deprecation_warning) | |
## | |
## and after the given date will have the following output | |
## | |
## *** You're using a gcc version less than 4.8.1. This is no longer supported. | |
## *** Upgrade your complier, or set the CC and CXX environment variables appropriately. | |
## *** | |
## CMake Error at CMakeLists.txt:65 (message): | |
## Unsupported gcc version. | |
## Call Stack (most recent call first): | |
## CMakeLists.txt:75 (deprecation_warning) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment