From 224c3199aacee73bc592133e04a93edaa9dd177f Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Wed, 9 Aug 2023 14:34:17 +0200
Subject: [PATCH] CONFIG: enable xcrun with cc/c++ based on WM_COMPILE_CONTROL
 (#2965)

- adding in +xcrun into WM_COMPILE_CONTROL changes the compiler
  settings as follows (for MacOS)

      cc         := xcrun cc
      CC         := xcrun c++ -std=c++14
---
 etc/bashrc                    | 1 +
 etc/cshrc                     | 1 +
 wmake/rules/darwin64Clang/c   | 4 ++++
 wmake/rules/darwin64Clang/c++ | 4 ++++
 4 files changed, 10 insertions(+)

diff --git a/etc/bashrc b/etc/bashrc
index 2e157923b74..e4cb5fb72d3 100644
--- a/etc/bashrc
+++ b/etc/bashrc
@@ -91,6 +91,7 @@ export WM_COMPILE_OPTION=Opt
 #   +openmp : with openmp
 #   ~openmp : without openmp
 #   +ccache : use ccache
+#   +xcrun  : use xcrun and native compilers [MacOS]
 #   ccache=... : ccache command (unquoted, single/double or <> quoted)
 #   version=... : compiler suffix (eg, "11" for gcc-11)
 #export WM_COMPILE_CONTROL="+gold"
diff --git a/etc/cshrc b/etc/cshrc
index 5a42602f505..19f58497460 100644
--- a/etc/cshrc
+++ b/etc/cshrc
@@ -91,6 +91,7 @@ setenv WM_COMPILE_OPTION Opt
 #   +openmp : with openmp
 #   ~openmp : without openmp
 #   +ccache : use ccache
+#   +xcrun  : use xcrun and native compilers [MacOS]
 #   ccache=... : ccache command (unquoted, single/double or <> quoted)
 #   version=... : compiler suffix (eg, "11" for gcc-11)
 #setenv WM_COMPILE_CONTROL "+gold"
diff --git a/wmake/rules/darwin64Clang/c b/wmake/rules/darwin64Clang/c
index d145bd5b927..3083b281ede 100644
--- a/wmake/rules/darwin64Clang/c
+++ b/wmake/rules/darwin64Clang/c
@@ -1,6 +1,10 @@
 #------------------------------------------------------------------------------
 include $(GENERAL_RULES)/Clang/c
 
+ifneq (,$(findstring +xcrun,$(WM_COMPILE_CONTROL)))
+cc         := xcrun cc
+endif
+
 cARCH      := -m64 -ftrapping-math
 
 ifneq (,$(strip $(WM_COMPILE_OPTION)))
diff --git a/wmake/rules/darwin64Clang/c++ b/wmake/rules/darwin64Clang/c++
index a9e092144ad..01158bcb0f5 100644
--- a/wmake/rules/darwin64Clang/c++
+++ b/wmake/rules/darwin64Clang/c++
@@ -1,6 +1,10 @@
 #------------------------------------------------------------------------------
 include $(GENERAL_RULES)/Clang/c++
 
+ifneq (,$(findstring +xcrun,$(WM_COMPILE_CONTROL)))
+CC         := xcrun c++ -std=c++14
+endif
+
 c++ARCH    := -m64 -pthread -ftrapping-math
 
 ifneq (,$(strip $(WM_COMPILE_OPTION)))
-- 
GitLab