From e77cb5b008afcd0456b4cac323cfd8b71e41d46b Mon Sep 17 00:00:00 2001 From: Tobias Schmidl Date: Thu, 4 May 2023 09:59:47 +0200 Subject: [PATCH] feature: added CPM download status This is very useful in shaky network solutions. We want both a success and a failure message, to determine if the download was successful. --- cmake/CPM.cmake | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cmake/CPM.cmake b/cmake/CPM.cmake index 0913400..0ac7637 100644 --- a/cmake/CPM.cmake +++ b/cmake/CPM.cmake @@ -15,8 +15,15 @@ function(download_cpm) message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}") file(DOWNLOAD https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake - ${CPM_DOWNLOAD_LOCATION} + ${CPM_DOWNLOAD_LOCATION} STATUS CPM_DOWNLOAD_STATUS ) + list(GET CPM_DOWNLOAD_STATUS 0 CPM_DOWNLOAD_STATUS_CODE) + list(GET CPM_DOWNLOAD_STATUS 1 CPM_DOWNLOAD_ERROR_MESSAGE) + if(${CPM_DOWNLOAD_STATUS_CODE} EQUAL 0) + message(STATUS "CPM: Download completed successfully.") + else() + message(FATAL_ERROR "CPM: Error occurred during download: ${CPM_DOWNLOAD_ERROR_MESSAGE}") + endif() endfunction() if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))