Permalink
Browse files

CMAKEgit s

  • Loading branch information...
gonsie committed Dec 19, 2018
1 parent ff7f060 commit bdca084dd37d44c70b7c27006ff7c108c9fe0131
@@ -0,0 +1,77 @@
PROJECT(MFU)

CMAKE_MINIMUM_REQUIRED(VERSION 3.1)
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)

# Configuration Options

OPTION(ENABLE_XATTRS "Enable code for extended attributes" ON)
IF(ENABLE_XATTRS)
ADD_DEFINITIONS(-DDCOPY_USE_XATTRS)
ENDIF(ENABLE_XATTRS)

OPTION(ENABLE_LUSTRE "Enable optimization and features for Lustre" OFF)
IF(ENABLE_LUSTRE)
ADD_DEFINITIONS(-DLUSTRE_SUPPORT)
# todo investigate usage of other lustre #defs
# - LUSTRE_STAT
# - HAVE_LUSTRE_LUSTREAPI_H
# - HAVE_LUSTRE_LUSTRE_USER_H
ENDIF(ENABLE_LUSTRE)

OPTION(ENABLE_EXPERIMENTAL "Build experimental tools" OFF)

# Dependencies

LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")

## MPI
INCLUDE(SetupMPI)
IF(MPI_C_FOUND)
INCLUDE_DIRECTORIES(${MPI_C_INCLUDE_PATH})
LIST(APPEND MFU_EXTERNAL_LIBS ${MPI_C_LIBRARIES})
ENDIF(MPI_C_FOUND)

## DTCMP
FIND_PACKAGE(DTCMP REQUIRED)
IF(DTCMP_FOUND)
INCLUDE_DIRECTORIES(${DTCMP_INCLUDE_DIRS})
LIST(APPEND MFU_EXTERNAL_LIBS ${DTCMP_LIBRARIES})
ENDIF(DTCMP_FOUND)

## LIBARCHIVE
# TODO how would we pass a version from spack?
FIND_PACKAGE(LibArchive REQUIRED)
IF(LibArchive_FOUND)
INCLUDE_DIRECTORIES(${LibArchive_INCLUDE_DIRS})
LIST(APPEND MFU_EXTERNAL_LIBS ${LibArchive_LIBRARIES})
ENDIF(LibArchive_FOUND)

## LIBCIRCLE
FIND_PACKAGE(LibCircle REQUIRED)
IF(LibCircle_FOUND)
INCLUDE_DIRECTORIES(${LibCircle_INCLUDE_DIRS})
LIST(APPEND MFU_EXTERNAL_LIBS ${LibCircle_LIBRARIES})
ENDIF(LibCircle_FOUND)

## OPENSSL for ddup
FIND_PACKAGE(OpenSSL)

# Setup Installation

INCLUDE(GNUInstallDirs)
SET(X_BINDIR ${CMAKE_INSTALL_FULL_BINDIR} CACHE INTERNAL "bin")
SET(X_DATADIR ${CMAKE_INSTALL_FULL_DATADIR} CACHE INTERNAL "share")
SET(X_INCLUDEDIR ${CMAKE_INSTALL_FULL_INCLUDEDIR} CACHE INTERNAL "include")
SET(X_LIBDIR ${CMAKE_INSTALL_FULL_LIBDIR} CACHE INTERNAL "lib")

# Subdirectories
INCLUDE(MFU_ADD_TOOL)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src/common)

ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(test)

IF(ENABLE_EXPERIMENTAL)
ADD_SUBDIRECTORY(experimental)
ENDIF(ENABLE_EXPERIMENTAL)
@@ -0,0 +1,31 @@
# - Try to find libdtcmp
# Once done this will define
# DTCMP_FOUND - System has libdtcmp
# DTCMP_INCLUDE_DIRS - The libdtcmp include directories
# DTCMP_LIBRARIES - The libraries needed to use libdtcmp

FIND_PATH(WITH_DTCMP_PREFIX
NAMES include/dtcmp.h
)

FIND_LIBRARY(DTCMP_LIBRARIES
NAMES dtcmp
HINTS ${WITH_DTCMP_PREFIX}/lib
)

FIND_PATH(DTCMP_INCLUDE_DIRS
NAMES dtcmp.h
HINTS ${WITH_DTCMP_PREFIX}/include
)

INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(DTCMP DEFAULT_MSG
DTCMP_LIBRARIES
DTCMP_INCLUDE_DIRS
)

# Hide these vars from ccmake GUI
MARK_AS_ADVANCED(
DTCMP_LIBRARIES
DTCMP_INCLUDE_DIRS
)
@@ -0,0 +1,31 @@
# - Try to find libdtcmp
# Once done this will define
# LibCircle_FOUND - System has libdtcmp
# LibCircle_INCLUDE_DIRS - The libdtcmp include directories
# LibCircle_LIBRARIES - The libraries needed to use libdtcmp

