Skip to content

Commit e244a91

Browse files
cosmo0920edsiper
authored andcommitted
build: wamrc: Make buildable with LLVM 15
Since LLVM 15, libedit will be linked with cmake functionality. We have to find out where libedit is installed in the building boxes. see: https://reviews.llvm.org/rG9426358ea1fa84bac7b85f550f9efce12349c9da Signed-off-by: Hiroshi Hatake <[email protected]>
1 parent e921d22 commit e244a91

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,11 @@ if (FLB_TESTS_OSSFUZZ)
348348
set(FLB_CONFIG_YAML Off)
349349
endif()
350350

351+
if (FLB_WASM)
352+
# For Linking libedit adjustments on LLVM 15.
353+
include(cmake/FindLibEdit.cmake)
354+
endif()
355+
351356
# Set Fluent Bit dependency libraries path
352357
include(cmake/libraries.cmake)
353358

cmake/FindLibEdit.cmake

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# FindLibEdit
2+
# -----------
3+
#
4+
# Find libedit library and headers
5+
#
6+
# The module defines the following variables:
7+
#
8+
# ::
9+
#
10+
# libedit_FOUND - true if libedit was found
11+
# libedit_INCLUDE_DIRS - include search path
12+
# libedit_LIBRARIES - libraries to link
13+
# libedit_VERSION - version number
14+
15+
# This cmake file is based on LLVM Project one's.
16+
#
17+
# Copyright (c) 2018-2022 LLVM Project
18+
#
19+
20+
if(libedit_INCLUDE_DIRS AND libedit_LIBRARIES)
21+
set(libedit_FOUND TRUE)
22+
else()
23+
find_package(PkgConfig QUIET)
24+
pkg_check_modules(PC_LIBEDIT QUIET libedit)
25+
26+
find_path(libedit_INCLUDE_DIRS
27+
NAMES
28+
histedit.h
29+
HINTS
30+
${PC_LIBEDIT_INCLUDEDIR}
31+
${PC_LIBEDIT_INCLUDE_DIRS}
32+
${CMAKE_INSTALL_FULL_INCLUDEDIR})
33+
find_library(libedit_LIBRARIES
34+
NAMES
35+
edit libedit
36+
HINTS
37+
${PC_LIBEDIT_LIBDIR}
38+
${PC_LIBEDIT_LIBRARY_DIRS}
39+
${CMAKE_INSTALL_FULL_LIBDIR})
40+
41+
if(libedit_INCLUDE_DIRS AND EXISTS "${libedit_INCLUDE_DIRS}/histedit.h")
42+
file(STRINGS "${libedit_INCLUDE_DIRS}/histedit.h"
43+
libedit_major_version_str
44+
REGEX "^#define[ \t]+LIBEDIT_MAJOR[ \t]+[0-9]+")
45+
string(REGEX REPLACE "^#define[ \t]+LIBEDIT_MAJOR[ \t]+([0-9]+)" "\\1"
46+
LIBEDIT_MAJOR_VERSION "${libedit_major_version_str}")
47+
48+
file(STRINGS "${libedit_INCLUDE_DIRS}/histedit.h"
49+
libedit_minor_version_str
50+
REGEX "^#define[ \t]+LIBEDIT_MINOR[ \t]+[0-9]+")
51+
string(REGEX REPLACE "^#define[ \t]+LIBEDIT_MINOR[ \t]+([0-9]+)" "\\1"
52+
LIBEDIT_MINOR_VERSION "${libedit_minor_version_str}")
53+
54+
set(libedit_VERSION_STRING "${libedit_major_version}.${libedit_minor_version}")
55+
endif()
56+
57+
include(FindPackageHandleStandardArgs)
58+
find_package_handle_standard_args(LibEdit
59+
REQUIRED_VARS
60+
libedit_INCLUDE_DIRS
61+
libedit_LIBRARIES
62+
VERSION_VAR
63+
libedit_VERSION_STRING)
64+
mark_as_advanced(libedit_INCLUDE_DIRS libedit_LIBRARIES)
65+
endif()
66+
67+
if (libedit_INCLUDE_DIRS AND libedit_LIBRARIES AND NOT TARGET LibEdit::LibEdit)
68+
add_library(LibEdit::LibEdit UNKNOWN IMPORTED)
69+
set_target_properties(LibEdit::LibEdit PROPERTIES
70+
IMPORTED_LOCATION ${libedit_LIBRARIES}
71+
INTERFACE_INCLUDE_DIRECTORIES ${libedit_INCLUDE_DIRS})
72+
endif()

0 commit comments

Comments
 (0)