Skip to content

Commit 1949fa9

Browse files
committed
[acquire/CMakeLists.txt] Use libbsd provided strnstr if available ; [ cmake/FindLibBSD.cmake] Add search for libbsd
1 parent 6eccebe commit 1949fa9

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

acquire/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,13 @@ else ()
251251
# "${CMAKE_BINARY_DIR}/generated_checksums.c")
252252

253253
add_library("${LIBRARY_NAME}_lib" SHARED "${gen_header_files}" "${gen_source_files}")
254+
255+
find_package(LibBSD)
256+
if (LibBSD_FOUND)
257+
target_link_directories("${LIBRARY_NAME}_lib" PUBLIC "${BSD_LIBRARY}")
258+
target_compile_definitions("${LIBRARY_NAME}_lib" PUBLIC HAVE_STRNSTR=1)
259+
endif (LibBSD_FOUND)
260+
254261
message(STATUS "${LIBRARY_NAME}_lib::CMAKE_SOURCE_DIR = ${CMAKE_SOURCE_DIR}")
255262
target_include_directories(
256263
"${LIBRARY_NAME}_lib"

cmake/FindLibBSD.cmake

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Find Bsd compat lib
2+
#
3+
# Once done, this will define:
4+
#
5+
# Bsd_FOUND - system has Bsd compat
6+
# Bsd_INCLUDE_DIRS - the Bsd compat include directories
7+
# Bsd_LIBRARIES - link these to use Bsd compat
8+
#
9+
10+
include(FindPkgConfig)
11+
12+
if (BSD_INCLUDE_DIR AND BSD_LIBRARY)
13+
# Already in cache, be silent
14+
set(BSD_FIND_QUIETLY TRUE)
15+
endif ()
16+
17+
pkg_check_modules(BSD_PKGCONF libbsd)
18+
19+
find_path(BSD_INCLUDE_DIR bsd.h
20+
PATH_SUFFIX bsd
21+
PATHS ${BSD_PKGCONF_INCLUDE_DIRS}
22+
)
23+
24+
find_library(BSD_LIBRARY
25+
NAMES bsd
26+
PATHS ${BSD_PKGCONF_LIBRARY_DIRS}
27+
)
28+
29+
set(BSD_PROCESS_INCLUDES BSD_INCLUDE_DIR)
30+
set(BSD_PROCESS_LIBS BSD_LIBRARY)
31+
if (BSD_LIBRARY)
32+
set(LibBSD_FOUND 1)
33+
endif (BSD_LIBRARY)

0 commit comments

Comments
 (0)