Building on MacOS in 2024

I went through the exercise of building from source on a new machine once again.

“Building SWI-Prolog on MacOSX” is a bit outdated. Not even sure if it should say “X” at the end.

I used Homebrew. This is on the website:

brew install \
     cmake \
     ninja \
     gmp \
     openssl \
     libarchive \
     readline \
     ossp-uuid \
     libyaml \
     unixodbc \
     berkeley-db \
     pcre \
     jpeg

At least:

  • You can and maybe should (?) skip gmp and readline
  • You probably want pcre2 instead of pcre

XQuartz is not mentioned at all in the Homebrew section, and I guess this is fine. It is available in Homebrew but the installation was somehow botched for me. I downloaded it from https://www.xquartz.org/.

Altogether, the Homebrew section of this page could use an update. I can try to do it but I am certainly not a MacOS expert. Please comment so that I know what to write there :smiley:

[EDIT] With the cmake version installed by homebrew, I get a whole lot of warnings. They look like this:

CMake Warning (dev) at cmake/QLF.cmake:75 (install):
  Policy CMP0177 is not set: install() DESTINATION paths are normalized.  Run
  "cmake --help-policy CMP0177" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.
Call Stack (most recent call first):
  packages/xpce/CMakeLists.txt:174 (add_swipl_target)
This warning is for project developers.  Use -Wno-dev to suppress it.

and also like this:

CMake Deprecation Warning at CMakeLists.txt:5 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

I am just reporting this, it looks benign and I don’t know what to do about it.

I see the exact same warnings on Linux. CMake version is:

$ cmake -version
cmake version 3.31.4

CMake suite maintained and supported by Kitware (kitware.com/cmake).

Eventually I just followed the instructions in the warnings.

I changed CMakeLists.txt:

$ git diff
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 37dc7de72..3e7a6b519 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,7 +2,7 @@ set(CMAKE_POLICY_DEFAULT_CMP0074 NEW)
 set(CMAKE_POLICY_DEFAULT_CMP0075 NEW)
 set(CMAKE_POLICY_DEFAULT_CMP0079 NEW)
 
-cmake_minimum_required(VERSION 3.5)
+cmake_minimum_required(VERSION 3.10)
 project(SWI-Prolog)
 
 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

And I also used:

$ cmake -Wno-dev -G Ninja ..

We see the same warnings when building swipl 9.2.9 on freebsd using “cmake version 3.31.5”. I ran the suggested “cmake --help-policy CMP0177”, and it seems to relate to the inclusion of “…”/“.” folder names in the install command. Eventually everything still works, but the build procedure looks a bit messy.

I pushed BUILD: Avoid CMake generating paths with double "/" · SWI-Prolog/swipl-devel@54861f6 · GitHub and BUILD: Updated cmake_minimum_required to 3.10 as adviced in CMake 3.31 · SWI-Prolog/swipl-devel@2bc4e5b · GitHub to address these.

I don’t know whether these work. Fedora is still on CMake 3.30. Can someone test?