freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2] GSoC-2020-greg 3f82a10: Greg Williamson 2020 GsoC Pproject t


From: Greg Williamson
Subject: [freetype2] GSoC-2020-greg 3f82a10: Greg Williamson 2020 GsoC Pproject to add continous integration
Date: Sun, 30 Aug 2020 13:00:04 -0400 (EDT)

branch: GSoC-2020-greg
commit 3f82a109c0f16458b05110beeb2ad443ba0274bd
Author: Greg Williamson <gwill6@uis.edu>
Commit: Greg Williamson <gwill6@uis.edu>

    Greg Williamson 2020 GsoC Pproject to add continous integration
---
 CI/Readme.md           |  30 ++
 CI/arch-setup.yml      |  21 ++
 CI/build-autotools.yml |  86 +++++
 CI/build-cmake.yml     |  59 ++++
 CI/build.yml           |  23 ++
 CI/ft-regression.sh    |  98 ++++++
 CI/ft-report.sh        | 177 ++++++++++
 CI/ft-test-font.sh     |  94 +++++
 CI/ft-test.sh          | 124 +++++++
 CI/ft-tests.config     |  35 ++
 CI/mingw-setup.yml     |  24 ++
 CI/regression-test.yml |  39 +++
 azure-pipelines.yml    | 232 +++++++++++++
 builds/cmake/iOS.cmake | 916 ++++++++++++++++++++++++++++++++++++-------------
 14 files changed, 1728 insertions(+), 230 deletions(-)

