aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniil Cherednik <dan.cherednik@gmail.com>2025-05-31 16:49:58 +0200
committerDaniil Cherednik <dan.cherednik@gmail.com>2025-05-31 16:52:15 +0200
commit0c3e65863f31459c4be8a12051a8d6260cb1d307 (patch)
tree914069c21e57f2f9f7e52d2908324ccd984a7b3c
parent93f74f12ebe3770c457fe4cee41699337a6715c1 (diff)
downloadlibgha-at3pghadev.tar.gz
Fix compilation for FreeBSD and probably other OS without alloca.h.at3pghadev
-rw-r--r--CMakeLists.txt8
-rw-r--r--src/gha.c4
2 files changed, 12 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7b37dfb..2e17acb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,9 +2,13 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8...3.26)
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -fsanitize=address -fno-omit-frame-pointer")
+INCLUDE (CheckIncludeFiles)
+
project(gha)
add_library(gha src/gha.c src/sle.c)
+CHECK_INCLUDE_FILES(alloca.h HAVE_ALLOCA_H)
+
if (NOT GHA_FFT_LIB)
set(SOURCE_FFT_LIB
@@ -35,6 +39,10 @@ ELSE()
list(APPEND GHALIB m)
ENDIF()
+IF (HAVE_ALLOCA_H)
+ add_compile_definitions(LIBGHA_HAVE_ALLOCA_H)
+ENDIF()
+
if (GHA_USE_DOUBLE_API)
set_source_files_properties(
src/gha.c
diff --git a/src/gha.c b/src/gha.c
index 6b1d01f..8cb73a1 100644
--- a/src/gha.c
+++ b/src/gha.c
@@ -13,10 +13,14 @@
#else
+#ifdef LIBGHA_HAVE_ALLOCA_H
+
#include <alloca.h>
#endif
+#endif
+
/*
* Ref: http://www.apsipa.org/proceedings_2009/pdf/WA-L3-3.pdf
*/