]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Fix musl build by using fts_* from external library
authorBart Ribbers <bribbers@disroot.org>
Wed, 9 Aug 2023 12:07:46 +0000 (14:07 +0200)
committerMéven Car <meven.car@kdemail.net>
Fri, 11 Aug 2023 08:45:13 +0000 (08:45 +0000)
musl does not support fts. There is however a standalone package that
can be used, but it must be linked against. This commit adds a check
that makes sure to link to the external library if it is required.

CMakeLists.txt
src/CMakeLists.txt

index 8a0b97c6350af317215f730d0bce89bf89aed3a8..0a655babb3769527aff2b662869fb3f38d1b1bf0 100644 (file)
@@ -27,6 +27,8 @@ include(GenerateExportHeader)
 include(FeatureSummary)
 include(ECMQtDeclareLoggingCategory)
 include(ECMDeprecationSettings)
+include(CheckIncludeFiles)
+include(CheckLibraryExists)
 
 ecm_setup_version(${RELEASE_SERVICE_VERSION} VARIABLE_PREFIX DOLPHIN
                   VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/src/dolphin_version.h"
@@ -150,6 +152,21 @@ else()
     set(HAVE_TERMINAL TRUE)
 endif()
 
+# Compatibility with platforms without native fts (e.g. musl)
+check_include_files("sys/types.h;sys/stat.h;fts.h" HAVE_FTS_H)
+if(HAVE_FTS_H)
+    check_function_exists(fts_open HAVE_FTS_OPEN)
+    if(NOT HAVE_FTS_OPEN)
+        check_library_exists(fts fts_open "" HAVE_LIB_FTS)
+    endif()
+endif()
+
+if(HAVE_LIB_FTS)
+    set(FTS_LIB fts)
+else()
+    set(FTS_LIB "")
+endif()
+
 add_subdirectory(src)
 add_subdirectory(doc)
 
index 5a481e39ff4b4e89ff3f87ebb3f1c4f74bffd0b6..fa7de5cc23c79abde02363fa1a0f3054fc6db72d 100644 (file)
@@ -213,6 +213,8 @@ target_link_libraries(
     KF6::KCMUtils
 
     KF6::MoreTools
+
+    ${FTS_LIB}
 )
 
 if(HAVE_BALOO)