Skip to content

Commit

Permalink
[CMake] Replace wget with FetchContent in CMake scripts. (#365)
Browse files Browse the repository at this point in the history
* [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 1be7d54.
  • Loading branch information
imorlxs authored May 24, 2024
1 parent abb79cd commit 23cd92c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 40 deletions.
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

0 comments on commit 23cd92c

Please sign in to comment.