From b87fbc93a64d9b5dd219396fc5c98e8779c55810 Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch
Date: Wed, 11 Sep 2024 04:55:48 +0200
Subject: Support musl libc
---
CMakeLists.txt | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
(limited to 'CMakeLists.txt')
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6afeaa4..501ea3a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -29,12 +29,6 @@ set (project_libraries ${dependencies_LIBRARIES} ${LibEV_LIBRARIES})
include_directories (${dependencies_INCLUDE_DIRS} ${LibEV_INCLUDE_DIRS})
link_directories (${dependencies_LIBRARY_DIRS})
-# -liconv may or may not be a part of libc
-find_library (iconv_LIBRARIES iconv)
-if (iconv_LIBRARIES)
- list (APPEND project_libraries ${iconv_LIBRARIES})
-endif ()
-
if ("${CMAKE_SYSTEM_NAME}" MATCHES "BSD")
# Need this for SIGWINCH in FreeBSD and OpenBSD respectively;
# our POSIX version macros make it undefined
@@ -43,6 +37,20 @@ elseif (APPLE)
add_definitions (-D_DARWIN_C_SOURCE)
endif ()
+# -liconv may or may not be a part of libc
+find_library (iconv_LIBRARIES iconv)
+if (iconv_LIBRARIES)
+ list (APPEND project_libraries ${iconv_LIBRARIES})
+endif ()
+
+include (CheckCSourceRuns)
+set (CMAKE_REQUIRED_LIBRARIES ${project_libraries})
+get_property (CMAKE_REQUIRED_INCLUDES
+ DIRECTORY "${PROJECT_SOURCE_DIR}" PROPERTY INCLUDE_DIRECTORIES)
+CHECK_C_SOURCE_RUNS ("#include