FIND_PATH(WITH_LibCircle_PREFIX
NAMES include/libcircle.h
)

FIND_LIBRARY(LibCircle_LIBRARIES
NAMES circle
HINTS ${WITH_LibCircle_PREFIX}/lib
)

FIND_PATH(LibCircle_INCLUDE_DIRS
NAMES libcircle.h
HINTS ${WITH_LibCircle_PREFIX}/include
)

INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibCircle DEFAULT_MSG
LibCircle_LIBRARIES
LibCircle_INCLUDE_DIRS
)

# Hide these vars from ccmake GUI
MARK_AS_ADVANCED(
LibCircle_LIBRARIES
LibCircle_INCLUDE_DIRS
)
@@ -0,0 +1,8 @@
FUNCTION(MFU_ADD_TOOL name)

ADD_EXECUTABLE(${name} ${name}.c)
TARGET_LINK_LIBRARIES(${name} mfu)
SET_TARGET_PROPERTIES(${name} PROPERTIES C_STANDARD 99)
INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${name} DESTINATION ${CMAKE_INSTALL_BINDIR})

ENDFUNCTION(MFU_ADD_TOOL name)
@@ -0,0 +1,77 @@
###############################################################################
# Copyright (c) 2017, Lawrence Livermore National Security, LLC.
#
# Produced at the Lawrence Livermore National Laboratory
#
# LLNL-CODE-725085
#
# All rights reserved.
#
# This file is part of BLT.
#
# For additional details, please also read BLT/LICENSE.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the disclaimer below.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the disclaimer (as noted below) in the
# documentation and/or other materials provided with the distribution.
#
# * Neither the name of the LLNS/LLNL nor the names of its contributors may
# be used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY,
# LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
###############################################################################

################################
# MPI
################################

find_package(MPI)
message(STATUS "MPI C Compile Flags: ${MPI_C_COMPILE_FLAGS}")
message(STATUS "MPI C Include Path: ${MPI_C_INCLUDE_PATH}")
message(STATUS "MPI C Link Flags: ${MPI_C_LINK_FLAGS}")
message(STATUS "MPI C Libraries: ${MPI_C_LIBRARIES}")

message(STATUS "MPI CXX Compile Flags: ${MPI_CXX_COMPILE_FLAGS}")
message(STATUS "MPI CXX Include Path: ${MPI_CXX_INCLUDE_PATH}")
message(STATUS "MPI CXX Link Flags: ${MPI_CXX_LINK_FLAGS}")
message(STATUS "MPI CXX Libraries: ${MPI_CXX_LIBRARIES}")

message(STATUS "MPI Executable: ${MPIEXEC}")
message(STATUS "MPI Num Proc Flag: ${MPIEXEC_NUMPROC_FLAG}")


if (ENABLE_FORTRAN)
# Determine if we should use fortran mpif.h header or fortran mpi module
find_path(mpif_path
NAMES "mpif.h"
PATHS ${MPI_Fortran_INCLUDE_PATH}
NO_DEFAULT_PATH
)

if(mpif_path)
set(MPI_Fortran_USE_MPIF ON CACHE PATH "")
message(STATUS "Using MPI Fortran header: mpif.h")
else()
set(MPI_Fortran_USE_MPIF OFF CACHE PATH "")
message(STATUS "Using MPI Fortran module: mpi.mod")
endif()
endif()
@@ -0,0 +1,4 @@
ADD_SUBDIRECTORY(dgrep)
ADD_SUBDIRECTORY(dparallel)
ADD_SUBDIRECTORY(dsh)
ADD_SUBDIRECTORY(dtar)
@@ -0,0 +1 @@
MFU_ADD_TOOL(dgrep)
@@ -0,0 +1 @@
MFU_ADD_TOOL(dparallel)
@@ -0,0 +1 @@
MFU_ADD_TOOL(dsh)
@@ -0,0 +1,7 @@
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})

# MFU_ADD_TOOL(dtar)
ADD_EXECUTABLE(dtar dtar.c mfu_flist_archive.c)
TARGET_LINK_LIBRARIES(dtar mfu)
SET_TARGET_PROPERTIES(dtar PROPERTIES C_STANDARD 99)
INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/dtar DESTINATION ${CMAKE_INSTALL_BINDIR})
@@ -0,0 +1,18 @@
# Common library
ADD_SUBDIRECTORY(common)

