From 23cd92c97371576f60a7403870e197e6562513b1 Mon Sep 17 00:00:00 2001 From: Isaac Morales Santana <102816007+imorlxs@users.noreply.github.com> Date: Fri, 24 May 2024 13:00:17 +0200 Subject: [PATCH] [CMake] Replace wget with FetchContent in CMake scripts. (#365) * [CMake] Replace wget with FetchContent in CMake scripts. * Remove subbuild files. * Deleted dependecies on wget and replaced with curl, which is standard in OS X * Revert "Deleted dependecies on wget and replaced with curl, which is standard in OS X" This reverts commit 1be7d54acc433d8a6feaf52c365387024b4ea779. --- CMakeLists.txt | 5 ---- cmake/UseBioDynaMo.cmake.in | 5 ---- cmake/utils.cmake | 46 +++++++++++++------------------------ 3 files changed, 16 insertions(+), 40 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 737cc26da..dc40e73d1 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -193,11 +193,6 @@ if (jemalloc) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -ljemalloc -L ${JEMALLOC_LIBRARY_DIR}") endif() -find_program(WGET_BIN wget) -if (NOT WGET_BIN) - message(FATAL_ERROR "The program wget was not found in your system. Please run ./prerequisites.sh again before calling cmake.") -endif() - if (APPLE) set(NOPYENV YES) endif() diff --git a/cmake/UseBioDynaMo.cmake.in b/cmake/UseBioDynaMo.cmake.in index 840ef6a60..e0c00aa34 100644 --- a/cmake/UseBioDynaMo.cmake.in +++ b/cmake/UseBioDynaMo.cmake.in @@ -143,11 +143,6 @@ if (jemalloc) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -ljemalloc -L ${JEMALLOC_LIBRARY_DIR}") endif() -find_program(WGET_BIN wget) -if (NOT WGET_BIN) - message(FATAL_ERROR "The program wget was not found in your system. Please run ./prerequisites.sh again before calling cmake.") -endif() - # In order to correctly compile and link the multi simulation manager with MPI, # you need to set CMAKE_[CXX|C]_COMPILER to [mpic++|mpicc] # We still however need to explicitly add the mpi.h include path to our include_directories diff --git a/cmake/utils.cmake b/cmake/utils.cmake index 9ab61f8b0..d7fc23074 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -540,37 +540,23 @@ Unset the environment variable BDM_LOCAL_LFS to download the file.") endif() else() # Download the file - if (${DETECTED_OS} MATCHES "centos.*") - execute_process(COMMAND ${WGET_BIN} --progress=bar:force - -O ${FULL_TAR_PATH} ${URL} - RESULT_VARIABLE DOWNLOAD_STATUS_CODE) - else() - execute_process(COMMAND ${WGET_BIN} -nv --show-progress --progress=bar:force:noscroll - -O ${FULL_TAR_PATH} ${URL} - RESULT_VARIABLE DOWNLOAD_STATUS_CODE) - endif() - if (NOT ${DOWNLOAD_STATUS_CODE} EQUAL 0) - message( FATAL_ERROR "\nERROR: We were unable to download:\ - ${URL}\n\ -This may be caused by several reasons, like network error connections or just \ -temporary network failure. Please retry again in a few minutes by deleting all \ -the contents of the build directory and by issuing again the 'cmake' command.\n") + include(FetchContent) + Set(FETCHCONTENT_QUIET FALSE) + FetchContent_Declare( + ${TAR_FILENAME} + URL ${URL} + URL_HASH SHA256=${HASH} + DOWNLOAD_DIR ${DEST_PARENT} + SOURCE_DIR ${DEST} + ) + + FetchContent_GetProperties(${TAR_FILENAME}) + if (NOT ${TAR_FILENAME}_POPULATED) + FetchContent_Populate(${TAR_FILENAME}) endif() - endif() - - # Verify download - file(SHA256 ${FULL_TAR_PATH} ACTUAL_SHA256) - if(NOT ACTUAL_SHA256 STREQUAL "${HASH}") - message(FATAL_ERROR "\nERROR: SHA256 sum verification failed.\n\ - Expected: ${HASH}\n\ - Actual: ${ACTUAL_SHA256}\n") - endif() - # Extract - execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf ${FULL_TAR_PATH} - WORKING_DIRECTORY ${DEST} - RESULT_VARIABLE EXTRACT_STATUS_CODE) - if (NOT ${EXTRACT_STATUS_CODE} EQUAL 0) - message(FATAL_ERROR "ERROR: Extraction of file ${FULL_TAR_PATH} to ${DEST} failed.") + + # Remove subbuild files, we don't need them + file(REMOVE_RECURSE ${CMAKE_BINARY_DIR}/_deps/) endif() file(WRITE ${DEST}/tar-sha256 "${HASH}")