Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorlistout <listout@protonmail.com>2022-08-18 01:04:56 +0300
committerCampbell Barton <campbell@blender.org>2022-08-18 01:12:56 +0300
commitf197b1a1f1bbc0334310fb1c911327246767a1a3 (patch)
treebf4b282fe4db30f6a66b532728ae2b69e03ca824 /source
parent0a84cc691d7945624ff83256ba083d35f80c3191 (diff)
CMake: support building with musl libc
Instead of using macros like GLIBC we can use the CMake build systems internal functions to check if some header or functions are present on the running system's libc. Add ./build_files/cmake/have_features.cmake to add checks for platform features which can be used to set defines for source files that require them. Reviewed By: campbellbarton Ref D15696
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenlib/CMakeLists.txt4
-rw-r--r--source/blender/blenlib/intern/system.c10
-rw-r--r--source/blender/makesdna/intern/CMakeLists.txt5
-rw-r--r--source/blender/makesrna/intern/CMakeLists.txt5
-rw-r--r--source/creator/CMakeLists.txt4
-rw-r--r--source/creator/creator_signals.c2
6 files changed, 25 insertions, 5 deletions
diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt
index d39a586206f..78455c44fe1 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -1,6 +1,10 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright 2006 Blender Foundation. All rights reserved.
+if(HAVE_EXECINFO_H)
+ add_definitions(-DHAVE_EXECINFO_H)
+endif()
+
set(INC
.
# ../blenkernel # don't add this back!
diff --git a/source/blender/blenlib/intern/system.c b/source/blender/blenlib/intern/system.c
index 35e26e0cb33..781b38f713a 100644
--- a/source/blender/blenlib/intern/system.c
+++ b/source/blender/blenlib/intern/system.c
@@ -21,7 +21,9 @@
# include "BLI_winstuff.h"
#else
-# include <execinfo.h>
+# if defined(HAVE_EXECINFO_H)
+# include <execinfo.h>
+# endif
# include <unistd.h>
#endif
@@ -61,9 +63,9 @@ int BLI_cpu_support_sse2(void)
#if !defined(_MSC_VER)
void BLI_system_backtrace(FILE *fp)
{
- /* ------------- */
- /* Linux / Apple */
-# if defined(__linux__) || defined(__APPLE__)
+ /* ----------------------- */
+ /* If system as execinfo.h */
+# if defined(HAVE_EXECINFO_H)
# define SIZE 100
void *buffer[SIZE];
diff --git a/source/blender/makesdna/intern/CMakeLists.txt b/source/blender/makesdna/intern/CMakeLists.txt
index c26696b4572..97198117a83 100644
--- a/source/blender/makesdna/intern/CMakeLists.txt
+++ b/source/blender/makesdna/intern/CMakeLists.txt
@@ -5,6 +5,11 @@
add_definitions(-DWITH_DNA_GHASH)
+# Needed for `mallocn.c`.
+if(HAVE_MALLOC_STATS_H)
+ add_definitions(-DHAVE_MALLOC_STATS_H)
+endif()
+
blender_include_dirs(
../../../../intern/atomic
../../../../intern/guardedalloc
diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt
index b0fb86c8bc3..7e6e3bcf90e 100644
--- a/source/blender/makesrna/intern/CMakeLists.txt
+++ b/source/blender/makesrna/intern/CMakeLists.txt
@@ -6,6 +6,11 @@ if(CMAKE_COMPILER_IS_GNUCC)
string(APPEND CMAKE_C_FLAGS " -Werror=implicit-function-declaration")
endif()
+# Needed for `mallocn.c`.
+if(HAVE_MALLOC_STATS_H)
+ add_definitions(-DHAVE_MALLOC_STATS_H)
+endif()
+
# files rna_access.c rna_define.c makesrna.c intentionally excluded.
set(DEFSRC
rna_ID.c
diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt
index becba393a36..5b01280c1c2 100644
--- a/source/creator/CMakeLists.txt
+++ b/source/creator/CMakeLists.txt
@@ -21,6 +21,10 @@ set(LIB
bf_windowmanager
)
+if(HAVE_FEENABLEEXCEPT)
+ add_definitions(-DHAVE_FEENABLEEXCEPT)
+endif()
+
if(WITH_TBB)
# Force TBB libraries to be in front of MKL (part of OpenImageDenoise), so
# that it is initialized before MKL and static library initialization order
diff --git a/source/creator/creator_signals.c b/source/creator/creator_signals.c
index 226277da363..65352f047f1 100644
--- a/source/creator/creator_signals.c
+++ b/source/creator/creator_signals.c
@@ -256,7 +256,7 @@ void main_signal_setup_fpe(void)
* set breakpoints on sig_handle_fpe */
signal(SIGFPE, sig_handle_fpe);
-# if defined(__linux__) && defined(__GNUC__)
+# if defined(__linux__) && defined(__GNUC__) && defined(HAVE_FEENABLEEXCEPT)
feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
# endif /* defined(__linux__) && defined(__GNUC__) */
# if defined(OSX_SSE_FPE)