From 863cb3bdb7bc3650873253e108b26eb3fe15862d Mon Sep 17 00:00:00 2001
From: Martin Michlmayr <tbm@cyrius.com>
Date: Wed, 9 Jan 2019 20:43:39 -0200
Subject: Use "macOS" consistently

macOS seems to be the current name for Mac OS X.
---
 CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'CMakeLists.txt')

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f8dbd892..e2ed3cac 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -260,7 +260,7 @@ macro(add_ledger_library_dependencies _target)
   endif()
   if (HAVE_BOOST_PYTHON)
     if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
-      # Don't link directly to a Python framework on OS X, to avoid segfaults
+      # Don't link directly to a Python framework on macOS, to avoid segfaults
       # when the module is imported from a different interpreter
       target_link_libraries(${_target} ${Boost_LIBRARIES})
       set_target_properties(${_target} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
-- 
cgit v1.2.3


From da9738f8ee7785724d62eb94747d7803502545a8 Mon Sep 17 00:00:00 2001
From: Tim Landscheidt <tim@tim-landscheidt.de>
Date: Sat, 12 Jan 2019 14:27:50 +0000
Subject: Remove unused macros HAVE_ACCESS and HAVE_REALPATH

---
 CMakeLists.txt   | 2 --
 src/system.hh.in | 4 +---
 src/utils.h      | 6 +-----
 3 files changed, 2 insertions(+), 10 deletions(-)

(limited to 'CMakeLists.txt')

diff --git a/CMakeLists.txt b/CMakeLists.txt
index e2ed3cac..c85a5157 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -96,8 +96,6 @@ include(CheckCXXSourceCompiles)
 include(CheckCXXSourceRuns)
 include(CMakePushCheckState)
 
-check_function_exists(access HAVE_ACCESS)
-check_function_exists(realpath HAVE_REALPATH)
 check_function_exists(getpwuid HAVE_GETPWUID)
 check_function_exists(getpwnam HAVE_GETPWNAM)
 check_function_exists(ioctl HAVE_IOCTL)
diff --git a/src/system.hh.in b/src/system.hh.in
index 38ac1e63..799bb47c 100644
--- a/src/system.hh.in
+++ b/src/system.hh.in
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003-2018, John Wiegley.  All rights reserved.
+ * Copyright (c) 2003-2019, John Wiegley.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -60,8 +60,6 @@
 #define HAVE_EDIT                @HAVE_EDIT@
 #define HAVE_GETTEXT             @HAVE_GETTEXT@
 
-#cmakedefine HAVE_ACCESS
-#cmakedefine HAVE_REALPATH
 #cmakedefine HAVE_GETPWUID
 #cmakedefine HAVE_GETPWNAM
 #cmakedefine HAVE_IOCTL
diff --git a/src/utils.h b/src/utils.h
index 857b8289..c9146dd7 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003-2018, John Wiegley.  All rights reserved.
+ * Copyright (c) 2003-2019, John Wiegley.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -500,10 +500,6 @@ inline T& downcast(U& object) {
 
 path resolve_path(const path& pathname);
 
-#ifdef HAVE_REALPATH
-extern "C" char * realpath(const char *, char resolved_path[]);
-#endif
-
 inline const string& either_or(const string& first,
                                const string& second) {
   return first.empty() ? second : first;
-- 
cgit v1.2.3


From 1116472dce6523ce18a7a9ea9376aac8bed9f864 Mon Sep 17 00:00:00 2001
From: Tim Landscheidt <tim@tim-landscheidt.de>
Date: Sat, 26 Jan 2019 17:40:21 +0000
Subject: Use CMAKE_CXX_COMPILER_ID for conditions based on compiler

CMAKE_CXX_COMPILER is the path to the compiler binary and does not
need to follow a specific pattern.  For example, on Linux with GCC and
without an explicit "-DCMAKE_CXX_COMPILER:PATH=" option,
CMAKE_CXX_COMPILER is "/usr/bin/c++" which does not match "g++".
CMAKE_CXX_COMPILER_ID however will always reliably be "Clang" or
"GNU".
---
 CMakeLists.txt     | 3 +--
 src/CMakeLists.txt | 4 ++--
 2 files changed, 3 insertions(+), 4 deletions(-)

(limited to 'CMakeLists.txt')

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c85a5157..c2c27097 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -296,8 +296,7 @@ configure_file(
   ${PROJECT_SOURCE_DIR}/src/system.hh.in
   ${PROJECT_BINARY_DIR}/system.hh)
 
-if((CMAKE_CXX_COMPILER MATCHES "clang") OR
-   (CMAKE_CXX_COMPILER MATCHES "clang\\+\\+"))
+if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
   set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem ")
 endif()
 
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 9cd54dbe..06acecf2 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -144,7 +144,7 @@ if (WIN32 OR CYGWIN)
 endif()
 
 if (CMAKE_BUILD_TYPE STREQUAL "Debug")
-  if (CMAKE_CXX_COMPILER MATCHES "clang\\+\\+")
+  if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
     add_definitions(
       # -Weverything
       # -Wno-disabled-macro-expansion
@@ -199,7 +199,7 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
         DEPENDS ${_header_filename})
     endmacro(ADD_PCH_RULE _header_filename _src_list _other_srcs)
 
-  elseif (CMAKE_CXX_COMPILER MATCHES "g\\+\\+")
+  elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
     set(GXX_WARNING_FLAGS
       -pedantic
       -Wall
-- 
cgit v1.2.3


From b554d1296888f567c3a661cbd6de2a57457528d1 Mon Sep 17 00:00:00 2001
From: Tim Landscheidt <tim@tim-landscheidt.de>
Date: Sun, 27 Jan 2019 14:09:31 +0000
Subject: Add Travis CI setup for macOS and homebrew-installed Boost

On macOS, CMake detects the Boost.Python component installed by
homebrew only when named "python27".  Thus this change not only adds a
Travis CI setup for macOS, but also a CMake option to switch the
component name between "python" and "python27".  In addition,
precompiling system.hh does not work with the current setup for Clang,
so another CMake option to disable it is added.

The currently used commands to compile specific versions of Boost do
not produce a result that works out of the box on macOS.  It should be
possible just to mimic homebrew's formula for boost-python
(https://github.com/Homebrew/homebrew-core/blob/master/Formula/boost-python.rb),
but for the moment on macOS this change tests only against Boost
installed by homebrew.
---
 .travis.yml        | 25 +++++++++++++++++++++++--
 CMakeLists.txt     |  8 +++++++-
 src/CMakeLists.txt |  4 +++-
 3 files changed, 33 insertions(+), 4 deletions(-)

(limited to 'CMakeLists.txt')

diff --git a/.travis.yml b/.travis.yml
index ae2ff727..825ad6d7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -7,6 +7,7 @@ compiler:
   - gcc
 os:
   - linux
+  - osx
 sudo: false
 cache:
   apt: true
@@ -20,8 +21,18 @@ env:
   matrix:
     # Boost version to build against; an empty string means the
     # distribution's default.
+    - BOOST_VERSION=""
     - BOOST_VERSION="1.61.0"
 
+# The configuration for macOS only works with Boost installed by
+# homebrew, so exclude the other combinations.
+matrix:
+  exclude:
+    - os: linux
+      env: BOOST_VERSION=""
+    - os: osx
+      env: BOOST_VERSION="1.61.0"
+
 addons:
   coverity_scan:
     project:
@@ -44,6 +55,12 @@ addons:
       - libboost-iostreams-dev
       - libboost-filesystem-dev
       - libboost-serialization-dev
+  homebrew:
+    packages:
+      - boost
+      - boost-python
+      - gmp
+      - mpfr
 
 before_install:
   - |
@@ -66,8 +83,12 @@ install:
     fi
 
 before_script:
-  - cmake . -DUSE_PYTHON=ON -DBUILD_DEBUG=ON
-  - make
+  # On macOS, CMake finds the Boost.Python installed by homebrew only
+  # with the component name "python27".  Also, precompiling system.hh
+  # does not work.
+  - if [ "$TRAVIS_OS_NAME" = osx -a -z "$BOOST_VERSION" ]; then EXTRA_CMAKE_ARGS="-DPRECOMPILE_SYSTEM_HH=OFF -DUSE_PYTHON27_COMPONENT=ON"; fi
+  - cmake . -DUSE_PYTHON=ON -DBUILD_DEBUG=ON $EXTRA_CMAKE_ARGS
+  - make VERBOSE=1
 
 script:
   - ctest --output-on-failure
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c2c27097..2116701e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,10 +27,12 @@ endif()
 ########################################################################
 
 option(USE_PYTHON "Build support for the Python scripting bridge" OFF)
+OPTION(USE_PYTHON27_COMPONENT "Use python27 as name of Boost.Python component" OFF)
 option(USE_DOXYGEN "Build reference documentation using Doxygen" OFF)
 
 option(DISABLE_ASSERTS "Build without any internal consistency checks" OFF)
 option(BUILD_DEBUG "Build support for runtime debugging" OFF)
+option(PRECOMPILE_SYSTEM_HH "Precompile system.hh" ON)
 
 option(BUILD_LIBRARY "Build and install Ledger as a library" ON)
 option(BUILD_DOCS "Build and install documentation" OFF)
@@ -67,7 +69,11 @@ if (USE_PYTHON)
 
   find_package(PythonLibs)
   if (PYTHONLIBS_FOUND)
-    set(BOOST_PYTHON python)
+    if(USE_PYTHON27_COMPONENT)
+      set(BOOST_PYTHON "python27")
+    else()
+      set(BOOST_PYTHON "python")
+    endif()
     set(HAVE_BOOST_PYTHON 1)
     include_directories(SYSTEM ${PYTHON_INCLUDE_DIRS})
   else()
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 06acecf2..9b39ea94 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -267,7 +267,9 @@ else()
   endmacro(ADD_PCH_RULE _header_filename _src_list _other_srcs)
 endif()
 
-add_pch_rule(${PROJECT_BINARY_DIR}/system.hh LEDGER_SOURCES LEDGER_CLI_SOURCES)
+if(PRECOMPILE_SYSTEM_HH)
+  add_pch_rule(${PROJECT_BINARY_DIR}/system.hh LEDGER_SOURCES LEDGER_CLI_SOURCES)
+endif()
 
 include(GNUInstallDirs)
 
-- 
cgit v1.2.3