[Povray] Work around build failure due to target OS macros changes.
https://github.com/llvm/llvm-project/pull/74676 changes some predefined
target OS macros on Apple platforms, which breaks building both Blender
and Povray.
Work around build failures by adding -fno-define-target-os-macros if
available.
(Workaround has already been applied to SPEC2017's version of Povray in
9b14a92d585657b87f2ca2b135ba9044685393be)
diff --git a/External/Povray/CMakeLists.txt b/External/Povray/CMakeLists.txt
index 9c4014a..b57ade8 100644
--- a/External/Povray/CMakeLists.txt
+++ b/External/Povray/CMakeLists.txt
@@ -12,6 +12,19 @@
${TEST_SUITE_POVRAY_ROOT}/source/libpng/example.c
)
+if(APPLE)
+ # Building Povray breaks with -fdefine-target-os-macros, add flag to disable
+ # it as workaround.
+ include(CheckCCompilerFlag)
+ check_c_compiler_flag(-fno-define-target-os-macros
+ COMPILER_HAS_NO_DEFINE_TARGET_OS_MACROS)
+ if (COMPILER_HAS_NO_DEFINE_TARGET_OS_MACROS)
+ list(APPEND CPPFLAGS
+ -fno-define-target-os-macros
+ )
+ endif()
+endif()
+
list(APPEND CPPFLAGS
-I${TEST_SUITE_POVRAY_ROOT}/source
-I${TEST_SUITE_POVRAY_ROOT}/source/unix
diff --git a/External/SPEC/CFP2006/453.povray/CMakeLists.txt b/External/SPEC/CFP2006/453.povray/CMakeLists.txt
index a5a9d3d..26e7440 100644
--- a/External/SPEC/CFP2006/453.povray/CMakeLists.txt
+++ b/External/SPEC/CFP2006/453.povray/CMakeLists.txt
@@ -9,6 +9,17 @@
list(APPEND CXXFLAGS -ffp-contract=off)
endif()
+if(APPLE)
+ # Building Povray breaks with -fdefine-target-os-macros, add flag to disable
+ # it as workaround.
+ include(CheckCCompilerFlag)
+ check_c_compiler_flag(-fno-define-target-os-macros
+ COMPILER_HAS_NO_DEFINE_TARGET_OS_MACROS)
+ if (COMPILER_HAS_NO_DEFINE_TARGET_OS_MACROS)
+ add_compile_options(-fno-define-target-os-macros)
+ endif()
+endif()
+
macro(test_input run_type stdout_reltol)
llvm_test_run(RUN_TYPE ${run_type}
WORKDIR %S/data/${run_type}/input