Skip to content

Commit f2c4b71

Browse files
author
Mauricio
committed
build: add cmake
1 parent adb3722 commit f2c4b71

File tree

4 files changed

+196
-0
lines changed

4 files changed

+196
-0
lines changed

CMakeLists.txt

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
cmake_minimum_required(VERSION 3.20)
2+
project(ltfs,
3+
VERSION 2.5.0.0
4+
)
5+
include(CheckSymbolExists REQUIRED)
6+
include(CheckTypeSize REQUIRED)
7+
include(CheckLibraryExists REQUIRED)
8+
include(CheckIncludeFiles REQUIRED)
9+
include(GNUInstallDirs REQUIRED)
10+
11+
find_package(PkgConfig REQUIRED)
12+
find_package(Threads REQUIRED)
13+
find_package(ICU COMPONENTS uc)
14+
15+
# pkg_check_modules(DL REQUIRED "libdl" IMPORTED_TARGET)
16+
pkg_check_modules(FUSE REQUIRED "fuse>=2.6.0" IMPORTED_TARGET)
17+
target_compile_definitions(PkgConfig::FUSE INTERFACE _FILE_OFFSET_BITS=64)
18+
19+
pkg_check_modules(XML2 REQUIRED "libxml-2.0>=2.6.16" IMPORTED_TARGET)
20+
21+
if(APPLE)
22+
pkg_check_modules(UUID REQUIRED "uuid>=1.6" IMPORTED_TARGET)
23+
else()
24+
pkg_check_modules(UUID REQUIRED "uuid>=1.36" IMPORTED_TARGET)
25+
endif()
26+
27+
add_subdirectory(messages)
28+
add_subdirectory(src/libltfs)
29+
add_subdirectory(src)
30+
31+
32+
# Parsing features options
33+
# NOTE: Is this needed? cmake can add this feature using -DUSE_UNORM2
34+
# option(ICU_6X "Force to use ICU6x (unorm2) functions" OFF)
35+
# if(ICU_6X)
36+
# add_definitions(-DUSE_UNORM2)
37+
# endif()
38+
39+
# option(SNMP "Force to use ICU6x (unorm2) functions" OFF)
40+
if(ENABLE_SNMP)
41+
pkg_check_modules(SNMP REQUIRED "net-snmp>=5.3" IMPORTED_TARGET)
42+
endif()
43+
44+
# # Check libraries exists
45+
# check_library_exists(pthread pthread_create "" HAVE_PTHREAD)
46+
# if(APPLE)
47+
# check_library_exists(rt clock_gettime "" HAVE_RT)
48+
# endif()
49+
50+
# if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
51+
# check_library_exists(cam cam_open_device "" HAVE_CAM)
52+
# check_library_exists(bsdxml XML_ParserCreate "" HAVE_BSDXML)
53+
# check_library_exists(mt mt_status_free "" HAVE_MT)
54+
# check_library_exists(execinfo backtrace "" HAVE_EXECINFO)
55+
# elseif(CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
56+
# check_library_exists(execinfo backtrace "" HAVE_EXECINFO)
57+
# endif()
58+
59+
# # Compilation requirements
60+
# # NOTE: Checking for standard headers is really needed?
61+
# set(
62+
# STD_HEADERS
63+
# "fcntl.h"
64+
# "limits.h"
65+
# "stddef.h"
66+
# "stdint.h"
67+
# "stdlib.h"
68+
# "stdbool.h"
69+
# "string.h"
70+
# "sys/ioctl.h"
71+
# "sys/mount.h"
72+
# "sys/time.h"
73+
# "termios.h"
74+
# "unistd.h"
75+
# "sys/sysctl.h"
76+
# )
77+
# check_include_files("${STD_HEADERS}" HAVE_STD_HEADERS)
78+
# check_type_size(mode_t MODE_T)
79+
# check_type_size(off_t OFF_T)
80+
# check_type_size(size_t SIZE_T)
81+
# check_type_size(ssize_t SSIZE_T)
82+
# check_type_size(time_t TIME_T)
83+
# check_type_size(uint8_t UINT8_T)
84+
# check_type_size(uint16_t UINT16_T)
85+
# check_type_size(uint32_t UINT32_T)
86+
# check_type_size(uint64_t UINT64_T)
87+
# check_type_size(uint64_t UINT64_T)
88+
# check_symbol_exists(malloc "stdlib.h" HAVE_MALLOC)
89+
# check_symbol_exists(strlen "string.h" HAVE_STRLEN)
90+
# check_symbol_exists(bzero "string.h" HAVE_BZERO)
91+
# check_symbol_exists(memchr "string.h" HAVE_MEMCHR)
92+
# check_symbol_exists(memset "string.h" HAVE_MEMSET)
93+
# check_symbol_exists(strcasecmp "string.h" HAVE_STRCASECMP)
94+
# check_symbol_exists(strdup "string.h" HAVE_STRDUP)
95+
# check_symbol_exists(strerror "string.h" HAVE_STRERROR)
96+
# check_symbol_exists(strndup "string.h" HAVE_STRNDUP)
97+
# check_symbol_exists(strrchr "string.h" HAVE_STRRCHR)
98+
# check_symbol_exists(strstr "string.h" HAVE_STRSTR)
99+
# check_symbol_exists(mkdir "sys/stat.h" HAVE_MKDIR)
100+
# check_symbol_exists(rmdir "unistd.h" HAVE_RMDIR)
101+
102+
103+
# check_library_exists(xml2 xmlTextReaderSetup "" HAVE_XML_TEXT_READER_SETUP)
104+
# if(HAVE_XML_TEXT_READER_SETUP)
105+
# # TODO: Add add macro definitions
106+
# endif()
107+
108+
# # check_symbol_exists(xmlTextReaderSetup "" HAVE_XML_TEXT_READER_SETUP)

