As part of our project we generate a CMake file with these contents:
# -----------------------------------------------------------------------
cmake_policy(SET CMP0012 NEW)
cmake_policy(SET CMP0054 NEW)
# --------------------------------------------------------------------------------------------------
# STARTING 6_5_test_data_1.tar.gz
# Download, Decompress, and possibly copy data archive
# message(STATUS "[DATA DOWNLOAD] 6_5_test_data_1.tar.gz")
# --------------------------------------------------------------------------------------------------
string(TIMESTAMP time_stamp_start %s)
file(DOWNLOAD https://github.com/bluequartzsoftware/simplnx/releases/download/Data_Archive/6_5_test_data_1.tar.gz
"/Users/mjackson/Workspace1/DREAM3DNX/../DREAM3D_Data/TestFiles/6_5_test_data_1.tar.gz"
EXPECTED_HASH SHA512=6e21118a882c6a0cc54341eec8928b89ee84ac3a41b1d5b534193f4fabcb49c363db22028055622ad777787be0163cf5525e6c548c11c2c369748feb23031651
# SHOW_PROGRESS
STATUS result
)
string(TIMESTAMP time_stamp_end %s)
list(GET result 1 status)
string(REPLACE "\"" "" status "${status}")
if("${status}" STREQUAL "No error")
math(EXPR time_diff "${time_stamp_end} - ${time_stamp_start}" OUTPUT_FORMAT DECIMAL) # value is set to "1000"
file(SIZE "/Users/mjackson/Workspace1/DREAM3DNX/../DREAM3D_Data/TestFiles/6_5_test_data_1.tar.gz" file_size)
if(NOT "${time_diff}" STREQUAL "0")
math(EXPR bandwidth "${file_size} / ${time_diff}" OUTPUT_FORMAT DECIMAL) # value is set to "1000"
message(STATUS "6_5_test_data_1.tar.gz Download Complete: ${bandwidth} bytes/sec")
else()
message(STATUS "6_5_test_data_1.tar.gz Download Complete")
endif()
endif()
which is basically repeated for about 50 other files. The issue is that when there is an error we get the following output during the build:
CMake Error at simplnx_fetch_remote_files.cmake:149 (file):
file DOWNLOAD cannot compute hash on failed download
status: [28;"Timeout was reached"]
which is sort of helpful. Obviously, I can go into the file and look at that line number and then get which file was the issue. But if this is on a CI machine, I don’t have the luxury. Is there any way to entice the “FILE” command to give a more detailed error message? We are on CMake 3.26.x currently.
Looking at the docs for the “FILE(DOWNLOAD…)” command I see a “LOG” option… except that I can’t even print what gets stored in that variable because CMake errors out before the next line of code is executed (Which would be my message(STATUS “”) line).
I guess I could use “SHOW_PROGRESS” but that is going to get awful messy with that number of files.
I could also do at message(STATUS "Download Started"..)
but this is also starting to print a lot of output when it isn’t needed in most cases.
What I’m asking is how to get CMake to print an error like:
CMake Error at simplnx_fetch_remote_files.cmake:149 (file):
file DOWNLOAD cannot compute hash on failed download
URL: https://github.com/bluequartzsoftware/simplnx/releases/download/Data_Archive/6_5_test_data_1.tar.gz
Result: time out
Thoughts?