Skip to content

Commit b6b2a83

Browse files
committed
fix: fix compilation issues
1 parent d2ab0b6 commit b6b2a83

File tree

4 files changed

+33
-43
lines changed

4 files changed

+33
-43
lines changed

.cmake/FindSNMP.cmake

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# TODO: Improve the use of SNMP, right now this flags are not added to the build.
2+
# TODO: Test the use of SNMP
3+
option(ENABLE_SNMP "Force to use ICU6x (unorm2) functions" OFF)
4+
if(ENABLE_SNMP)
5+
pkg_check_modules(SNMP REQUIRED "net-snmp>=5.3" IMPORTED_TARGET)
6+
find_program(NETSNMP_CONFIG_BIN net-snmp-config REQUIRED)
7+
if(NETSNMP_CONFIG_BIN)
8+
exec_program(${NETSNMP_CONFIG_BIN} ARGS --cflags OUTPUT_VARIABLE _NETSNMP_CFLAGS)
9+
exec_program(${NETSNMP_CONFIG_BIN} ARGS --libs OUTPUT_VARIABLE _NETSNMP_LIBS)
10+
11+
string(REGEX REPLACE "[\"\r\n]" " " _NETSNMP_CFLAGS "${_NETSNMP_CFLAGS}")
12+
string(REGEX REPLACE "[\"\r\n]" " " _NETSNMP_LIBS "${_NETSNMP_LIBS}")
13+
set(NETSNMP_CFLAGS ${_NETSNMP_CFLAGS} CACHE STRING "CFLAGS for net-snmp lib")
14+
set(NETSNMP_LIBS ${_NETSNMP_LIBS} CACHE STRING "linker options for net-snmp lib")
15+
set(NETSNMP_FOUND TRUE CACHE BOOL "net-snmp is found")
16+
else()
17+
set (NETSNMP_FOUND FALSE CACHE BOOL "net-snmp is not found")
18+
endif()
19+
endif()

CMakeLists.txt

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
cmake_minimum_required(VERSION 3.20)
2-
project(ltfs,
3-
# TODO: Find a better solution to mark this version as different from the official build
4-
VERSION "2.5.0.9999"
5-
)
1+
cmake_minimum_required(VERSION 3.26)
2+
project(ltfs
3+
LANGUAGES C)
4+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/.cmake")
5+
66
include(CheckSymbolExists REQUIRED)
77
include(CheckTypeSize REQUIRED)
88
include(CheckLibraryExists REQUIRED)
99
include(CheckIncludeFiles REQUIRED)
1010
include(GNUInstallDirs REQUIRED)
1111

12+
find_package(SNMP REQUIRED)
1213
find_package(PkgConfig REQUIRED)
1314
find_package(Threads REQUIRED)
1415
find_package(ICU COMPONENTS uc)
1516
find_package(LibXml2 REQUIRED)
1617

18+
check_type_size(time_t SIZEOF_TIME_T)
1719
add_compile_definitions(_GNU_SOURCE __CMAKE_BUILD)
1820

1921
pkg_check_modules(FUSE REQUIRED "fuse>=2.6.0" IMPORTED_TARGET)
@@ -29,29 +31,3 @@ endif()
2931

3032
add_subdirectory(messages)
3133
add_subdirectory(src)
32-
33-
# TODO: Improve the use of SNMP, right now this flags are not added to the build.
34-
# TODO: Test the use of SNMP
35-
option(ENABLE_SNMP "Force to use ICU6x (unorm2) functions" OFF)
36-
if(ENABLE_SNMP)
37-
pkg_check_modules(SNMP REQUIRED "net-snmp>=5.3" IMPORTED_TARGET)
38-
find_program(NETSNMP_CONFIG_BIN net-snmp-config REQUIRED)
39-
if(NETSNMP_CONFIG_BIN)
40-
exec_program(${NETSNMP_CONFIG_BIN} ARGS --cflags OUTPUT_VARIABLE _NETSNMP_CFLAGS)
41-
exec_program(${NETSNMP_CONFIG_BIN} ARGS --libs OUTPUT_VARIABLE _NETSNMP_LIBS)
42-
43-
string(REGEX REPLACE "[\"\r\n]" " " _NETSNMP_CFLAGS "${_NETSNMP_CFLAGS}")
44-
string(REGEX REPLACE "[\"\r\n]" " " _NETSNMP_LIBS "${_NETSNMP_LIBS}")
45-
set(NETSNMP_CFLAGS ${_NETSNMP_CFLAGS} CACHE STRING "CFLAGS for net-snmp lib")
46-
set(NETSNMP_LIBS ${_NETSNMP_LIBS} CACHE STRING "linker options for net-snmp lib")
47-
set(NETSNMP_FOUND TRUE CACHE BOOL "net-snmp is found")
48-
else()
49-
set (NETSNMP_FOUND FALSE CACHE BOOL "net-snmp is not found")
50-
endif()
51-
endif()
52-
53-
54-
check_type_size(time_t SIZEOF_TIME_T)
55-
add_compile_definitions(
56-
SIZEOF_TIME_T=${SIZEOF_TIME_T}
57-
)

build/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore

messages/CMakeLists.txt

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,13 @@ set(MESSAGES_LIBS
2121
foreach(NAME IN LISTS MESSAGES_LIBS)
2222
file(GLOB SRCS "${NAME}/*.txt")
2323

24-
# Compile the message resources using genrb and pkgdata see make_message_src.sh
25-
add_custom_command(
26-
OUTPUT "res_${NAME}/lib${NAME}.a"
27-
COMMAND mkdir -p res_${NAME}
28-
COMMAND ${ICU_GENRB_EXECUTABLE} -q ${SRCS} -d res_${NAME} 1> /dev/null
29-
COMMAND find res_${NAME} -name *.res > res_${NAME}/paths.txt
30-
COMMAND ${ICU_PKGDATA_EXECUTABLE} -d res_${NAME}/ -m static -p ${NAME} -q res_${NAME}/paths.txt 1> /dev/null
31-
BYPRODUCTS "res_${NAME}"
32-
)
3324
# Add the command as a target to be build when all is invoked
3425
add_custom_target("${NAME}.a" ALL
35-
cp res_${NAME}/lib${NAME}.a lib${NAME}.a
36-
DEPENDS "res_${NAME}/lib${NAME}.a"
37-
BYPRODUCTS lib${NAME}.a
26+
${ICU_GENRB_EXECUTABLE} -q ${SRCS} 1> /dev/null
27+
COMMAND ls *.res > paths.txt
28+
COMMAND ${ICU_PKGDATA_EXECUTABLE} -m static -p ${NAME} -q paths.txt 1> /dev/null
29+
COMMAND cp lib${NAME}.a ..
30+
WORKING_DIRECTORY res_${NAME}
3831
)
3932

4033
# Define the library as an imported CMake lib

0 commit comments

Comments
 (0)