messages/CMakeLists.txt

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# file(GLOB _MESSAGES_LIBS RELATIVE "." "*/")
2+
set(MESSAGES_LIBS
3+
bin_ltfs
4+
bin_ltfsck
5+
bin_ltfsindextool
6+
bin_mkltfs
7+
internal_error
8+
iosched_fcfs
9+
iosched_unified
10+
kmi_flatfile
11+
kmi_simple
12+
libltfs
13+
tape_common
14+
tape_freebsd_cam
15+
tape_generic_file
16+
tape_generic_itdtimg
17+
tape_iokit
18+
tape_linux_lin_tape
19+
tape_linux_sg
20+
)
21+
22+
foreach(NAME IN LISTS MESSAGES_LIBS)
23+
file(GLOB SRCS "${NAME}/*.txt")
24+
25+
add_custom_command(
26+
OUTPUT "res_${NAME}/lib${NAME}.a"
27+
# ALL
28+
COMMAND mkdir -p res_${NAME}
29+
COMMAND ${ICU_GENRB_EXECUTABLE} -q ${SRCS} -d res_${NAME} 1> /dev/null
30+
COMMAND find res_${NAME} -name *.res > res_${NAME}/paths.txt
31+
COMMAND ${ICU_PKGDATA_EXECUTABLE} -d res_${NAME}/ -m static -p ${NAME} -q res_${NAME}/paths.txt 1> /dev/null
32+
BYPRODUCTS "res_${NAME}"
33+
# SOURCES
34+
)
35+
add_custom_target("${NAME}.a" ALL
36+
cp res_${NAME}/lib${NAME}.a lib${NAME}.a
37+
DEPENDS "res_${NAME}/lib${NAME}.a"
38+
BYPRODUCTS lib${NAME}.a
39+
)
40+
41+
add_library("lib${NAME}" STATIC IMPORTED GLOBAL)
42+
set_target_properties("lib${NAME}" PROPERTIES IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/lib${NAME}.a")
43+
endforeach()

src/CMakeLists.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Define the project targets
2+
add_executable(ltfs main.c ltfs_fuse.c)
3+
target_link_libraries(ltfs
4+
Threads::Threads
5+
PkgConfig::FUSE
6+
PkgConfig::XML2
7+
PkgConfig::UUID
8+
ICU::uc
9+
libltfs
10+
)
11+
target_include_directories(ltfs BEFORE PUBLIC "." )
12+
target_compile_definitions(ltfs PRIVATE
13+
_GNU_SOURCE
14+
LTFS_CONFIG_FILE="${SYSCONFDIR}/ltfs.conf"
15+
LTFS_BASE_DIR="${CMAKE_INSTALL_PREFIX}"
16+
PACKAGE_VERSION="${PROJECT_VERSION}"
17+
PACKAGE_NAME="${PROJECT_NAME}"
18+
)

src/libltfs/CMakeLists.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
cmake_minimum_required(VERSION 3.20)
2+
project(libltfs,
3+
VERSION 2.5.0.0
4+
)
5+
6+
file(GLOB_RECURSE LIBLTFS_SRCS LIST_DIRECTORIES false "*.c")
7+
add_library(libltfs SHARED ${LIBLTFS_SRCS})
8+
target_include_directories(libltfs BEFORE PUBLIC ".." )
9+
10+
target_link_libraries(libltfs
11+
Threads::Threads
12+
PkgConfig::FUSE
13+
PkgConfig::XML2
14+
PkgConfig::UUID
15+
libbin_ltfs
16+
liblibltfs
17+
libinternal_error
18+
libtape_common
19+
)
20+
21+
target_compile_definitions(libltfs PRIVATE
22+
_GNU_SOURCE
23+
LTFS_CONFIG_FILE="${SYSCONFDIR}/ltfs.conf"
24+
LTFS_BASE_DIR="${CMAKE_INSTALL_PREFIX}"
25+
PACKAGE_VERSION="${PROJECT_VERSION}"
26+
PACKAGE_NAME="${PROJECT_NAME}"
27+
)

0 commit comments

Comments
 (0)