Skip to content

Commit e606f52

Browse files
committed
[build] Check for unicode functions in libedit
Some versions of libedit may have histedit.h but not the Unicode functions. Explicitly check for the Unicode functions in the found libedit to ensure the check is accurate. I considered making this a component of the LibEdit package in our find module, but CMake's documentation [1] says "Packages that find multiple semi-independent parts (like bundles of libraries) should search for the components...", and the "multiple semi-independent parts" definitely isn't the case here; we're just interested in determining if the found library supports a particular feature. [1] https://cmake.org/cmake/help/v3.16/manual/cmake-developer.7.html#find-modules
1 parent c584ebd commit e606f52

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,19 @@ else()
930930
find_package(LibEdit)
931931
endif()
932932

933+
if(LibEdit_FOUND)
934+
cmake_push_check_state()
935+
list(APPEND CMAKE_REQUIRED_INCLUDES ${LibEdit_INCLUDE_DIRS})
936+
list(APPEND CMAKE_REQUIRED_LIBRARIES ${LibEdit_LIBRARIES})
937+
check_symbol_exists(el_wgets "histedit.h" HAVE_EL_WGETS)
938+
if(HAVE_EL_WGETS)
939+
set(LibEdit_HAS_UNICODE YES)
940+
else()
941+
set(LibEdit_HAS_UNICODE NO)
942+
endif()
943+
cmake_pop_check_state()
944+
endif()
945+
933946
check_symbol_exists(wait4 "sys/wait.h" HAVE_WAIT4)
934947

935948
check_symbol_exists(proc_pid_rusage "libproc.h" HAVE_PROC_PID_RUSAGE)

lib/Immediate/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ target_link_libraries(swiftImmediate PRIVATE
1212
swiftIRGen
1313
swiftSILGen
1414
swiftSILOptimizer)
15-
if(LibEdit_FOUND)
15+
if(LibEdit_FOUND AND LibEdit_HAS_UNICODE)
1616
target_compile_definitions(swiftImmediate PRIVATE
1717
HAVE_LIBEDIT)
1818
target_link_libraries(swiftImmediate PRIVATE

tools/SourceKit/tools/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ include_directories(
66

77
add_swift_lib_subdirectory(sourcekitd)
88
add_swift_tool_subdirectory(sourcekitd-test)
9-
if(LibEdit_FOUND)
9+
if(LibEdit_FOUND AND LibEdit_HAS_UNICODE)
1010
add_swift_tool_subdirectory(sourcekitd-repl)
1111
endif()
1212
add_swift_tool_subdirectory(complete-test)

0 commit comments

Comments
 (0)