Skip to content

Commit

Permalink
libarchive: conditional compile
Browse files Browse the repository at this point in the history
Not all systems have a libarchive-3.5* package available
through yum, apt-get, dnf, etc.

To avoid the need to build libarchive from source when it
is not needed, add the optional cmake flag ENABLE_LIBARCHIVE.
By default, this is turned on.
When turned off, mfu will not link against libarchive, nor will
it build dtar, which requires libarchive.

Signed-off-by: Dalton Bohning <daltonx.bohning@intel.com>
Co-authored-by: Adam Moody <moody20@llnl.gov>
  • Loading branch information
2 people authored and daltonbohning committed Jan 22, 2021
1 parent f56cbf3 commit 82b8cf1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,17 @@ INCLUDE_DIRECTORIES(${DTCMP_INCLUDE_DIRS})
LIST(APPEND MFU_EXTERNAL_LIBS ${DTCMP_LIBRARIES})

## LIBARCHIVE
OPTION(ENABLE_LIBARCHIVE "Enable usage of libarchive and corresponding tools" ON)
# TODO how would we pass a version from spack?
# libarchive 3.1.2 is available on some systems,
# but pick a newer libarchive to avoid bug with files starting with "._",
# which is misinterpretted as a MacOS extension on Linuxlibarchive 3.1.2
FIND_PACKAGE(LibArchive 3.5.1 REQUIRED)
INCLUDE_DIRECTORIES(${LibArchive_INCLUDE_DIRS})
LIST(APPEND MFU_EXTERNAL_LIBS ${LibArchive_LIBRARIES})
IF(ENABLE_LIBARCHIVE)
FIND_PACKAGE(LibArchive 3.5.1 REQUIRED)
INCLUDE_DIRECTORIES(${LibArchive_INCLUDE_DIRS})
LIST(APPEND MFU_EXTERNAL_LIBS ${LibArchive_LIBRARIES})
ADD_DEFINITIONS(-DLIBARCHIVE_SUPPORT)
ENDIF(ENABLE_LIBARCHIVE)

OPTION(ENABLE_DAOS "Enable DAOS support")
IF(ENABLE_DAOS)
Expand Down
6 changes: 6 additions & 0 deletions doc/rst/build.rst
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ To enable Lustre, GPFS, and experimental tools, add the following flags during C
-DENABLE_GPFS=ON
-DENABLE_EXPERIMENTAL=ON
To disable linking against libarchive, and tools requiring libarchive, add the following flag during CMake:

.. code-block:: Bash
-DENABLE_LIBARCHIVE=OFF
--------------------------------------------------------------
Build mpiFileUtils directly, build its dependencies with Spack
--------------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@ IF(ENABLE_EXPERIMENTAL)
ADD_SUBDIRECTORY(dgrep)
ADD_SUBDIRECTORY(dparallel)
ADD_SUBDIRECTORY(dsh)
ADD_SUBDIRECTORY(dtar)
IF(ENABLE_LIBARCHIVE)
ADD_SUBDIRECTORY(dtar)
ENDIF(ENABLE_LIBARCHIVE)
ENDIF(ENABLE_EXPERIMENTAL)
8 changes: 6 additions & 2 deletions src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ LIST(APPEND libmfu_srcs
mfu_compress_bz2_libcircle.c
mfu_decompress_bz2_libcircle.c
mfu_flist.c
mfu_flist_archive.c
mfu_flist_chunk.c
mfu_flist_copy.c
mfu_flist_io.c
Expand All @@ -51,7 +50,12 @@ LIST(APPEND libmfu_srcs
mfu_util.c
strmap.c
)
if(ENABLE_DAOS)
IF(ENABLE_LIBARCHIVE)
LIST(APPEND libmfu_srcs
mfu_flist_archive.c
)
ENDIF(ENABLE_LIBARCHIVE)
IF(ENABLE_DAOS)
LIST(APPEND libmfu_srcs
mfu_daos.c
)
Expand Down

0 comments on commit 82b8cf1

Please sign in to comment.