# tools
ADD_SUBDIRECTORY(dbcast)
ADD_SUBDIRECTORY(dbz2)
ADD_SUBDIRECTORY(dchmod)
ADD_SUBDIRECTORY(dcmp)
ADD_SUBDIRECTORY(dcp)
ADD_SUBDIRECTORY(dcp1)
ADD_SUBDIRECTORY(ddup)
ADD_SUBDIRECTORY(dfilemaker)
ADD_SUBDIRECTORY(dfilemaker1)
ADD_SUBDIRECTORY(dfind)
ADD_SUBDIRECTORY(drm)
ADD_SUBDIRECTORY(dstripe)
ADD_SUBDIRECTORY(dsync)
ADD_SUBDIRECTORY(dwalk)
@@ -1,9 +1,48 @@
cmake_minimum_required(VERSION 2.8)
project(fileutils_common)
# todo re-asses if all of these must be *installed*
LIST(APPEND libmfu_install_headers
mfu.h
mfu_bz2.h
mfu_flist.h
mfu_flist_internal.h
mfu_io.h
mfu_param_path.h
mfu_path.h
mfu_pred.h
mfu_util.h
)
INSTALL(FILES ${libmfu_install_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

file(GLOB common_h_files *.h)
file(GLOB common_c_files *.c)
list(APPEND common_src_files ${common_h_files} ${common_c_files})
# common library
LIST(APPEND libmfu_srcs
mfu_compress_bz2_libcircle.c
mfu_decompress_bz2_libcircle.c
mfu_flist.c
mfu_flist_chunk.c
mfu_flist_copy.c
mfu_flist_io.c
mfu_flist_chmod.c
mfu_flist_create.c
mfu_flist_remove.c
mfu_flist_sort.c
mfu_flist_usrgrp.c
mfu_flist_walk.c
mfu_io.c
mfu_param_path.c
mfu_path.c
mfu_pred.c
mfu_util.c
strmap.c
)

add_library(mfu ${common_src_files})
target_link_libraries(mfu ${MPI_LIBRARIES} dtcmp )
ADD_LIBRARY(mfu_o OBJECT ${libmfu_srcs})
SET_TARGET_PROPERTIES(mfu_o PROPERTIES C_STANDARD 99)

ADD_LIBRARY(mfu SHARED $<TARGET_OBJECTS:mfu_o>)
TARGET_LINK_LIBRARIES(mfu ${MFU_EXTERNAL_LIBS})
SET_TARGET_PROPERTIES(mfu PROPERTIES OUTPUT_NAME mfu CLEAN_DIRECT_OUTPUT 1)
INSTALL(TARGETS mfu DESTINATION ${CMAKE_INSTALL_LIBDIR})

ADD_LIBRARY(mfu-static STATIC $<TARGET_OBJECTS:mfu_o>)
TARGET_LINK_LIBRARIES(mfu-static ${MFU_EXTERNAL_LIBS})
SET_TARGET_PROPERTIES(mfu-static PROPERTIES OUTPUT_NAME mfu CLEAN_DIRECT_OUTPUT 1)
INSTALL(TARGETS mfu-static DESTINATION ${CMAKE_INSTALL_LIBDIR})
@@ -0,0 +1 @@
MFU_ADD_TOOL(dbcast)
@@ -0,0 +1 @@
MFU_ADD_TOOL(dbz2)
@@ -0,0 +1 @@
MFU_ADD_TOOL(dchmod)
@@ -0,0 +1 @@
MFU_ADD_TOOL(dcmp)
@@ -0,0 +1 @@
MFU_ADD_TOOL(dcp)
@@ -0,0 +1,18 @@
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})

# MFU_ADD_TOOL(dcp1)

LIST(APPEND dcp1_srcs
dcp1.c
cleanup.c
common.c
compare.c
copy.c
handle_args.c
treewalk.c
)

ADD_EXECUTABLE(dcp1 ${dcp1_srcs})
TARGET_LINK_LIBRARIES(dcp1 mfu)
SET_TARGET_PROPERTIES(dcp1 PROPERTIES C_STANDARD 99)
INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/dcp1 DESTINATION ${CMAKE_INSTALL_BINDIR})
@@ -0,0 +1,2 @@
MFU_ADD_TOOL(ddup)
TARGET_LINK_LIBRARIES(ddup ${OPENSSL_LIBRARIES})
@@ -0,0 +1 @@
MFU_ADD_TOOL(dfilemaker)
@@ -0,0 +1 @@
MFU_ADD_TOOL(dfilemaker1)
@@ -0,0 +1 @@
MFU_ADD_TOOL(dfind)
@@ -0,0 +1 @@
MFU_ADD_TOOL(drm)
@@ -0,0 +1 @@
MFU_ADD_TOOL(dstripe)
@@ -0,0 +1 @@
MFU_ADD_TOOL(dsync)
@@ -0,0 +1 @@
MFU_ADD_TOOL(dwalk)
No changes.

0 comments on commit bdca084

Please sign in to comment.