diff --git a/CI/Readme.md b/CI/Readme.md
new file mode 100644
index 0000000..81372fd
--- /dev/null
+++ b/CI/Readme.md
@@ -0,0 +1,30 @@
+# Freetype2 CI
+ 
+Continuous integration is a tool used in software development to ensure that 
your application and/or library builds and runs correctly. Continuous 
deployment takes this a step further and uses the builds from the CI to create 
releases for developers and other users to download and use. In this folder are 
several configuration files and scripts drafted by Greg Williamson for a 2020 
GSoC project: https://summerofcode.withgoogle.com/projects/#5724074732421120
+ 
+# How it works
+ 
+Upon each commit, several builds are triggered for various operating systems 
and build configurations. Each build status is then reported back to the 
developers in the Pull Request comment section on GitLab or GitHub. Each build 
creates artifacts containing the newly-built FreeType libraries for developers 
and users to download. There are also special pipeline phases called 
"Regression Tests" that run FreeType's built-in demo programs to compare visual 
outputs between commits. An HTML re [...]
+ 
+# Running locally
+ 
+All of the "Regression Tests" can be run locally (Currently only on 
Linux-based platforms). You will need to have xvfb, imagemagick, and prettydiff 
installed. You can find more details about this in CI/ft-regression.sh. You 
will also need "Liberation Fonts" which can be found here: 
https://releases.pagure.org/liberation-fonts/. The current tests expect the 
.ttf files to be extracted to ${HOME}/test-fonts. Once set up, you can run all 
tests by running ./CI/ft-regression.sh <TEST_INDEX>, w [...]
+ 
+# Adding / Changing Tests
+ 
+All regular build tests are listed and configured in azure-pipelines.yml and 
the several templates it includes in the CI/ folder. If you wish to add an 
additional platform or build configuration, azure-pipelines.yml is the place to 
do so. For "Regression Tests", there exists a configuration file at 
CI/ft-tests.config that contains an array where you can add, remove or change 
test configurations. Each line in the array is a separate test. In order to 
have Azure run new tests, you will als [...]
+ 
+```yaml
+  strategy:
+    matrix:
+      Test1:
+        TEST: 0
+      Test2:
+        TEST: 1
+      Test3:
+        TEST: 2
+```
+ 
+# Todo
+ 
+Savannah doesn't allow for integration with any modern CI so this cannot be 
implemented directly until FreeType moves to GitLab or GitHub. GitHub makes 
integrating this as simple as a few mouse clicks. For the GitLab route, 
however, we may need to port my yaml configurations to their CI's format. 
Another alternative is mirroring the repo. GitLab does have some mirroring 
capabilities, but for Savannah, developers would need to upload their commits 
to both manually.
diff --git a/CI/arch-setup.yml b/CI/arch-setup.yml
new file mode 100644
index 0000000..afa4285
--- /dev/null
+++ b/CI/arch-setup.yml
@@ -0,0 +1,21 @@
+steps:
+  - bash: |
+      set -e
+      cd $(Build.BinariesDirectory)
+      ARCH_URL=`curl -s https://mirrors.acm.wpi.edu/archlinux/iso/latest/ | 
egrep -o 'archlinux-bootstrap-([0-9._]+)-x86_64.tar.gz' | head -n1`
+      echo https://mirrors.acm.wpi.edu/archlinux/iso/latest/$ARCH_URL
+      curl https://mirrors.acm.wpi.edu/archlinux/iso/latest/$ARCH_URL -o 
arch.tar.gz
+      sudo tar xzf arch.tar.gz
+      sudo mount --bind ./root.x86_64/ ./root.x86_64/
+      sudo cp -R $(Agent.BuildDirectory)/freetype2 ./root.x86_64/
+      sudo mkdir -p ./root.x86_64/$(Build.BinariesDirectory)
+      sudo mount --bind $(Build.BinariesDirectory) 
./root.x86_64/$(Build.BinariesDirectory)
+      cat << EOF | sudo ./root.x86_64/bin/arch-chroot ./root.x86_64/
+      set -e
+      echo 'Server = https://mirrors.kernel.org/archlinux/\$repo/os/\$arch' >> 
/etc/pacman.d/mirrorlist
+      pacman-key --init 
+      pacman-key --populate archlinux
+      pacman -Syu --noconfirm base base-devel git gcc cmake harfbuzz zlib 
libpng xorg-server-xvfb imagemagick npm xorg-xwd
+      npm install -g pretty-diff
+      EOF
+    displayName: 'Bootstrap Archlinux'
diff --git a/CI/build-autotools.yml b/CI/build-autotools.yml
new file mode 100644
index 0000000..90d1131
--- /dev/null
+++ b/CI/build-autotools.yml
@@ -0,0 +1,86 @@
+# This is a template for building and publishing freetype2 build artifacts 
using autotools
+parameters:
+- name: buildArgs # Configure flags
+  default: ''
+- name: mingw     # Mingw requires special enviormental setup
+  type: boolean
+  default: false
+- name: preCMD    # Command(s) executed before calling configure
+  default: ''
+- name: srcDIR    # Location of freetype2 sources
+  default: '.'
+- name: postCMD   # Command(s) executed after calling make
+  default: ''
+
+steps:
+- ${{ if eq(parameters.mingw, true) }}:
+  - script: |
+      set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem
+      cd $(Build.SourcesDirectory)
+      %CD:~0,2%\msys64\usr\bin\bash -lc "./autogen.sh && ./configure"
+    displayName: 'Configure'
+    env:
+      MSYSTEM: $(MINGW_UPPER)
+      CHERE_INVOKING: yes
+      MINGW_INSTALLS: $(MINGW_LOWER)
+      
+  - script: |
+      set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem
+      %CD:~0,2%\msys64\usr\bin\bash -lc "make && make install DESTDIR=$(echo 
\"$(Build.BinariesDirectory)/install\" | tr '\\' '/')"
+      %CD:~0,2%\msys64\usr\bin\bash -lc "cp -R ${{ parameters.srcDIR }} $(echo 
\"$(Build.BinariesDirectory)/freetype2\" | tr '\\' '/')"
+    displayName: 'Build and Package'
+    env:
+      MSYSTEM: $(MINGW_UPPER)
+      CHERE_INVOKING: yes
+      MINGW_INSTALLS: $(MINGW_LOWER)
+
+  # Building Demos in mingw seems broken do to configuration error of it 
including termios.h in ttdebug.c which doesn't exist in mingw
+  #- script: |
+  #    set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem
+  #    %CD:~0,2%\msys64\usr\bin\bash -lc "cd $(echo 
\"$(Build.BinariesDirectory)\" | tr '\\' '/') && git clone 
git://git.sv.nongnu.org/freetype/freetype2-demos.git && cd freetype2-demos && 
make && mv bin/ $(echo \"$(Build.BinariesDirectory)/install/demos\" | tr '\\' 
'/')"
+  #  displayName: 'Build Demos'
+  #  env:
+  #    MSYSTEM: $(MINGW_UPPER)
+  #    CHERE_INVOKING: yes
+  #    MINGW_INSTALLS: $(MINGW_LOWER)
+  
+  - script: |
+      set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem"
+      %CD:~0,2%\msys64\usr\bin\bash -lc "zip -r $(echo 
\"$(Build.ArtifactStagingDirectory)/freetype-build.zip\" | tr '\\' '/') $(echo 
\"$(Build.BinariesDirectory)/install\" | tr '\\' '/')"
+    displayName: 'Stage Artifacts'
+
+- ${{ if eq(parameters.mingw, false) }}:
+  - script: |
+      ${{ parameters.preCMD }}
+      cd ${{ parameters.srcDIR }}
+      ./autogen.sh
+      ./configure ${{ parameters.buildArgs }}
+      ${{ parameters.postCMD }}
+    displayName: 'Configure'
+    
+  - script: |
+      ${{ parameters.preCMD }}
+      cd ${{ parameters.srcDIR }}
+      make 
+      make install DESTDIR=$(Build.BinariesDirectory)/install
+      ${{ parameters.postCMD }}
+    displayName: 'Build and Install'
+    
+  - script: |
+      cd ${{ parameters.srcDIR }}
+      git clone git://git.sv.nongnu.org/freetype/freetype2-demos.git
+      cd freetype2-demos
+      ln -s ${{ parameters.srcDIR }} ../freetype2
+      make
+      mv bin/ $(Build.BinariesDirectory)/install/demos
+    displayName: 'Build Demos'
+
+  - script: |
+      zip -r $(Build.ArtifactStagingDirectory)/freetype-build.zip 
$(Build.BinariesDirectory)/install
+    displayName: 'Stage Artifacts'
+
+- task: PublishBuildArtifacts@1
+  displayName: 'Push Build Artifacts'
+  inputs:
+    pathtoPublish: $(Build.ArtifactStagingDirectory)
+    artifactName: $(Agent.JobName)
diff --git a/CI/build-cmake.yml b/CI/build-cmake.yml
new file mode 100644
index 0000000..001a479
--- /dev/null
+++ b/CI/build-cmake.yml
@@ -0,0 +1,59 @@
+# This is a template for building and publishing freetype2 build artifacts 
using CMake
+
+parameters:
+- name: buildArgs # CMake configure flags
+  default: ''
+- name: mingw     # Mingw requires special enviormental setup
+  type: boolean
+  default: false
+- name: preCMD    # Command(s) executed before calling CMake 
+  default: ''
+- name: srcDIR    # Location of freetype2 sources
+  default: '.'
+- name: postCMD   # Command(s) executed after calling CMake 
+  default: ''
+
+steps:
+- ${{ if eq(parameters.mingw, true) }}:
+  - script: |
+      set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem
+      cd $(Build.SourcesDirectory)
+      %CD:~0,2%\msys64\usr\bin\bash -lc "cmake . ${{ parameters.buildArgs }} 
-B $(echo \"$(Build.BinariesDirectory)\" | tr '\\' '/') -D 
CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=install"
+    displayName: 'CMake Configure'
+    env:
+      MSYSTEM: $(MINGW_UPPER)
+      CHERE_INVOKING: yes
+      MINGW_INSTALLS: $(MINGW_LOWER)
+
+  - script: |
+      set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem
+      %CD:~0,2%\msys64\usr\bin\bash -lc "cmake --build $(echo 
\"$(Build.BinariesDirectory)\" | tr '\\' '/') --config Release --target package"
+    displayName: 'CMake Build and Package'
+    env:
+      MSYSTEM: $(MINGW_UPPER)
+      CHERE_INVOKING: yes
+      MINGW_INSTALLS: $(MINGW_LOWER)
+
+- ${{ if eq(parameters.mingw, false) }}:
+  - script: |
+      ${{ parameters.preCMD }}
+      cd ${{ parameters.srcDIR }}
+      cmake . ${{ parameters.buildArgs }} -B $(Build.BinariesDirectory) -D 
CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=install
+      ${{ parameters.postCMD }}
+    displayName: 'CMake Configure'
+    
+  - script: |
+      ${{ parameters.preCMD }}
+      cd ${{ parameters.srcDIR }}
+      cmake --build $(Build.BinariesDirectory) --config Release --target 
package
+      ${{ parameters.postCMD }}
+    displayName: 'CMake Build and Package'
+
+- script: mv $(Build.BinariesDirectory)/freetype-* 
$(Build.ArtifactStagingDirectory)
+  displayName: 'Stage Artifacts'
+
+- task: PublishBuildArtifacts@1
+  displayName: 'Push Build Artifacts'
+  inputs:
+    pathtoPublish: $(Build.ArtifactStagingDirectory)
+    artifactName: $(Agent.JobName)
diff --git a/CI/build.yml b/CI/build.yml
new file mode 100644
index 0000000..56b5349
--- /dev/null
+++ b/CI/build.yml
@@ -0,0 +1,23 @@
+# passthrough templateto call other build templates
+
+parameters:
+- name: buildArgs # CMake configure flags
+  default: ''
+- name: buildArgs # CMake configure flags
+  default: ''
+- name: mingw     # Mingw requires special enviormental setup
+  type: boolean
+  default: false
+- name: preCMD    # Command(s) executed before calling CMake 
+  default: ''
+- name: srcDIR    # Location of freetype2 sources
+  default: '.'
+- name: postCMD   # Command(s) executed after calling CMake 
+  default: ''
+
+- template: build-autotools.yml
+  parameters:
+    preCMD: ${{ parameters.preCMD }}
+    srcDIR: ${{ parameters.srcDIR }}
+    postCMD: ${{ parameters.postCMD }}
+    buildArgs: ${{ parameters.buildArgs }}
diff --git a/CI/ft-regression.sh b/CI/ft-regression.sh
new file mode 100755
index 0000000..4aa0c81
--- /dev/null
+++ b/CI/ft-regression.sh
@@ -0,0 +1,98 @@
+#!/bin/bash
+
+# Include our configuration
+. ./CI/ft-tests.config
+
+# Usage: ./CI/ft-regression.sh <commit to test against> <test to run (a number 
or "all")>
+
+# The following script checks the source code in the current folder for
+# regressions or changes against previous commits. This is the main script you 
+# should be calling and the rest are more for utility.
+
+# These scripts requires xvfb (for capturing demos), imagick 
+# (for comparing images) and pretty-diff which can be installed via npm  
+# (for diffing text)
+
+# Below is utility function used to build both versions of freetype and 
+# respective demos exes linked against the specific builds
+function build() {
+  # Here we set the script to exit on any failed command because if the build 
+  # fails, then there's nothing to compare so no point in continuing.
+  set -e
+  ./autogen.sh
+  ./configure
+  make
+  pushd ..
+  [[ -d ./freetype2-demos ]]\
+  || git clone ${DEMOS_URL}
+  pushd freetype2-demos
+  git checkout `git rev-list -n 1 --first-parent --before="$(git show -s 
--format=%ci $1)" master`
+  make
+  popd
+  popd
+  # Unset exit on error so the tests will continue to run despie any errors.
+  set +e
+}
+
+# The script wasn't passed a git hash to compare so we exit early and print.
+if [ -z "$1" ]; then
+  echo "No commit specified to check out master for regression tests."
+  echo "Aborting!"
+  exit 1
+fi
+
+if [ -z "$2" ]; then
+  echo "No tests specified running all tests"
+  export RUN_TEST="all"
+else
+  export RUN_TEST="$2"
+fi
+
+# We want a fresh checkout and work dir in order to prevent any stale changes 
+# from slipping through.
+rm -rf "${COMP_COMMIT_DIR}" "${TEST_OUTDIR}"
+
+# Here we store the current directories shortened commit hash which is used as 
+# the subdirectory name for where to dump the logs and images.
+PREV_GIT_HASH=$(git log --pretty=format:'%h' -n 1)
+
+# Again we export this because it's used in the other scripts later.
+export PREVIOUS_PWD=${PWD}
+
+# This is the first build/run of the current dir that will dump our "A" 
+# metricts.
+build ${PREV_GIT_HASH}
+./CI/ft-test.sh
+
+# Next we set up our "B" directory by copyiing our current sources.
+echo "Copying ${PWD} to ${COMP_COMMIT_DIR}"
+cp -p -r "${PWD}" "${COMP_COMMIT_DIR}"
+pushd "${COMP_COMMIT_DIR}"
+
+# Clean before we checkout
+make clean
+
+# Here we stash / clean in the copied "B" directory to prevent any issues
+# checking out the desired test commit.
+if [[ "${PWD}" == "${COMP_COMMIT_DIR}" ]]; then
+  git stash
+  git clean -f -d
+  git checkout "$1"
+  GIT_HASH=$(git log --pretty=format:'%h' -n 1)
+  # Here we start the build / metrics for build "B" 
+  build ${GIT_HASH}
+  # We call the scripts from the current directory as they may not exist in 
+  # previous commits and to prevent confusion when modifying them. One set of
+  # scripts is called but on each call they call different versions of the 
demos
+  # exes.
+  ${PREVIOUS_PWD}/CI/ft-test.sh ${PREV_GIT_HASH} ${GIT_HASH}
+  EXIT=$?
+  popd
+else
+  echo "Failed to change directory to ${COMP_COMMIT_DIR}.\
+    Something is horribly wrong..."
+  echo "Aborting!"
+  exit 1
+fi
+
+exit 0
diff --git a/CI/ft-report.sh b/CI/ft-report.sh
new file mode 100755
index 0000000..d3f9c97
--- /dev/null
+++ b/CI/ft-report.sh
@@ -0,0 +1,177 @@
+#!/bin/bash
+
+# Include our configuration
+. ${PREVIOUS_PWD}/CI/ft-tests.config
+
+# Arguments
+FONT=$1
+SIZE=$2
+COMMIT_A=$3
+COMMIT_B=$4
+
+# This script generates diffs and html reports from the metrics previously 
+# generated.
+
+EXIT=0
+
+metrics_dir="$(basename ${FONT})/${SIZE}/"
+diff_dir="${TEST_OUTDIR}/${COMMIT_A}_${COMMIT_B}_diffs/${metrics_dir}"
+mkdir -p "${diff_dir}"
+
+OUTDIR_A="${TEST_OUTDIR}/${COMMIT_A}/$(basename ${FONT})/${SIZE}/"
+OUTDIR_B="${TEST_OUTDIR}/${COMMIT_B}/$(basename ${FONT})/${SIZE}/"
+
+RELATIVE_OUTDIR_A="${COMMIT_A}/$(basename ${FONT})/${SIZE}/"
+RELATIVE_OUTDIR_B="${COMMIT_B}/$(basename ${FONT})/${SIZE}/"
+
+# Function below generates a page to compare images. The image should change 
+# between the two versions on mouse over to easily spot differences.
+function write_img_comp() {
+  echo "<!DOCTYPE html>
+  <html>
+  <head>
+  <style>
+  .comp {
+    width: $(identify -format '%w' $1)px;
+    height: $(identify -format '%h' $1)px;
+    background: url(\"${RELATIVE_OUTDIR_A}/$(basename $1)\") no-repeat;
+    display: inline-block;
+  }
+  .comp:hover {
+    background: url(\"${RELATIVE_OUTDIR_B}/$(basename $1)\") no-repeat;
+  }
+  .diff {
+    width: $(identify -format '%w' $1)px;
+    height: $(identify -format '%h' $1)px;
+    background: url(\"${diff_dir}/$(basename $1 .png)_diff.png\") no-repeat;
+    display: inline-block;
+  }
+  </style>
+  </head>
+  <body>
+  <h2>
+  Comparison of $(basename $1) between commits ${COMMIT_A} and ${COMMIT_B}
+  </h2>
+  <div class=\"comp\"></div>
+  <div class=\"diff\"></div>
+  </body>
+  </html>"
+}
+
+# Here we start generating html report. It is just a simple table of pass / 
fail
+# results.
+echo "<!DOCTYPE html>
+<html>
+<head>
+<style>
+table, tr {
+  border: 1px solid black;
+  display:table;
+  margin-right:auto;
+  margin-left:auto;
+  width:100%;
+}
+
+th.fail {
+ color: red       
+}
+
+th.pass {
+ color: green      
+}
+
+</style>
+</head>
+<body>
+
+<h2>Freetype2 Difference Report</h2>
+<h3>
+Commit A: ${COMMIT_A}
+Commit B: ${COMMIT_B}
+</h3>
+<h3>
+Font: $(basename $1)
+</h3>
+<h3>
+Size: $2
+</h3>
+<table>"
+
+PASS=()
+FAIL=()
+FILES=${OUTDIR_A}/*
+
+for f in $FILES
+do
+  filename=$(basename $f)
+  extension="${filename##*.}"
+  
+  # If is png compare with imagick
+  if [[ "$extension" == "png" ]];
+  then
+    diif_cmd=$(compare -metric AE -highlight-color Red -lowlight-color 
PaleGreen $f ${OUTDIR_B}/$(basename $f)\
+     "${diff_dir}/$(basename $f .png)_diff.png" &> /dev/null)
+    result=$?
+  # Else if txt compare with
+  else
+    diif_cmd=$(diff $f ${OUTDIR_B}/$(basename $f) &>\
+     $diff_dir/$(basename $f .$extension).diff) # we only care about return 
result
+    result=$?
+  fi  
+    
+  # Generate approriate diff page
+  PAGE="$(basename $f .$extension)_${COMMIT_A}_${COMMIT_B}_diff.html"
+  if [ "$result" -eq "0" ]; 
+  then
+    PASS+="$f "
+  else
+    if [[ "$extension" == "png" ]];
+    then
+      write_img_comp $f &> "${TEST_OUTDIR}/${COMMIT_A}_${COMMIT_B}_diffs/$PAGE"
+    else
+      DISPLAY=-1 pretty-diff $f ${OUTDIR_B}/$(basename $f)
+      mv /tmp/diff.html "${TEST_OUTDIR}/${COMMIT_A}_${COMMIT_B}_diffs/$PAGE"
+    fi
+    FAIL+="$f "
+  fi
+done
+
+# Below we fill out the results table
+echo "<tr><th class=\"fail\">FAIL</th></tr>"
+
+for f in $FAIL
+do
+  filename=$(basename $f)
+  extension="${filename##*.}"
+  if [[ "$filename" != "bench.txt" ]];
+  then
+    EXIT=1
+  fi
+  PAGE="$(basename $f .$extension).html"
+  echo "
+  <tr>
+    <td><a href=\"${COMMIT_A}_${COMMIT_B}_diffs/$(basename $f 
.$extension)_${COMMIT_A}_${COMMIT_B}_diff.html\">$(basename $f)</a></td>
+  </tr>"
+done
+
+echo "<tr><th class=\"pass\">PASS</th></tr>"
+
+for f in $PASS
+do
+  echo "
+  <tr>
+    <td><a 
href=\"${COMMIT_A}_${COMMIT_B}_diffs/${COMMIT_A}/${metrics_dir}/$(basename 
$f)\">$(basename $f)</a></td>
+  </tr>"
+done
+
+echo "
+</table>
+
+</body>
+</html>"
+
+# Move our tests results into dir so html refrences work
+cp -R ${TEST_OUTDIR}/${COMMIT_A}/ ${TEST_OUTDIR}/${COMMIT_A}_${COMMIT_B}_diffs 
&> /dev/null
+cp -R ${TEST_OUTDIR}/${COMMIT_B}/ ${TEST_OUTDIR}/${COMMIT_A}_${COMMIT_B}_diffs 
&> /dev/null
+
+exit $EXIT
diff --git a/CI/ft-test-font.sh b/CI/ft-test-font.sh
new file mode 100755
index 0000000..273fc43
--- /dev/null
+++ b/CI/ft-test-font.sh
@@ -0,0 +1,94 @@
+#!/bin/bash
+
+# Include our configuration
+. ${PREVIOUS_PWD}/CI/ft-tests.config
+
+# Arguments
+COMMIT=$1
+FONT=$2
+SIZE=$3
+DPI=$4
+DUMP=$5
+BENCH=$6
+VIEW=$7
+STRING=$8
+START_GLYPH=$9
+END_GLYPH=${10}
+
+OUT_DIR="${TEST_OUTDIR}/${COMMIT}/$(basename ${FONT})/${SIZE}/"
+
+# Ensure directory we want to write to exists.
+mkdir -p $OUT_DIR
+
+# This script dumps specified metrics for a specified font. The arguments 
listed
+# above allow you to specify which metricts to dum when this script is called 
+# from ft-test.sh
+
+
+# Below sets up a virtual X framebuffer to run the demos in. It is 1024x768 at 
+# 24b depth. If you need a larget screen to fit the demos change the resolution
+# here.
+function startX {
+  if [ ! -f "/tmp/.X${1}-lock" ]; then
+    Xvfb :"$1" -screen 0 1024x768x24 &
+    # Wait 2 seconds to ensure X is ready.
+    sleep 2
+  fi
+}
+
+# Below is a utility function to run a command inside the virtual frame buffer,
+# wait 1 second and capture the screen and kill it.The first two arguments are 
+# the xvfb ID and the output image file name.
+function xvfbRunAndScreenShot {
+  display="$1"
+  shift
+  screenshot_name="$1"
+  shift
+  DISPLAY=:"$display" $@ &
+  PID=$!
+  sleep 1
+  DISPLAY=:"$display" xwd -root -silent\
+   | convert -colorspace sRGB -define png:color-type=2 -trim xwd:- 
png:${OUT_DIR}/${screenshot_name}
+  kill $PID
+}
+
+# Because witing 1 second for every command can be slow we set up multiple 
xvfbs
+# in order to expedite the proccess.
+for worker in $(seq 1 $WORKERS)
+do
+  startX $((98 + ${worker})) &
+done
+
+# Below are simple metricts to test that only require one run per font. 
+if [[ "$DUMP" -eq 1 ]]; then
+  ${DEMOS_DIR}/ftdump ${FONT} &> ${OUT_DIR}/dump.txt
+fi
+
+if [[ "$BENCH" -eq 1 ]]; then
+  ${DEMOS_DIR}/ftbench ${FONT} &> ${OUT_DIR}/bench.txt
+fi
+
+if [[ "$STRING" -eq 1 ]]; then
+  xvfbRunAndScreenShot 99 "ftstring.png" ${DEMOS_DIR}/ftstring\
+   -r $DPI ${SIZE} ${FONT}
+fi
+
+if [[ "$VIEW" -eq 1 ]]; then
+  xvfbRunAndScreenShot 99 "ftview.png" ${DEMOS_DIR}/ftview -r $DPI ${SIZE} 
${FONT}
+fi
+
+# For ftgrid we run it on thousands of glyphys so this loop takes advantage of
+# the above mentioned xvfb workers to speed it up.
+for GLYPH in $(seq ${START_GLYPH} ${END_GLYPH})
+do 
+   ((i=i%WORKERS)); ((i++==0)) && wait
+   echo "$(basename $FONT) ftgrid ${GLYPH}"
+   # Pad name with 0s to maintain order
+   GLYPH_padded=$(printf "%04d" ${GLYPH})
+   xvfbRunAndScreenShot $((98 + ${i})) "ftgrid_${GLYPH_padded}.png"\
+    ${DEMOS_DIR}/ftgrid -r $DPI -f ${GLYPH} ${SIZE} ${FONT} &
+done
+
+sleep 2 # wait for workers to finish up
+#killall Xvfb
+sleep 2 # wait for all xvfb to die
diff --git a/CI/ft-test.sh b/CI/ft-test.sh
new file mode 100755
index 0000000..6f208a7
--- /dev/null
+++ b/CI/ft-test.sh
@@ -0,0 +1,124 @@
+#!/bin/bash
+
+# Include our configuration
+. ${PREVIOUS_PWD}/CI/ft-tests.config
+
+# Arguments to /ft-test-font.sh
+#COMMIT=$1
+#FONT=$2
+#SIZE=$3
+#DPI=$4
+#DUMP=$5
+#BENCH=$6
+#VIEW=$7
+#STRING=$8
+#START_GLYPH=$9
+#END_GLYPH=$10
+
+# This script is where one might add additional tests. Currently, it cycles
+# through the below directory and call the metric dumping script for any files
+# in that directory. Currently, it only tests all files at pt 16 and dpi 72 and
+# with ft-grid's default rendering mode.
+  
+GIT_HASH=$(git log --pretty=format:'%h' -n 1)
+
+EXIT=0
+PASS=()
+FAIL=()
+
+# Ensure directory we want to write to exists.
+mkdir -p $TEST_OUTDIR
+
+if [[ "$RUN_TEST" == "all" ]]; then
+  for ((i = 0; i < ${#FT_TESTS[@]}; i++))
+  do
+    args=(${FT_TESTS[$i]})
+    ${PREVIOUS_PWD}/CI/ft-test-font.sh ${GIT_HASH} ${FT_TESTS[$i]}
+    if [ ! -z "$1" ]; then
+     ${PREVIOUS_PWD}/CI/ft-report.sh ${args[0]} ${args[1]} ${1} ${2}\
+      &> ${TEST_OUTDIR}/ft-$(basename ${args[0]})-${args[1]}-report.html
+     result=$?
+     if [ "$result" -eq "0" ];
+     then
+       RESULT_STR="PASS"
+       PASS+="ft-$(basename ${args[0]})-${args[1]}-report.html "
+     else
+       RESULT_STR="FAIL"
+       FAIL+="ft-$(basename ${args[0]})-${args[1]}-report.html "
+       # We store any failure to use later in the exit command.
+       EXIT=1
+     fi
+     echo "ft-$(basename ${args[0]})-${args[1]}-report.html [$RESULT_STR]"
+    fi
+  done
+else
+  args=(${FT_TESTS[$RUN_TEST]})
+  ${PREVIOUS_PWD}/CI/ft-test-font.sh ${GIT_HASH} ${FT_TESTS[$RUN_TEST]}
+  if [ ! -z "$1" ]; then
+   ${PREVIOUS_PWD}/CI/ft-report.sh ${args[0]} ${args[1]} ${1} ${2}\
+    &> ${TEST_OUTDIR}/ft-$(basename ${args[0]})-${args[1]}-report.html
+   result=$?
+   if [ "$result" -eq "0" ];
+   then
+     RESULT_STR="PASS"
+     PASS+="ft-$(basename ${args[0]})-${args[1]}-report.html "
+   else
+     RESULT_STR="FAIL"
+     FAIL+="ft-$(basename ${args[0]})-${args[1]}-report.html "
+     # We store any failure to use later in the exit command.
+     EXIT=1
+   fi
+   echo "ft-$(basename ${args[0]})-${args[1]}-report.html [$RESULT_STR]"
+  fi
+fi
+
+# Below we generate an index of all reports generated
+echo "<!DOCTYPE html>
+<html>
+<head>
+<style>
+table, tr {
+  border: 1px solid black;
+  display:table;
+  margin-right:auto;
+  margin-left:auto;
+  width:100%;
+}
+th.fail {
+ color: red       
+}
+th.pass {
+ color: green      
+}
+</style>
+</head>
+<body>
+<h2>Freetype2 Difference Reports Index</h2>
+<table>" &> "${TEST_OUTDIR}/index.html"
+
+echo "<tr><th class=\"fail\">FAIL</th></tr>" &>> "${TEST_OUTDIR}/index.html"
+
+for f in $FAIL
+do
+  echo "
+  <tr>
+    <td><a href=\"$f\">$(basename $f .html)</a></td>
+  </tr>" &>> "${TEST_OUTDIR}/index.html"
+done
+
+echo "<tr><th class=\"pass\">PASS</th></tr>" &>> "${TEST_OUTDIR}/index.html"
+
+for f in $PASS
+do
+  echo "
+  <tr>
+        <td><a href=\"$f\">$(basename $f .html)</a></td>
+  </tr>" &>> "${TEST_OUTDIR}/index.html"
+done
+
+echo "
+</table>
+</body>
+</html>" &>> "${TEST_OUTDIR}/index.html"
+
+exit $EXIT
diff --git a/CI/ft-tests.config b/CI/ft-tests.config
new file mode 100755
index 0000000..611e9fb
--- /dev/null
+++ b/CI/ft-tests.config
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+# URL to clone demos from
+DEMOS_URL="git://git.sv.nongnu.org/freetype/freetype2-demos.git"
+
+# Directory of demos relative to freetype
+DEMOS_DIR="../freetype2-demos/bin"
+
+# Base directory to ouptut test results
+TEST_OUTDIR="/tmp/ft-tests"
+
+# This is where we build the commit of freetype we wish to compare against. We
+# export it here because this variable is used in other scripts invoked later.
+COMP_COMMIT_DIR="/tmp/freetype2"
+
+# Number of xvfb threads to use
+WORKERS=20
+
+# List of tests Below
+## Arguments (in order)
+### FONT: path to ttf
+### SIZE: size to render test at
+### DPI: dpi to render test at
+### DUMP: boolean, run dump test 
+### BENCH: boolean, run bench test
+### VIEW: boolean, run dump view test
+### STRING: boolean, run string test
+### START_GLYPH: first glyph to use in ftview tests
+### END_GLYPH: last glyph to use in ftview tests
+
+FT_TESTS=(
+"${HOME}/test-fonts/LiberationSerif-Regular.ttf 16 72 1 1 1 1 0 10"
+"${HOME}/test-fonts/LiberationSans-Bold.ttf 32 72 1 1 1 1 10 30"
+"${HOME}/test-fonts/LiberationMono-BoldItalic.ttf 32 72 1 1 1 1 0 2394"
+)
diff --git a/CI/mingw-setup.yml b/CI/mingw-setup.yml
new file mode 100644
index 0000000..506adcd
--- /dev/null
+++ b/CI/mingw-setup.yml
@@ -0,0 +1,24 @@
+steps:
+  - script: |
+      git clone https://github.com/msys2/msys2-ci-base.git %CD:~0,2%\msys64
+      %CD:~0,2%\msys64\usr\bin\rm -rf %CD:~0,2%\msys64\.git
+    displayName: Install MSYS2
+  
+  - script: |
+      set 
PATH=%CD:~0,2%\msys64\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem
+      %CD:~0,2%\msys64\usr\bin\curl -O 
http://repo.msys2.org/msys/x86_64/msys2-keyring-r21.b39fb11-1-any.pkg.tar.xz
+      %CD:~0,2%\msys64\usr\bin\curl -O 
http://repo.msys2.org/msys/x86_64/msys2-keyring-r21.b39fb11-1-any.pkg.tar.xz.sig
+      %CD:~0,2%\msys64\usr\bin\pacman-key --verify 
msys2-keyring-r21.b39fb11-1-any.pkg.tar.xz.sig
+      %CD:~0,2%\msys64\usr\bin\pacman --overwrite='*' --noconfirm -U 
msys2-keyring-r21.b39fb11-1-any.pkg.tar.xz
+      %CD:~0,2%\msys64\usr\bin\pacman --noconfirm -Syyuu
+    displayName: Update MSYS2
+    
+  - script: taskkill /f /fi "MODULES eq msys-2.0.dll" || exit /b 0s
+    displayName: Reset MSYS2
+  
+  - script: |
+      set 
PATH=%CD:~0,2%\msys64\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem
+      %CD:~0,2%\msys64\usr\bin\pacman --noconfirm -Syyuu
+      %CD:~0,2%\msys64\usr\bin\pacman --noconfirm --needed -S zip git 
base-devel mingw-w64-$(MINGW_ARCH)-toolchain mingw-w64-$(MINGW_ARCH)-cmake 
mingw-w64-$(MINGW_ARCH)-harfbuzz
+      %CD:~0,2%\msys64\usr\bin\pacman --noconfirm -Scc
+    displayName: Install Toolchain
diff --git a/CI/regression-test.yml b/CI/regression-test.yml
new file mode 100644
index 0000000..70947d8
--- /dev/null
+++ b/CI/regression-test.yml
@@ -0,0 +1,39 @@
+# This is a template for building, running and publishing freetype2 build 
+# regression test artifacts 
+parameters:
+- name: preCMD    # Command(s) executed before calling configure
+  default: ''
+- name: srcDIR    # Location of freetype2 sources
+  default: '.'
+- name: postCMD   # Command(s) executed after calling make
+  default: ''
+- name: testNum   # Test number to run
+  default: '0'
+
+steps:
+  - script: |
+      ${{ parameters.preCMD }}
+      curl 
https://releases.pagure.org/liberation-fonts/liberation-fonts-ttf-2.00.1.tar.gz 
-o /tmp/fonts.tar.gz
+      tar -xf /tmp/fonts.tar.gz
+      mkdir -p ~/test-fonts/
+      mv liberation-fonts-*/*.ttf  ~/test-fonts/
+      cd ${{ parameters.srcDIR }}
+      git clone git://git.sv.nongnu.org/freetype/freetype2-demos.git
+      cd freetype2-demos
+      ln -s ${{ parameters.srcDIR }} ../freetype2
+      cd /freetype2
+      ./CI/ft-regression.sh master ${{ parameters.testNum }}
+      chmod -R 755 /tmp/ft-tests/
+      mv /tmp/ft-tests/ /
+      ${{ parameters.postCMD }}
+    displayName: 'Run Regression Tests'
+
+  - script: |
+      cp -R $(Build.BinariesDirectory)/root.x86_64/ft-tests 
$(Build.ArtifactStagingDirectory)
+    displayName: 'Stage Artifacts'
+
+  - task: PublishBuildArtifacts@1
+    displayName: 'Push Build Artifacts'
+    inputs:
+      pathtoPublish: $(Build.ArtifactStagingDirectory)
+      artifactName: $(Agent.JobName)
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
new file mode 100644
index 0000000..4dc53c5
--- /dev/null
+++ b/azure-pipelines.yml
@@ -0,0 +1,232 @@
+# This file is responsible for seting up several compiler enviorments.
+# Once setup is done, the template "CI/build-cmake.yml" is invoked to test 
freetype
+# compiles successfully on various operating systems and compilers liststed
+# below. Artifacts of all builds are also published to azure.
+
+# TODO: Add functionality tests
+
+trigger:
+- master
+
+variables:
+  vcpkgGitRef: a41c53c14794bb32cb03269069cdd3b66fedda5f # Update this git ref 
to update vcpkg
+  vckpgPackages: zlib bzip2 libpng harfbuzz
+  
+jobs:
+
+## Linux ##
+- job: ArchLinux_Regression
+  displayName: "Archlinux Regression tests"
+  pool:
+    vmImage: ubuntu-latest
+  strategy:
+    matrix:
+      Test1:
+        TEST: 0
+      Test2:
+        TEST: 1
+      Test3:
+        TEST: 2
+        
+  timeoutInMinutes: 360
+  steps:
+    - checkout: self
+      path: freetype2
+      
+    - template: CI/arch-setup.yml
+      
+    - template: CI/regression-test.yml
+      parameters:
+        preCMD: 'cd $(Build.BinariesDirectory) && cat << EOF | sudo 
./root.x86_64/bin/arch-chroot ./root.x86_64/'
+        srcDIR: freetype2
+        postCMD: 'EOF'
+        testNum: $(TEST)
+        
+- job: ArchLinux_Autotools
+  displayName: "Archlinux Autotools"
+  pool:
+    vmImage: ubuntu-latest
+  steps:
+    - checkout: self
+      path: freetype2
+      
+    - template: CI/arch-setup.yml
+      
+    - template: CI/build-autotools.yml
+
+- job: ArchLinux_Cmake
+  displayName: "Archlinux CMake"
+  pool:
+    vmImage: ubuntu-latest
+  strategy:
+    matrix:
+      shared:
+        BUILD_SHARED_LIBS: true
+        BUILD_ARGS: '-G "Unix Makefiles" -D 
BUILD_SHARED_LIBS=$(BUILD_SHARED_LIBS)'
+      static:
+        BUILD_SHARED_LIBS: false
+  
+  steps:
+    - checkout: self
+      path: freetype2
+      
+    - template: CI/arch-setup.yml
+      
+    - template: CI/build-cmake.yml
+      parameters:
+        preCMD: 'cd $(Build.BinariesDirectory) && cat << EOF | sudo 
./root.x86_64/bin/arch-chroot ./root.x86_64/'
+        srcDIR: freetype2
+        postCMD: 'EOF'
+        buildArgs: $(BUILD_ARGS)
+
+## Windows ##
+
+- job: MSVC_2019_CMake
+  displayName: "MVSC 2019 CMake"
+  pool:
+    vmImage: windows-latest
+  strategy:
+    matrix:
+      i686_shared:
+        TRIPLET: x86-windows
+        BUILD_SHARED_LIBS: true
+        ARCH: Win32
+      x86_64_shared:
+        TRIPLET: x64-windows
+        BUILD_SHARED_LIBS: true
+        ARCH: x64
+      i686_static:
+        TRIPLET: x86-windows-static
+        BUILD_SHARED_LIBS: false
+        ARCH: Win32
+      x86_64_static:
+        TRIPLET: x64-windows-static
+        BUILD_SHARED_LIBS: false
+        ARCH: x64
+
+  steps:
+    - task: Cache@2
+      displayName: 'Cache VCPKG Artifacts'
+      inputs:
+        key: '"$(TRIPLET)" | "$(vckpgPackages)" | "$(vcpkgGitRef)" | 
"$(Agent.OS)"'
+        path: '$(Build.BinariesDirectory)/vcpkg'
+        
+    - task: run-vcpkg@0
+      displayName: 'Run VCPKG'
+      inputs:
+        vcpkgArguments: --triplet $(TRIPLET) $(vckpgPackages)
+        vcpkgGitCommitId: $(vcpkgGitRef)
+        vcpkgGitURL: https://github.com/microsoft/vcpkg.git
+
+    - template: CI/build-cmake.yml
+      parameters:
+        buildArgs: '-G "Visual Studio 16 2019" -A $(ARCH) -D 
CMAKE_TOOLCHAIN_FILE=$(Build.BinariesDirectory)\vcpkg\scripts\buildsystems\vcpkg.cmake
 -D VCPKG_ROOT=$(Build.BinariesDirectory)\vcpkg -D 
VCPKG_TARGET_TRIPLET=$(TRIPLET) -D BUILD_SHARED_LIBS=$(BUILD_SHARED_LIBS)'
+
+- job: MINGW_Autotools
+  displayName: "Mingw Autotools"
+  pool:
+    vmImage: windows-latest
+  strategy:
+    matrix:
+      i686:
+        MINGW_UPPER: MINGW32
+        MINGW_LOWER: mingw32
+        MINGW_ARCH: i686
+      x86_64:
+        MINGW_UPPER: MINGW64
+        MINGW_LOWER: mingw64
+        MINGW_ARCH: x86_64
+  
+  steps:
+    - template: CI/mingw-setup.yml
+      
+    - template: CI/build-autotools.yml
+      parameters:
+        mingw: true
+
+- job: MINGW_CMake
+  displayName: "MingGW CMake"
+  pool:
+    vmImage: windows-latest
+  strategy:
+    matrix:
+      i686_shared:
+        MINGW_UPPER: MINGW32
+        MINGW_LOWER: mingw32
+        MINGW_ARCH: i686
+        BUILD_SHARED_LIBS: true
+      x86_64_shared:
+        MINGW_UPPER: MINGW64
+        MINGW_LOWER: mingw64
+        MINGW_ARCH: x86_64
+        BUILD_SHARED_LIBS: true
+      i686_static:
+        MINGW_UPPER: MINGW32
+        MINGW_LOWER: mingw32
+        MINGW_ARCH: i686
+        BUILD_SHARED_LIBS: false
+      x86_64_static:
+        MINGW_UPPER: MINGW64
+        MINGW_LOWER: mingw64
+        MINGW_ARCH: x86_64
+        BUILD_SHARED_LIBS: false
+  
+  steps:
+    - template: CI/mingw-setup.yml
+      
+    - template: CI/build-cmake.yml
+      parameters:
+        mingw: true
+        buildArgs: '-G \"MSYS Makefiles\" -D 
BUILD_SHARED_LIBS=$(BUILD_SHARED_LIBS)'
+
+## MacOS X ##
+
+- job: MacOS_X_Autotools
+  displayName: "MacOS X Autotools"
+  pool:
+    vmImage: macos-latest
+    
+  steps:
+    - script: |
+        curl -fsSL 
https://raw.githubusercontent.com/Homebrew/install/master/install.sh
+        bash ./install.sh
+        brew install autoconf automake
+      displayName: 'Install Brew'
+      
+    - template: CI/build-autotools.yml
+
+- job: MacOS_X_CMake
+  displayName: "MacOS X CMake"
+  pool:
+    vmImage: macos-latest
+
+  steps:
+    - template: CI/build-cmake.yml
+      parameters:
+        buildArgs: '-G Xcode -D BUILD_FRAMEWORK:BOOL=true'
+
+### iOS ##
+
+- job: iOS_CMake
+  displayName: "iOS CMake"
+  pool:
+    vmImage: macos-latest
+  strategy:
+    matrix:
+      OS:
+        IOS_PLATFORM: OS
+      Simulator:
+        IOS_PLATFORM: SIMULATOR64
+      TV_OS:
+        IOS_PLATFORM: TVOS
+      TV_OS_Simulator:
+        IOS_PLATFORM: SIMULATOR_TVOS
+      Watch_OS:
+        IOS_PLATFORM: WATCHOS
+      Watch_OS_Simulator:
+        IOS_PLATFORM: SIMULATOR_WATCHOS
+      
+  steps:
+    - template: CI/build-cmake.yml
+      parameters:
+        buildArgs: '-G Xcode -D PLATFORM=$(IOS_PLATFORM)'
diff --git a/builds/cmake/iOS.cmake b/builds/cmake/iOS.cmake
index 6f46836..0178556 100644
--- a/builds/cmake/iOS.cmake
+++ b/builds/cmake/iOS.cmake
@@ -1,270 +1,726 @@
-# iOS.cmake
+# This file is part of the ios-cmake project. It was retrieved from
+# https://github.com/cristeab/ios-cmake.git, which is a fork of
+# https://code.google.com/p/ios-cmake/. Which in turn is based off of
+# the Platform/Darwin.cmake and Platform/UnixPaths.cmake files which
+# are included with CMake 2.8.4
 #
-# Copyright (C) 2014-2020 by
-# David Turner, Robert Wilhelm, and Werner Lemberg.
+# The ios-cmake project is licensed under the new BSD license.
 #
-# Written by David Wimsey <david@wimsey.us>
+# Copyright (c) 2014, Bogdan Cristea and LTE Engineering Software,
+# Kitware, Inc., Insight Software Consortium.  All rights reserved.
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
 #
-# This file is part of the FreeType project, and may only be used, modified,
-# and distributed under the terms of the FreeType project license,
-# LICENSE.TXT.  By continuing to use, modify, or distribute this file you
-# indicate that you have read the license and understand and accept it
-# fully.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
 #
+# 3. Neither the name of the copyright holder nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
 #
-# This file is derived from the files `Platform/Darwin.cmake' and
-# `Platform/UnixPaths.cmake', which are part of CMake 2.8.4.  It has been
-# altered for iOS development.
-
-
-# Options
-# -------
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+# This file is based off of the Platform/Darwin.cmake and
+# Platform/UnixPaths.cmake files which are included with CMake 2.8.4
+# It has been altered for iOS development.
+#
+# Updated by Alex Stewart (alexs.mac@gmail.com)
+#
+# *****************************************************************************
+#      Now maintained by Alexander Widerberg (widerbergaren [at] gmail.com)
+#                      under the BSD-3-Clause license
+#                   https://github.com/leetal/ios-cmake
+# *****************************************************************************
+#
+#                           INFORMATION / HELP
+#
+# The following arguments control the behaviour of this toolchain:
+#
+# PLATFORM: (default "OS")
+#    OS = Build for iPhoneOS.
+#    OS64 = Build for arm64 iphoneOS.
+#    OS64COMBINED = Build for arm64 x86_64 iphoneOS. Combined into FAT STATIC 
lib (supported on 3.14+ of CMakewith "-G Xcode" argument ONLY)
+#    SIMULATOR = Build for x86 i386 iphoneOS Simulator.
+#    SIMULATOR64 = Build for x86_64 iphoneOS Simulator.
+#    TVOS = Build for arm64 tvOS.
+#    TVOSCOMBINED = Build for arm64 x86_64 tvOS. Combined into FAT STATIC lib 
(supported on 3.14+ of CMake with "-G Xcode" argument ONLY)
+#    SIMULATOR_TVOS = Build for x86_64 tvOS Simulator.
+#    WATCHOS = Build for armv7k arm64_32 for watchOS.
+#    WATCHOSCOMBINED = Build for armv7k arm64_32 x86_64 watchOS. Combined into 
FAT STATIC lib (supported on 3.14+ of CMake with "-G Xcode" argument ONLY)
+#    SIMULATOR_WATCHOS = Build for x86_64 for watchOS Simulator.
+#
+# CMAKE_OSX_SYSROOT: Path to the SDK to use.  By default this is
+#    automatically determined from PLATFORM and xcodebuild, but
+#    can also be manually specified (although this should not be required).
 #
-#   IOS_PLATFORM = OS | SIMULATOR
+# CMAKE_DEVELOPER_ROOT: Path to the Developer directory for the platform
+#    being compiled for.  By default this is automatically determined from
+#    CMAKE_OSX_SYSROOT, but can also be manually specified (although this 
should
+#    not be required).
 #
-#     This decides whether SDKS are selected from the `iPhoneOS.platform' or
-#     `iPhoneSimulator.platform' folders.
+# DEPLOYMENT_TARGET: Minimum SDK version to target. Default 2.0 on watchOS and 
9.0 on tvOS+iOS
 #
-#     OS - the default, used to build for iPhone and iPad physical devices,
-#       which have an ARM architecture.
-#     SIMULATOR - used to build for the Simulator platforms, which have an
-#       x86 architecture.
+# ENABLE_BITCODE: (1|0) Enables or disables bitcode support. Default 1 (true)
 #
-#   CMAKE_IOS_DEVELOPER_ROOT = /path/to/platform/Developer folder
+# ENABLE_ARC: (1|0) Enables or disables ARC support. Default 1 (true, ARC 
enabled by default)
 #
-#     By default, this location is automatically chosen based on the
-#     IOS_PLATFORM value above.  If you manually set this variable, it
-#     overrides the default location and forces the use of a particular
-#     Developer Platform.
+# ENABLE_VISIBILITY: (1|0) Enables or disables symbol visibility support. 
Default 0 (false, visibility hidden by default)
 #
-#   CMAKE_IOS_SDK_ROOT = /path/to/platform/Developer/SDKs/SDK folder
+# ENABLE_STRICT_TRY_COMPILE: (1|0) Enables or disables strict try_compile() on 
all Check* directives (will run linker
+#    to actually check if linking is possible). Default 0 (false, will set 
CMAKE_TRY_COMPILE_TARGET_TYPE to STATIC_LIBRARY)
 #
-#     By default, this location is automatically chosen based on the
-#     CMAKE_IOS_DEVELOPER_ROOT value.  In this case it is always the most
-#     up-to-date SDK found in the CMAKE_IOS_DEVELOPER_ROOT path.  If you
-#     manually set this variable, it forces the use of a specific SDK
-#     version.
+# ARCHS: (armv7 armv7s armv7k arm64 arm64_32 i386 x86_64) If specified, will 
override the default architectures for the given PLATFORM
+#    OS = armv7 armv7s arm64 (if applicable)
+#    OS64 = arm64 (if applicable)
+#    SIMULATOR = i386
+#    SIMULATOR64 = x86_64
+#    TVOS = arm64
+#    SIMULATOR_TVOS = x86_64 (i386 has since long been deprecated)
+#    WATCHOS = armv7k arm64_32 (if applicable)
+#    SIMULATOR_WATCHOS = x86_64 (i386 has since long been deprecated)
 #
+# This toolchain defines the following variables for use externally:
 #
-# Macros
-# ------
+# XCODE_VERSION: Version number (not including Build version) of Xcode 
detected.
+# SDK_VERSION: Version of SDK being used.
+# CMAKE_OSX_ARCHITECTURES: Architectures being compiled for (generated from 
PLATFORM).
+# APPLE_TARGET_TRIPLE: Used by autoconf build systems. NOTE: If "ARCHS" are 
overridden, this will *NOT* be set!
 #
-#   set_xcode_property (TARGET XCODE_PROPERTY XCODE_VALUE)
+# This toolchain defines the following macros for use externally:
 #
-#     A convenience macro for setting Xcode specific properties on targets.
+# set_xcode_property (TARGET XCODE_PROPERTY XCODE_VALUE XCODE_VARIANT)
+#   A convenience macro for setting xcode specific properties on targets.
+#   Available variants are: All, Release, RelWithDebInfo, Debug, MinSizeRel
+#   example: set_xcode_property (myioslib IPHONEOS_DEPLOYMENT_TARGET "3.1" 
"all").
 #
