Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CMake] Replace wget with FetchContent in CMake scripts. #365

Merged
merged 4 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 0 additions & 5 deletions cmake/UseBioDynaMo.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
46 changes: 16 additions & 30 deletions cmake/utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
Loading