-#     Example:
+# find_host_package (PROGRAM ARGS)
+#   A macro used to find executable programs on the host system, not within the
+#   environment.  Thanks to the android-cmake project for providing the
+#   command.
 #
-#       set_xcode_property(myioslib IPHONEOS_DEPLOYMENT_TARGET "3.1")
+# ******************************** DEPRECATIONS *******************************
 #
-#   find_host_package (PROGRAM ARGS)
+# IOS_DEPLOYMENT_TARGET: (Deprecated) Alias to DEPLOYMENT_TARGET
+# CMAKE_IOS_DEVELOPER_ROOT: (Deprecated) Alias to CMAKE_DEVELOPER_ROOT
+# IOS_PLATFORM: (Deprecated) Alias to PLATFORM
+# IOS_ARCH: (Deprecated) Alias to ARCHS
 #
-#     A macro to find executable programs on the host system, not within the
-#     iOS environment.  Thanks to the `android-cmake' project for providing
-#     the command.
-
-
-# standard settings
-set(CMAKE_SYSTEM_NAME Darwin)
-set(CMAKE_SYSTEM_VERSION 1)
-set(UNIX True)
-set(APPLE True)
-set(IOS True)
-
-# required as of cmake 2.8.10
-set(CMAKE_OSX_DEPLOYMENT_TARGET ""
-  CACHE STRING "Force unset of the deployment target for iOS" FORCE
-)
-
-# determine the cmake host system version so we know where to find the iOS
-# SDKs
-find_program(CMAKE_UNAME uname /bin /usr/bin /usr/local/bin)
-if (CMAKE_UNAME)
-  exec_program(uname ARGS -r OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_VERSION)
-  string(REGEX REPLACE "^([0-9]+)\\.([0-9]+).*$" "\\1"
-    DARWIN_MAJOR_VERSION "${CMAKE_HOST_SYSTEM_VERSION}")
-endif (CMAKE_UNAME)
-
-# skip the platform compiler checks for cross compiling
-set(CMAKE_CXX_COMPILER_WORKS TRUE)
-set(CMAKE_C_COMPILER_WORKS TRUE)
-
-# all iOS/Darwin specific settings - some may be redundant
+# *****************************************************************************
+#
+
+# Fix for PThread library not in path
+set(CMAKE_THREAD_LIBS_INIT "-lpthread")
+set(CMAKE_HAVE_THREADS_LIBRARY 1)
+set(CMAKE_USE_WIN32_THREADS_INIT 0)
+set(CMAKE_USE_PTHREADS_INIT 1)
+
+# Cache what generator is used
+set(USED_CMAKE_GENERATOR "${CMAKE_GENERATOR}" CACHE STRING "Expose 
CMAKE_GENERATOR" FORCE)
+
+if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.14")
+  set(MODERN_CMAKE YES)
+endif()
+
+# Get the Xcode version being used.
+execute_process(COMMAND xcodebuild -version
+  OUTPUT_VARIABLE XCODE_VERSION
+  ERROR_QUIET
+  OUTPUT_STRIP_TRAILING_WHITESPACE)
+string(REGEX MATCH "Xcode [0-9\\.]+" XCODE_VERSION "${XCODE_VERSION}")
+string(REGEX REPLACE "Xcode ([0-9\\.]+)" "\\1" XCODE_VERSION 
"${XCODE_VERSION}")
+
+######## ALIASES (DEPRECATION WARNINGS)
+
+if(DEFINED IOS_PLATFORM)
+  set(PLATFORM ${IOS_PLATFORM})
+  message(DEPRECATION "IOS_PLATFORM argument is DEPRECATED. Consider using the 
new PLATFORM argument instead.")
+endif()
+
+if(DEFINED IOS_DEPLOYMENT_TARGET)
+  set(DEPLOYMENT_TARGET ${IOS_DEPLOYMENT_TARGET})
+  message(DEPRECATION "IOS_DEPLOYMENT_TARGET argument is DEPRECATED. Consider 
using the new DEPLOYMENT_TARGET argument instead.")
+endif()
+
+if(DEFINED CMAKE_IOS_DEVELOPER_ROOT)
+  set(CMAKE_DEVELOPER_ROOT ${CMAKE_IOS_DEVELOPER_ROOT})
+  message(DEPRECATION "CMAKE_IOS_DEVELOPER_ROOT argument is DEPRECATED. 
Consider using the new CMAKE_DEVELOPER_ROOT argument instead.")
+endif()
+
+if(DEFINED IOS_ARCH)
+  set(ARCHS ${IOS_ARCH})
+  message(DEPRECATION "IOS_ARCH argument is DEPRECATED. Consider using the new 
ARCHS argument instead.")
+endif()
+
+######## END ALIASES
+
+# Unset the FORCE on cache variables if in try_compile()
+set(FORCE_CACHE FORCE)
+get_property(_CMAKE_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE)
+if(_CMAKE_IN_TRY_COMPILE)
+  unset(FORCE_CACHE)
+endif()
+
+# Default to building for iPhoneOS if not specified otherwise, and we cannot
+# determine the platform from the CMAKE_OSX_ARCHITECTURES variable. The use
+# of CMAKE_OSX_ARCHITECTURES is such that try_compile() projects can correctly
+# determine the value of PLATFORM from the root project, as
+# CMAKE_OSX_ARCHITECTURES is propagated to them by CMake.
+if(NOT DEFINED PLATFORM)
+  if (CMAKE_OSX_ARCHITECTURES)
+    if(CMAKE_OSX_ARCHITECTURES MATCHES ".*arm.*" AND CMAKE_OSX_SYSROOT MATCHES 
".*iphoneos.*")
+      set(PLATFORM "OS")
+    elseif(CMAKE_OSX_ARCHITECTURES MATCHES "i386" AND CMAKE_OSX_SYSROOT 
MATCHES ".*iphonesimulator.*")
+      set(PLATFORM "SIMULATOR")
+    elseif(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64" AND CMAKE_OSX_SYSROOT 
MATCHES ".*iphonesimulator.*")
+      set(PLATFORM "SIMULATOR64")
+    elseif(CMAKE_OSX_ARCHITECTURES MATCHES "arm64" AND CMAKE_OSX_SYSROOT 
MATCHES ".*appletvos.*")
+      set(PLATFORM "TVOS")
+    elseif(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64" AND CMAKE_OSX_SYSROOT 
MATCHES ".*appletvsimulator.*")
+      set(PLATFORM "SIMULATOR_TVOS")
+    elseif(CMAKE_OSX_ARCHITECTURES MATCHES ".*armv7k.*" AND CMAKE_OSX_SYSROOT 
MATCHES ".*watchos.*")
+      set(PLATFORM "WATCHOS")
+    elseif(CMAKE_OSX_ARCHITECTURES MATCHES "i386" AND CMAKE_OSX_SYSROOT 
MATCHES ".*watchsimulator.*")
+      set(PLATFORM "SIMULATOR_WATCHOS")
+    endif()
+  endif()
+  if (NOT PLATFORM)
+    set(PLATFORM "OS")
+  endif()
+endif()
+
+set(PLATFORM_INT "${PLATFORM}" CACHE STRING "Type of platform for which the 
build targets.")
+
+# Handle the case where we are targeting iOS and a version above 10.3.4 
(32-bit support dropped officially)
+if(PLATFORM_INT STREQUAL "OS" AND DEPLOYMENT_TARGET VERSION_GREATER_EQUAL 
10.3.4)
+  set(PLATFORM_INT "OS64")
+  message(STATUS "Targeting minimum SDK version ${DEPLOYMENT_TARGET}. Dropping 
32-bit support.")
+elseif(PLATFORM_INT STREQUAL "SIMULATOR" AND DEPLOYMENT_TARGET 
VERSION_GREATER_EQUAL 10.3.4)
+  set(PLATFORM_INT "SIMULATOR64")
+  message(STATUS "Targeting minimum SDK version ${DEPLOYMENT_TARGET}. Dropping 
32-bit support.")
+endif()
+
+# Determine the platform name and architectures for use in xcodebuild commands
+# from the specified PLATFORM name.
+if(PLATFORM_INT STREQUAL "OS")
+  set(SDK_NAME iphoneos)
+  if(NOT ARCHS)
+    set(ARCHS armv7 armv7s arm64)
+    set(APPLE_TARGET_TRIPLE_INT arm-apple-ios)
+  endif()
+elseif(PLATFORM_INT STREQUAL "OS64")
+  set(SDK_NAME iphoneos)
+  if(NOT ARCHS)
+    if (XCODE_VERSION VERSION_GREATER 10.0)
+      set(ARCHS arm64) # Add arm64e when Apple have fixed the integration 
issues with it, libarclite_iphoneos.a is currently missung bitcode markers for 
example
+    else()
+      set(ARCHS arm64)
+    endif()
+    set(APPLE_TARGET_TRIPLE_INT aarch64-apple-ios)
+  endif()
+elseif(PLATFORM_INT STREQUAL "OS64COMBINED")
+  set(SDK_NAME iphoneos)
+  if(MODERN_CMAKE)
+    if(NOT ARCHS)
+      if (XCODE_VERSION VERSION_GREATER 10.0)
+        set(ARCHS arm64 x86_64) # Add arm64e when Apple have fixed the 
integration issues with it, libarclite_iphoneos.a is currently missung bitcode 
markers for example
+      else()
+        set(ARCHS arm64 x86_64)
+      endif()
+      set(APPLE_TARGET_TRIPLE_INT aarch64-x86_64-apple-ios)
+    endif()
+  else()
+    message(FATAL_ERROR "Please make sure that you are running CMake 3.14+ to 
make the OS64COMBINED setting work")
+  endif()
+elseif(PLATFORM_INT STREQUAL "SIMULATOR")
+  set(SDK_NAME iphonesimulator)
+  if(NOT ARCHS)
+    set(ARCHS i386)
+    set(APPLE_TARGET_TRIPLE_INT i386-apple-ios)
+  endif()
+  message(DEPRECATION "SIMULATOR IS DEPRECATED. Consider using SIMULATOR64 
instead.")
+elseif(PLATFORM_INT STREQUAL "SIMULATOR64")
+  set(SDK_NAME iphonesimulator)
+  if(NOT ARCHS)
+    set(ARCHS x86_64)
+    set(APPLE_TARGET_TRIPLE_INT x86_64-apple-ios)
+  endif()
+elseif(PLATFORM_INT STREQUAL "TVOS")
+  set(SDK_NAME appletvos)
+  if(NOT ARCHS)
+    set(ARCHS arm64)
+    set(APPLE_TARGET_TRIPLE_INT aarch64-apple-tvos)
+  endif()
+elseif (PLATFORM_INT STREQUAL "TVOSCOMBINED")
+  set(SDK_NAME appletvos)
+  if(MODERN_CMAKE)
+    if(NOT ARCHS)
+      set(ARCHS arm64 x86_64)
+      set(APPLE_TARGET_TRIPLE_INT aarch64-x86_64-apple-tvos)
+    endif()
+  else()
+    message(FATAL_ERROR "Please make sure that you are running CMake 3.14+ to 
make the TVOSCOMBINED setting work")
+  endif()
+elseif(PLATFORM_INT STREQUAL "SIMULATOR_TVOS")
+  set(SDK_NAME appletvsimulator)
+  if(NOT ARCHS)
+    set(ARCHS x86_64)
+    set(APPLE_TARGET_TRIPLE_INT x86_64-apple-tvos)
+  endif()
+elseif(PLATFORM_INT STREQUAL "WATCHOS")
+  set(SDK_NAME watchos)
+  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fgnu-inline-asm")
+  if(NOT ARCHS)
+    if (XCODE_VERSION VERSION_GREATER 10.0)
+      set(ARCHS armv7k arm64_32)
+      set(APPLE_TARGET_TRIPLE_INT aarch64_32-apple-watchos)
+    else()
+      set(ARCHS armv7k)
+      set(APPLE_TARGET_TRIPLE_INT arm-apple-watchos)
+    endif()
+  endif()
+elseif(PLATFORM_INT STREQUAL "WATCHOSCOMBINED")
+  set(SDK_NAME watchos)
+  if(MODERN_CMAKE)
+    if(NOT ARCHS)
+      if (XCODE_VERSION VERSION_GREATER 10.0)
+        set(ARCHS armv7k arm64_32 i386)
+        set(APPLE_TARGET_TRIPLE_INT aarch64_32-i386-apple-watchos)
+      else()
+        set(ARCHS armv7k i386)
+        set(APPLE_TARGET_TRIPLE_INT arm-i386-apple-watchos)
+      endif()
+    endif()
+  else()
+    message(FATAL_ERROR "Please make sure that you are running CMake 3.14+ to 
make the WATCHOSCOMBINED setting work")
+  endif()
+elseif(PLATFORM_INT STREQUAL "SIMULATOR_WATCHOS")
+  set(SDK_NAME watchsimulator)
+  if(NOT ARCHS)
+    set(ARCHS i386)
+    set(APPLE_TARGET_TRIPLE_INT i386-apple-watchos)
+  endif()
+else()
+  message(FATAL_ERROR "Invalid PLATFORM: ${PLATFORM_INT}")
+endif()
+
+if(MODERN_CMAKE AND PLATFORM_INT MATCHES ".*COMBINED" AND NOT 
USED_CMAKE_GENERATOR MATCHES "Xcode")
+  message(FATAL_ERROR "The COMBINED options only work with Xcode generator, -G 
Xcode")
+endif()
+
+# If user did not specify the SDK root to use, then query xcodebuild for it.
+execute_process(COMMAND xcodebuild -version -sdk ${SDK_NAME} Path
+    OUTPUT_VARIABLE CMAKE_OSX_SYSROOT_INT
+    ERROR_QUIET
+    OUTPUT_STRIP_TRAILING_WHITESPACE)
+if (NOT DEFINED CMAKE_OSX_SYSROOT_INT AND NOT DEFINED CMAKE_OSX_SYSROOT)
+  message(SEND_ERROR "Please make sure that Xcode is installed and that the 
toolchain"
+  "is pointing to the correct path. Please run:"
+  "sudo xcode-select -s /Applications/Xcode.app/Contents/Developer"
+  "and see if that fixes the problem for you.")
+  message(FATAL_ERROR "Invalid CMAKE_OSX_SYSROOT: ${CMAKE_OSX_SYSROOT} "
+  "does not exist.")
+elseif(DEFINED CMAKE_OSX_SYSROOT_INT)
+   set(CMAKE_OSX_SYSROOT "${CMAKE_OSX_SYSROOT_INT}" CACHE INTERNAL "")
+endif()
+
+# Set Xcode property for SDKROOT as well if Xcode generator is used
+if(USED_CMAKE_GENERATOR MATCHES "Xcode")
+  set(CMAKE_OSX_SYSROOT "${SDK_NAME}" CACHE INTERNAL "")
+  if(NOT DEFINED CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM)
+    set(CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM "123456789A" CACHE INTERNAL "")
+  endif()
+endif()
+
+# Specify minimum version of deployment target.
+if(NOT DEFINED DEPLOYMENT_TARGET)
+  if (PLATFORM_INT STREQUAL "WATCHOS" OR PLATFORM_INT STREQUAL 
"SIMULATOR_WATCHOS")
+    # Unless specified, SDK version 2.0 is used by default as minimum target 
version (watchOS).
+    set(DEPLOYMENT_TARGET "2.0"
+            CACHE STRING "Minimum SDK version to build for." )
+  else()
+    # Unless specified, SDK version 9.0 is used by default as minimum target 
version (iOS, tvOS).
+    set(DEPLOYMENT_TARGET "9.0"
+            CACHE STRING "Minimum SDK version to build for." )
+  endif()
+  message(STATUS "Using the default min-version since DEPLOYMENT_TARGET not 
provided!")
+endif()
+
+# Use bitcode or not
+if(NOT DEFINED ENABLE_BITCODE AND NOT ARCHS MATCHES "((^|;|, )(i386|x86_64))+")
+  # Unless specified, enable bitcode support by default
+  message(STATUS "Enabling bitcode support by default. ENABLE_BITCODE not 
provided!")
+  set(ENABLE_BITCODE TRUE)
+elseif(NOT DEFINED ENABLE_BITCODE)
+  message(STATUS "Disabling bitcode support by default on simulators. 
ENABLE_BITCODE not provided for override!")
+  set(ENABLE_BITCODE FALSE)
+endif()
+set(ENABLE_BITCODE_INT ${ENABLE_BITCODE} CACHE BOOL "Whether or not to enable 
bitcode" ${FORCE_CACHE})
+# Use ARC or not
+if(NOT DEFINED ENABLE_ARC)
+  # Unless specified, enable ARC support by default
+  set(ENABLE_ARC TRUE)
+  message(STATUS "Enabling ARC support by default. ENABLE_ARC not provided!")
+endif()
+set(ENABLE_ARC_INT ${ENABLE_ARC} CACHE BOOL "Whether or not to enable ARC" 
${FORCE_CACHE})
+# Use hidden visibility or not
+if(NOT DEFINED ENABLE_VISIBILITY)
+  # Unless specified, disable symbols visibility by default
+  set(ENABLE_VISIBILITY FALSE)
+  message(STATUS "Hiding symbols visibility by default. ENABLE_VISIBILITY not 
provided!")
+endif()
+set(ENABLE_VISIBILITY_INT ${ENABLE_VISIBILITY} CACHE BOOL "Whether or not to 
hide symbols (-fvisibility=hidden)" ${FORCE_CACHE})
+# Set strict compiler checks or not
+if(NOT DEFINED ENABLE_STRICT_TRY_COMPILE)
+  # Unless specified, disable strict try_compile()
+  set(ENABLE_STRICT_TRY_COMPILE FALSE)
+  message(STATUS "Using NON-strict compiler checks by default. 
ENABLE_STRICT_TRY_COMPILE not provided!")
+endif()
+set(ENABLE_STRICT_TRY_COMPILE_INT ${ENABLE_STRICT_TRY_COMPILE} CACHE BOOL 
"Whether or not to use strict compiler checks" ${FORCE_CACHE})
+# Get the SDK version information.
+execute_process(COMMAND xcodebuild -sdk ${CMAKE_OSX_SYSROOT} -version 
SDKVersion
+  OUTPUT_VARIABLE SDK_VERSION
+  ERROR_QUIET
+  OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+# Find the Developer root for the specific iOS platform being compiled for
+# from CMAKE_OSX_SYSROOT.  Should be ../../ from SDK specified in
+# CMAKE_OSX_SYSROOT. There does not appear to be a direct way to obtain
+# this information from xcrun or xcodebuild.
+if (NOT DEFINED CMAKE_DEVELOPER_ROOT AND NOT USED_CMAKE_GENERATOR MATCHES 
"Xcode")
+  get_filename_component(PLATFORM_SDK_DIR ${CMAKE_OSX_SYSROOT} PATH)
+  get_filename_component(CMAKE_DEVELOPER_ROOT ${PLATFORM_SDK_DIR} PATH)
+  if (NOT DEFINED CMAKE_DEVELOPER_ROOT)
+    message(FATAL_ERROR "Invalid CMAKE_DEVELOPER_ROOT: "
+      "${CMAKE_DEVELOPER_ROOT} does not exist.")
+  endif()
+endif()
+# Find the C & C++ compilers for the specified SDK.
+if(NOT CMAKE_C_COMPILER)
+  execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find clang
+    OUTPUT_VARIABLE CMAKE_C_COMPILER
+    ERROR_QUIET
+    OUTPUT_STRIP_TRAILING_WHITESPACE)
+  message(STATUS "Using C compiler: ${CMAKE_C_COMPILER}")
+endif()
+if(NOT CMAKE_CXX_COMPILER)
+  execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find clang++
+    OUTPUT_VARIABLE CMAKE_CXX_COMPILER
+    ERROR_QUIET
+    OUTPUT_STRIP_TRAILING_WHITESPACE)
+  message(STATUS "Using CXX compiler: ${CMAKE_CXX_COMPILER}")
+endif()
+# Find (Apple's) libtool.
+execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find libtool
+  OUTPUT_VARIABLE BUILD_LIBTOOL
+  ERROR_QUIET
+  OUTPUT_STRIP_TRAILING_WHITESPACE)
+message(STATUS "Using libtool: ${BUILD_LIBTOOL}")
+# Configure libtool to be used instead of ar + ranlib to build static 
libraries.
+# This is required on Xcode 7+, but should also work on previous versions of
+# Xcode.
+set(CMAKE_C_CREATE_STATIC_LIBRARY
+  "${BUILD_LIBTOOL} -static -o <TARGET> <LINK_FLAGS> <OBJECTS> ")
+set(CMAKE_CXX_CREATE_STATIC_LIBRARY
+  "${BUILD_LIBTOOL} -static -o <TARGET> <LINK_FLAGS> <OBJECTS> ")
+# Find the toolchain's provided install_name_tool if none is found on the host
+if(NOT CMAKE_INSTALL_NAME_TOOL)
+  execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find 
install_name_tool
+      OUTPUT_VARIABLE CMAKE_INSTALL_NAME_TOOL_INT
+      ERROR_QUIET
+      OUTPUT_STRIP_TRAILING_WHITESPACE)
+  set(CMAKE_INSTALL_NAME_TOOL ${CMAKE_INSTALL_NAME_TOOL_INT} CACHE STRING "" 
${FORCE_CACHE})
+endif()
+# Get the version of Darwin (OS X) of the host.
+execute_process(COMMAND uname -r
+  OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_VERSION
+  ERROR_QUIET
+  OUTPUT_STRIP_TRAILING_WHITESPACE)
+if(SDK_NAME MATCHES "iphone")
+  set(CMAKE_SYSTEM_NAME iOS CACHE INTERNAL "" ${FORCE_CACHE})
+endif()
+# CMake 3.14+ support building for iOS, watchOS and tvOS out of the box.
+if(MODERN_CMAKE)
+  if(SDK_NAME MATCHES "appletv")
+    set(CMAKE_SYSTEM_NAME tvOS CACHE INTERNAL "" ${FORCE_CACHE})
+  elseif(SDK_NAME MATCHES "watch")
+    set(CMAKE_SYSTEM_NAME watchOS CACHE INTERNAL "" ${FORCE_CACHE})
+  endif()
+  # Provide flags for a combined FAT library build on newer CMake versions
+  if(PLATFORM_INT MATCHES ".*COMBINED")
+    set(CMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH "NO" CACHE INTERNAL "" 
${FORCE_CACHE})
+    set(CMAKE_IOS_INSTALL_COMBINED YES CACHE INTERNAL "" ${FORCE_CACHE})
+    message(STATUS "Will combine built (static) artifacts into FAT lib...")
+  endif()
+elseif(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.10")
+  # Legacy code path prior to CMake 3.14 or fallback if no SDK_NAME specified
+  set(CMAKE_SYSTEM_NAME iOS CACHE INTERNAL "" ${FORCE_CACHE})
+else()
+  # Legacy code path prior to CMake 3.14 or fallback if no SDK_NAME specified
+  set(CMAKE_SYSTEM_NAME Darwin CACHE INTERNAL "" ${FORCE_CACHE})
+endif()
+# Standard settings.
+set(CMAKE_SYSTEM_VERSION ${SDK_VERSION} CACHE INTERNAL "")
+set(UNIX TRUE CACHE BOOL "")
+set(APPLE TRUE CACHE BOOL "")
+set(IOS TRUE CACHE BOOL "")
+set(CMAKE_AR ar CACHE FILEPATH "" FORCE)
+set(CMAKE_RANLIB ranlib CACHE FILEPATH "" FORCE)
+set(CMAKE_STRIP strip CACHE FILEPATH "" FORCE)
+# Set the architectures for which to build.
+set(CMAKE_OSX_ARCHITECTURES ${ARCHS} CACHE STRING "Build architecture for iOS")
+# Change the type of target generated for try_compile() so it'll work when 
cross-compiling, weak compiler checks
+if(ENABLE_STRICT_TRY_COMPILE_INT)
+  message(STATUS "Using strict compiler checks (default in CMake).")
+else()
+  set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
+endif()
+# All iOS/Darwin specific settings - some may be redundant.
+set(CMAKE_MACOSX_BUNDLE YES)
+set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
 set(CMAKE_SHARED_LIBRARY_PREFIX "lib")
 set(CMAKE_SHARED_LIBRARY_SUFFIX ".dylib")
 set(CMAKE_SHARED_MODULE_PREFIX "lib")
 set(CMAKE_SHARED_MODULE_SUFFIX ".so")
+set(CMAKE_C_COMPILER_ABI ELF)
+set(CMAKE_CXX_COMPILER_ABI ELF)
+set(CMAKE_C_HAS_ISYSROOT 1)
+set(CMAKE_CXX_HAS_ISYSROOT 1)
 set(CMAKE_MODULE_EXISTS 1)
 set(CMAKE_DL_LIBS "")
-
-set(CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG
-  "-compatibility_version ")
-set(CMAKE_C_OSX_CURRENT_VERSION_FLAG
-  "-current_version ")
-set(CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG
-  "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}")
-set(CMAKE_CXX_OSX_CURRENT_VERSION_FLAG
-  "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}")
-
-# hidden visibility is required for cxx on iOS
-set(CMAKE_C_FLAGS_INIT "")
-set(CMAKE_CXX_FLAGS_INIT
-  "-headerpad_max_install_names -fvisibility=hidden 
-fvisibility-inlines-hidden")
-
-set(CMAKE_C_LINK_FLAGS
-  "-Wl,-search_paths_first ${CMAKE_C_LINK_FLAGS}")
-set(CMAKE_CXX_LINK_FLAGS
-  "-Wl,-search_paths_first ${CMAKE_CXX_LINK_FLAGS}")
+set(CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ")
+set(CMAKE_C_OSX_CURRENT_VERSION_FLAG "-current_version ")
+set(CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG 
"${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}")
+set(CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}")
+
+if(ARCHS MATCHES "((^|;|, )(arm64|arm64e|x86_64))+")
+  set(CMAKE_C_SIZEOF_DATA_PTR 8)
+  set(CMAKE_CXX_SIZEOF_DATA_PTR 8)
+  if(ARCHS MATCHES "((^|;|, )(arm64|arm64e))+")
+    set(CMAKE_SYSTEM_PROCESSOR "aarch64")
+  else()
+    set(CMAKE_SYSTEM_PROCESSOR "x86_64")
+  endif()
+else()
+  set(CMAKE_C_SIZEOF_DATA_PTR 4)
+  set(CMAKE_CXX_SIZEOF_DATA_PTR 4)
+  set(CMAKE_SYSTEM_PROCESSOR "arm")
+endif()
+
+# Note that only Xcode 7+ supports the newer more specific:
+# -m${SDK_NAME}-version-min flags, older versions of Xcode use:
+# -m(ios/ios-simulator)-version-min instead.
+if(${CMAKE_VERSION} VERSION_LESS "3.11")
+  if(PLATFORM_INT STREQUAL "OS" OR PLATFORM_INT STREQUAL "OS64")
+    if(XCODE_VERSION VERSION_LESS 7.0)
+      set(SDK_NAME_VERSION_FLAGS
+        "-mios-version-min=${DEPLOYMENT_TARGET}")
+    else()
+      # Xcode 7.0+ uses flags we can build directly from SDK_NAME.
+      set(SDK_NAME_VERSION_FLAGS
+        "-m${SDK_NAME}-version-min=${DEPLOYMENT_TARGET}")
+    endif()
+  elseif(PLATFORM_INT STREQUAL "TVOS")
+    set(SDK_NAME_VERSION_FLAGS
+      "-mtvos-version-min=${DEPLOYMENT_TARGET}")
+  elseif(PLATFORM_INT STREQUAL "SIMULATOR_TVOS")
+    set(SDK_NAME_VERSION_FLAGS
+      "-mtvos-simulator-version-min=${DEPLOYMENT_TARGET}")
+  elseif(PLATFORM_INT STREQUAL "WATCHOS")
+    set(SDK_NAME_VERSION_FLAGS
+      "-mwatchos-version-min=${DEPLOYMENT_TARGET}")
+  elseif(PLATFORM_INT STREQUAL "SIMULATOR_WATCHOS")
+    set(SDK_NAME_VERSION_FLAGS
+      "-mwatchos-simulator-version-min=${DEPLOYMENT_TARGET}")
+  else()
+    # SIMULATOR or SIMULATOR64 both use -mios-simulator-version-min.
+    set(SDK_NAME_VERSION_FLAGS
+      "-mios-simulator-version-min=${DEPLOYMENT_TARGET}")
+  endif()
+else()
+  # Newer versions of CMake sets the version min flags correctly
+  set(CMAKE_OSX_DEPLOYMENT_TARGET ${DEPLOYMENT_TARGET} CACHE STRING
+      "Set CMake deployment target" ${FORCE_CACHE})
+endif()
+
+if(DEFINED APPLE_TARGET_TRIPLE_INT)
+  set(APPLE_TARGET_TRIPLE ${APPLE_TARGET_TRIPLE_INT} CACHE STRING
+          "Autoconf target triple compatible variable" ${FORCE_CACHE})
+endif()
+
+if(ENABLE_BITCODE_INT)
+  set(BITCODE "-fembed-bitcode")
+  set(CMAKE_XCODE_ATTRIBUTE_BITCODE_GENERATION_MODE "bitcode" CACHE INTERNAL 
"")
+  set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES" CACHE INTERNAL "")
+else()
+  set(BITCODE "")
+  set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO" CACHE INTERNAL "")
+endif()
+
+if(ENABLE_ARC_INT)
+  set(FOBJC_ARC "-fobjc-arc")
+  set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC "YES" CACHE INTERNAL "")
+else()
+  set(FOBJC_ARC "-fno-objc-arc")
+  set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC "NO" CACHE INTERNAL "")
+endif()
+
+if(NOT ENABLE_VISIBILITY_INT)
+  set(VISIBILITY "-fvisibility=hidden")
+  set(CMAKE_XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN "YES" CACHE INTERNAL "")
+else()
+  set(VISIBILITY "")
+  set(CMAKE_XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN "NO" CACHE INTERNAL "")
+endif()
+
+if(NOT IOS_TOOLCHAIN_HAS_RUN)
+  #Check if Xcode generator is used, since that will handle these flags 
automagically
+  if(USED_CMAKE_GENERATOR MATCHES "Xcode")
+    message(STATUS "Not setting any manual command-line buildflags, since 
Xcode is selected as generator.")
+  else()
+    set(CMAKE_C_FLAGS
+    "${SDK_NAME_VERSION_FLAGS} ${BITCODE} -fobjc-abi-version=2 ${FOBJC_ARC} 
${CMAKE_C_FLAGS}")
+    # Hidden visibilty is required for C++ on iOS.
+    set(CMAKE_CXX_FLAGS
+    "${SDK_NAME_VERSION_FLAGS} ${BITCODE} ${VISIBILITY} 
-fvisibility-inlines-hidden -fobjc-abi-version=2 ${FOBJC_ARC} 
${CMAKE_CXX_FLAGS}")
+    set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -O0 -g 
${CMAKE_CXX_FLAGS_DEBUG}")
+    set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS} -DNDEBUG -Os 
-ffast-math ${CMAKE_CXX_FLAGS_MINSIZEREL}")
+    set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS} -DNDEBUG -O2 -g 
-ffast-math ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
+    set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -DNDEBUG -O3 -ffast-math 
${CMAKE_CXX_FLAGS_RELEASE}")
+    set(CMAKE_C_LINK_FLAGS "${SDK_NAME_VERSION_FLAGS} -Wl,-search_paths_first 
${CMAKE_C_LINK_FLAGS}")
+    set(CMAKE_CXX_LINK_FLAGS "${SDK_NAME_VERSION_FLAGS}  
-Wl,-search_paths_first ${CMAKE_CXX_LINK_FLAGS}")
+    set(CMAKE_ASM_FLAGS "${CFLAGS} -x assembler-with-cpp")
+
+    # In order to ensure that the updated compiler flags are used in 
try_compile()
+    # tests, we have to forcibly set them in the CMake cache, not merely set 
them
+    # in the local scope.
+    set(VARS_TO_FORCE_IN_CACHE
+      CMAKE_C_FLAGS
+      CMAKE_CXX_FLAGS
+      CMAKE_CXX_FLAGS_DEBUG
+      CMAKE_CXX_FLAGS_RELWITHDEBINFO
+      CMAKE_CXX_FLAGS_MINSIZEREL
+      CMAKE_CXX_FLAGS_RELEASE
+      CMAKE_C_LINK_FLAGS
+      CMAKE_CXX_LINK_FLAGS)
+    foreach(VAR_TO_FORCE ${VARS_TO_FORCE_IN_CACHE})
+      set(${VAR_TO_FORCE} "${${VAR_TO_FORCE}}" CACHE STRING "" ${FORCE_CACHE})
+    endforeach()
+  endif()
+
+  ## Print status messages to inform of the current state
+  message(STATUS "Configuring ${SDK_NAME} build for platform: ${PLATFORM_INT}, 
architecture(s): ${ARCHS}")
+  message(STATUS "Using SDK: ${CMAKE_OSX_SYSROOT_INT}")
+  if(DEFINED APPLE_TARGET_TRIPLE)
+    message(STATUS "Autoconf target triple: ${APPLE_TARGET_TRIPLE}")
+  endif()
+  message(STATUS "Using minimum deployment version: ${DEPLOYMENT_TARGET}"
+      " (SDK version: ${SDK_VERSION})")
+  if(MODERN_CMAKE)
+    message(STATUS "Merging integrated CMake 3.14+ iOS,tvOS,watchOS,macOS 
toolchain(s) with this toolchain!")
+  endif()
+  if(USED_CMAKE_GENERATOR MATCHES "Xcode")
+    message(STATUS "Using Xcode version: ${XCODE_VERSION}")
+  endif()
+  if(DEFINED SDK_NAME_VERSION_FLAGS)
+    message(STATUS "Using version flags: ${SDK_NAME_VERSION_FLAGS}")
+  endif()
+  message(STATUS "Using a data_ptr size of: ${CMAKE_CXX_SIZEOF_DATA_PTR}")
+  message(STATUS "Using install_name_tool: ${CMAKE_INSTALL_NAME_TOOL}")
+  if(ENABLE_BITCODE_INT)
+    message(STATUS "Enabling bitcode support.")
+  else()
+    message(STATUS "Disabling bitcode support.")
+  endif()
+
+  if(ENABLE_ARC_INT)
+    message(STATUS "Enabling ARC support.")
+  else()
+    message(STATUS "Disabling ARC support.")
+  endif()
+
+  if(NOT ENABLE_VISIBILITY_INT)
+    message(STATUS "Hiding symbols (-fvisibility=hidden).")
+  endif()
+endif()
 
 set(CMAKE_PLATFORM_HAS_INSTALLNAME 1)
-set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS
-  "-dynamiclib -headerpad_max_install_names")
-set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS
-  "-bundle -headerpad_max_install_names")
-set(CMAKE_SHARED_MODULE_LOADER_C_FLAG
-  "-Wl,-bundle_loader,")
-set(CMAKE_SHARED_MODULE_LOADER_CXX_FLAG
-  "-Wl,-bundle_loader,")
-set(CMAKE_FIND_LIBRARY_SUFFIXES
-  ".dylib" ".so" ".a")
-
-# hack: If a new cmake (which uses CMAKE_INSTALL_NAME_TOOL) runs on an old
-#       build tree (where `install_name_tool' was hardcoded), and where
-#       CMAKE_INSTALL_NAME_TOOL isn't in the cache and still cmake didn't
-#       fail in `CMakeFindBinUtils.cmake' (because it isn't rerun), hardcode
-#       CMAKE_INSTALL_NAME_TOOL here to `install_name_tool' so it behaves as
-#       it did before.
-if (NOT DEFINED CMAKE_INSTALL_NAME_TOOL)
-  find_program(CMAKE_INSTALL_NAME_TOOL install_name_tool)
-endif (NOT DEFINED CMAKE_INSTALL_NAME_TOOL)
-
-# set up iOS platform unless specified manually with IOS_PLATFORM
-if (NOT DEFINED IOS_PLATFORM)
-  set(IOS_PLATFORM "OS")
-endif (NOT DEFINED IOS_PLATFORM)
-
-set(IOS_PLATFORM ${IOS_PLATFORM} CACHE STRING "Type of iOS Platform")
-
-# check the platform selection and setup for developer root
-if (${IOS_PLATFORM} STREQUAL "OS")
-  set(IOS_PLATFORM_LOCATION "iPhoneOS.platform")
-
-  # this causes the installers to properly locate the output libraries
-  set(CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos")
-
-elseif (${IOS_PLATFORM} STREQUAL "SIMULATOR")
-  set(IOS_PLATFORM_LOCATION "iPhoneSimulator.platform")
-
-  # this causes the installers to properly locate the output libraries
-  set(CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphonesimulator")
-
-else (${IOS_PLATFORM} STREQUAL "OS")
-  message(FATAL_ERROR
-    "Unsupported IOS_PLATFORM value selected.  Please choose OS or SIMULATOR.")
-
-endif (${IOS_PLATFORM} STREQUAL "OS")
-
-# set up iOS developer location unless specified manually with
-# CMAKE_IOS_DEVELOPER_ROOT --
-# note that Xcode 4.3 changed the installation location; choose the most
-# recent one available
-set(XCODE_POST_43_ROOT
-  
"/Applications/Xcode.app/Contents/Developer/Platforms/${IOS_PLATFORM_LOCATION}/Developer")
-set(XCODE_PRE_43_ROOT
-  "/Developer/Platforms/${IOS_PLATFORM_LOCATION}/Developer")
-
-if (NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT)
-  if (EXISTS ${XCODE_POST_43_ROOT})
-    set(CMAKE_IOS_DEVELOPER_ROOT ${XCODE_POST_43_ROOT})
-  elseif (EXISTS ${XCODE_PRE_43_ROOT})
-    set(CMAKE_IOS_DEVELOPER_ROOT ${XCODE_PRE_43_ROOT})
-  endif (EXISTS ${XCODE_POST_43_ROOT})
-endif (NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT)
-
-set(CMAKE_IOS_DEVELOPER_ROOT ${CMAKE_IOS_DEVELOPER_ROOT}
-  CACHE PATH "Location of iOS Platform"
-)
-
-# find and use the most recent iOS SDK unless specified manually with
-# CMAKE_IOS_SDK_ROOT
-if (NOT DEFINED CMAKE_IOS_SDK_ROOT)
-  file(GLOB _CMAKE_IOS_SDKS "${CMAKE_IOS_DEVELOPER_ROOT}/SDKs/*")
-  if (_CMAKE_IOS_SDKS)
-    list(SORT _CMAKE_IOS_SDKS)
-    list(REVERSE _CMAKE_IOS_SDKS)
-    list(GET _CMAKE_IOS_SDKS 0 CMAKE_IOS_SDK_ROOT)
-  else (_CMAKE_IOS_SDKS)
-    message(FATAL_ERROR
-      "No iOS SDK's found in default search path ${CMAKE_IOS_DEVELOPER_ROOT}.  
Manually set CMAKE_IOS_SDK_ROOT or install the iOS SDK.")
-  endif (_CMAKE_IOS_SDKS)
-
-  message(STATUS "Toolchain using default iOS SDK: ${CMAKE_IOS_SDK_ROOT}")
-endif (NOT DEFINED CMAKE_IOS_SDK_ROOT)
-
-set(CMAKE_IOS_SDK_ROOT ${CMAKE_IOS_SDK_ROOT}
-  CACHE PATH "Location of the selected iOS SDK"
-)
-
-# set the sysroot default to the most recent SDK
-set(CMAKE_OSX_SYSROOT ${CMAKE_IOS_SDK_ROOT}
-  CACHE PATH "Sysroot used for iOS support"
-)
-
-# set the architecture for iOS --
-# note that currently both ARCHS_STANDARD_32_BIT and
-# ARCHS_UNIVERSAL_IPHONE_OS set armv7 only, so set both manually
-if (${IOS_PLATFORM} STREQUAL "OS")
-  set(IOS_ARCH $(ARCHS_STANDARD_32_64_BIT))
-else (${IOS_PLATFORM} STREQUAL "OS")
-  set(IOS_ARCH i386)
-endif (${IOS_PLATFORM} STREQUAL "OS")
-
-set(CMAKE_OSX_ARCHITECTURES ${IOS_ARCH}
-  CACHE string "Build architecture for iOS"
-)
-
-# set the find root to the iOS developer roots and to user defined paths
-set(CMAKE_FIND_ROOT_PATH
-  ${CMAKE_IOS_DEVELOPER_ROOT}
-  ${CMAKE_IOS_SDK_ROOT}
-  ${CMAKE_PREFIX_PATH}
-  CACHE string  "iOS find search path root"
-)
-
-# default to searching for frameworks first
+set(CMAKE_SHARED_LINKER_FLAGS "-rpath @executable_path/Frameworks -rpath 
@loader_path/Frameworks")
+set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib 
-Wl,-headerpad_max_install_names")
+set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle 
-Wl,-headerpad_max_install_names")
+set(CMAKE_SHARED_MODULE_LOADER_C_FLAG "-Wl,-bundle_loader,")
+set(CMAKE_SHARED_MODULE_LOADER_CXX_FLAG "-Wl,-bundle_loader,")
+set(CMAKE_FIND_LIBRARY_SUFFIXES ".tbd" ".dylib" ".so" ".a")
+set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-install_name")
+
+# Set the find root to the iOS developer roots and to user defined paths.
+set(CMAKE_FIND_ROOT_PATH ${CMAKE_OSX_SYSROOT_INT} ${CMAKE_PREFIX_PATH} CACHE 
STRING "Root path that will be prepended
+ to all search paths")
+# Default to searching for frameworks first.
 set(CMAKE_FIND_FRAMEWORK FIRST)
+# Set up the default search directories for frameworks.
+set(CMAKE_FRAMEWORK_PATH
+  ${CMAKE_DEVELOPER_ROOT}/Library/PrivateFrameworks
+  ${CMAKE_OSX_SYSROOT_INT}/System/Library/Frameworks
+  ${CMAKE_FRAMEWORK_PATH} CACHE STRING "Frameworks search paths" 
${FORCE_CACHE})
+
+set(IOS_TOOLCHAIN_HAS_RUN TRUE CACHE BOOL "Has the CMake toolchain run 
already?" ${FORCE_CACHE})
+
+# By default, search both the specified iOS SDK and the remainder of the host 
filesystem.
+if(NOT CMAKE_FIND_ROOT_PATH_MODE_PROGRAM)
+  set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH CACHE STRING "" ${FORCE_CACHE})
+endif()
+if(NOT CMAKE_FIND_ROOT_PATH_MODE_LIBRARY)
+  set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH CACHE STRING "" ${FORCE_CACHE})
+endif()
+if(NOT CMAKE_FIND_ROOT_PATH_MODE_INCLUDE)
+  set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH CACHE STRING "" ${FORCE_CACHE})
+endif()
+if(NOT CMAKE_FIND_ROOT_PATH_MODE_PACKAGE)
+  set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH CACHE STRING "" ${FORCE_CACHE})
+endif()
 
-# set up the default search directories for frameworks
-set(CMAKE_SYSTEM_FRAMEWORK_PATH
-  ${CMAKE_IOS_SDK_ROOT}/System/Library/Frameworks
-  ${CMAKE_IOS_SDK_ROOT}/System/Library/PrivateFrameworks
-  ${CMAKE_IOS_SDK_ROOT}/Developer/Library/Frameworks
-)
-
-# only search the iOS SDKs, not the remainder of the host filesystem
-set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
-set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
-set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
-
-# this little macro lets you set any Xcode specific property
-macro(set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE)
-  set_property(TARGET ${TARGET}
-    PROPERTY XCODE_ATTRIBUTE_${XCODE_PROPERTY} ${XCODE_VALUE})
+#
+# Some helper-macros below to simplify and beautify the CMakeFile
+#
+
+# This little macro lets you set any Xcode specific property.
+macro(set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE XCODE_RELVERSION)
+  set(XCODE_RELVERSION_I "${XCODE_RELVERSION}")
+  if(XCODE_RELVERSION_I STREQUAL "All")
+    set_property(TARGET ${TARGET} PROPERTY
+    XCODE_ATTRIBUTE_${XCODE_PROPERTY} "${XCODE_VALUE}")
+  else()
+    set_property(TARGET ${TARGET} PROPERTY
+    XCODE_ATTRIBUTE_${XCODE_PROPERTY}[variant=${XCODE_RELVERSION_I}] 
"${XCODE_VALUE}")
+  endif()
 endmacro(set_xcode_property)
 
-# this macro lets you find executable programs on the host system
+# This macro lets you find executable programs on the host system.
 macro(find_host_package)
   set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
   set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
   set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)
+  set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE NEVER)
   set(IOS FALSE)
-
   find_package(${ARGN})
-
   set(IOS TRUE)
-  set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
-  set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
-  set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+  set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
+  set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
+  set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
+  set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH)
 endmacro(find_host_package)
-
-# eof



reply via email to

[Prev in Thread] Current Thread [Next in Thread]