summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml44
-rw-r--r--CMakeLists.txt26
-rw-r--r--src/CMakeLists.txt19
-rw-r--r--test/CMakeLists.txt10
-rw-r--r--test/unit/CMakeLists.txt8
5 files changed, 28 insertions, 79 deletions
diff --git a/.travis.yml b/.travis.yml
index 825ad6d7..44667dcb 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,6 +8,9 @@ compiler:
os:
- linux
- osx
+dist:
+ - bionic
+osx_image: xcode11.2
sudo: false
cache:
apt: true
@@ -18,20 +21,6 @@ env:
- BOOST_LIBS="date_time,filesystem,iostreams,python,regex,system,test"
# Encrypted COVERITY_SCAN_TOKEN
- secure: "mYNxD1B8WNSvUeKzInehZ7syi2g1jH2ymeSQxoeKKD2duq3pvNWPdZdc4o9MlWQcAqcz58rhFZRIpuEWCnP0LbbJaG+MyuemMn9uAmg9Y4gFpMsBPHuTdf8pO3rDex+tkrr9puEJFgL+QV/TehxO6NDDpx7UdYvJb+4aZD/auYI="
- 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:
@@ -56,37 +45,16 @@ addons:
- libboost-filesystem-dev
- libboost-serialization-dev
homebrew:
+ update: true
packages:
- boost
- boost-python
- gmp
- mpfr
-before_install:
- - |
- if [ -n "${BOOST_VERSION}" ]; then
- BOOST_SOURCE="$(mktemp -d)"
- BOOST_SOURCE_URL="https://sourceforge.net/projects/boost/files/boost/${BOOST_VERSION}/boost_${BOOST_VERSION//./_}.tar.bz2/download"
- curl -Ls "$BOOST_SOURCE_URL" |
- tar jx -C "${BOOST_SOURCE}" --strip-components 1
- fi
-
-install:
- - |
- if [ -n "${BOOST_VERSION}" ]; then
- export BOOST_ROOT="${HOME}/boost"
- pushd "${BOOST_SOURCE}"
- ./bootstrap.sh --with-libraries="${BOOST_LIBS}"
- ./b2 threading=multi -d0 --prefix="${BOOST_ROOT}" install
- popd
- rm -Rf "${BOOST_SOURCE}"
- fi
-
before_script:
- # 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
+ # On macOS, precompiling system.hh does not work, and boost-python packaging is broken
+ - if [ "$TRAVIS_OS_NAME" = osx ]; then EXTRA_CMAKE_ARGS="-DPRECOMPILE_SYSTEM_HH=OFF -DBoost_NO_BOOST_CMAKE=ON"; fi
- cmake . -DUSE_PYTHON=ON -DBUILD_DEBUG=ON $EXTRA_CMAKE_ARGS
- make VERBOSE=1
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9a6ceae0..2a50089d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,8 +1,4 @@
cmake_minimum_required(VERSION 2.8.5)
-if(POLICY CMP0042)
- # CMP0042 is only known to CMake 3.0 and above
- cmake_policy(SET CMP0042 OLD)
-endif(POLICY CMP0042)
PROJECT(ledger)
@@ -27,7 +23,6 @@ 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)
@@ -59,23 +54,18 @@ endif()
########################################################################
-set(Python_ADDITIONAL_VERSIONS 2.7 2.6)
-find_package(PythonInterp) # Used for running tests
+find_package(Python 2 COMPONENTS Interpreter) # Used for running tests
if (USE_PYTHON)
if (NOT BUILD_LIBRARY)
message(ERROR "Building the python module requires BUILD_LIBRARY=ON.")
endif()
- find_package(PythonLibs)
- if (PYTHONLIBS_FOUND)
- if(USE_PYTHON27_COMPONENT)
- set(BOOST_PYTHON "python27")
- else()
- set(BOOST_PYTHON "python")
- endif()
+ find_package(Python 2 COMPONENTS Interpreter Development)
+ if (PYTHON_FOUND)
+ set(BOOST_PYTHON "python${Python_VERSION_MAJOR}${Python_VERSION_MINOR}")
set(HAVE_BOOST_PYTHON 1)
- include_directories(SYSTEM ${PYTHON_INCLUDE_DIRS})
+ include_directories(SYSTEM ${Python_INCLUDE_DIR})
else()
set(HAVE_BOOST_PYTHON 0)
message("Could not find a Python library to use with Boost.Python")
@@ -173,9 +163,9 @@ if (HAVE_BOOST_PYTHON)
cmake_push_check_state()
set(CMAKE_REQUIRED_INCLUDES
- ${CMAKE_INCLUDE_PATH} ${Boost_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS})
+ ${CMAKE_INCLUDE_PATH} ${Boost_INCLUDE_DIRS} ${Python_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES
- ${Boost_LIBRARIES} ${PYTHON_LIBRARIES} ${PROFILE_LIBS})
+ ${Boost_LIBRARIES} ${Python_LIBRARIES} ${PROFILE_LIBS})
check_cxx_source_compiles("
#include <boost/python.hpp>
@@ -269,7 +259,7 @@ macro(add_ledger_library_dependencies _target)
target_link_libraries(${_target} ${Boost_LIBRARIES})
set_target_properties(${_target} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
else()
- target_link_libraries(${_target} ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})
+ target_link_libraries(${_target} ${Boost_LIBRARIES} ${Python_LIBRARIES})
endif()
else()
target_link_libraries(${_target} ${Boost_LIBRARIES})
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 756df376..5eddd5ac 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -272,7 +272,6 @@ endif()
include(GNUInstallDirs)
if (BUILD_LIBRARY)
- set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
add_library(libledger SHARED ${LEDGER_SOURCES})
add_ledger_library_dependencies(libledger)
set_target_properties(libledger PROPERTIES
@@ -283,8 +282,8 @@ if (BUILD_LIBRARY)
add_executable(ledger main.cc global.cc)
target_link_libraries(ledger libledger)
- if (CMAKE_SYSTEM_NAME STREQUAL Darwin AND HAVE_BOOST_PYTHON)
- target_link_libraries(ledger ${PYTHON_LIBRARIES})
+ if (HAVE_BOOST_PYTHON)
+ target_link_libraries(ledger ${Python_LIBRARIES})
endif()
install(TARGETS libledger DESTINATION ${CMAKE_INSTALL_LIBDIR})
@@ -296,15 +295,7 @@ else()
endif()
if (USE_PYTHON)
- execute_process(COMMAND ${PYTHON_EXECUTABLE} -c
- "from __future__ import print_function
-import distutils.sysconfig as s
-print(s.get_python_lib(True, prefix=''))"
- OUTPUT_VARIABLE _TMP_PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE)
- set(PYTHON_SITE_PACKAGES ${_TMP_PYTHON_SITE_PACKAGES}
- CACHE PATH "python module directory (${_TMP_PYTHON_SITE_PACKAGES})")
-
- if (PYTHON_SITE_PACKAGES)
+ if (Python_SITEARCH)
if (WIN32 AND NOT CYGWIN)
set(_ledger_python_module_name "ledger.pyd")
elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
@@ -323,9 +314,9 @@ print(s.get_python_lib(True, prefix=''))"
$<TARGET_FILE:libledger> "${CMAKE_BINARY_DIR}/${_ledger_python_module_name}")
install(
FILES "${CMAKE_BINARY_DIR}/${_ledger_python_module_name}"
- DESTINATION ${PYTHON_SITE_PACKAGES})
+ DESTINATION ${Python_SITEARCH})
else()
- message(WARNING "PYTHON_SITE_PACKAGES not set. Will not install python module.")
+ message(WARNING "Python_SITEARCH not set. Will not install python module.")
endif()
endif()
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 41eecb36..867abbd4 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -15,14 +15,14 @@ if (HAVE_BOOST_PYTHON)
endif()
macro(add_ledger_harness_tests _class)
- if (PYTHONINTERP_FOUND)
+ if (Python_EXECUTABLE)
file(GLOB ${_class}_TESTS *.test)
foreach(TestFile ${${_class}_TESTS})
get_filename_component(TestFile_Name ${TestFile} NAME_WE)
string(FIND ${TestFile_Name} "_py" TestFile_IsPythonTest)
if ((TestFile_IsPythonTest EQUAL -1) OR HAVE_BOOST_PYTHON)
add_test(NAME ${_class}Test_${TestFile_Name}
- COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/test/RegressTests.py
+ COMMAND ${Python_EXECUTABLE} ${PROJECT_SOURCE_DIR}/test/RegressTests.py
$<TARGET_FILE:ledger> ${PROJECT_SOURCE_DIR}
${TestFile} ${TEST_PYTHON_FLAGS})
set_tests_properties(${_class}Test_${TestFile_Name}
@@ -36,13 +36,13 @@ add_subdirectory(manual)
add_subdirectory(baseline)
add_subdirectory(regress)
-if (PYTHONINTERP_FOUND)
+if (Python_EXECUTABLE)
set(_class DocTests)
file(GLOB ${_class}_TESTS ${PROJECT_SOURCE_DIR}/doc/*.texi)
foreach(TestFile ${${_class}_TESTS})
get_filename_component(TestFile_Name ${TestFile} NAME_WE)
add_test(NAME ${_class}Test_${TestFile_Name}
- COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/test/${_class}.py
+ COMMAND ${Python_EXECUTABLE} ${PROJECT_SOURCE_DIR}/test/${_class}.py
--ledger $<TARGET_FILE:ledger> --file ${TestFile})
set_tests_properties(${_class}Test_${TestFile_Name}
PROPERTIES ENVIRONMENT "TZ=${Ledger_TEST_TIMEZONE}")
@@ -53,7 +53,7 @@ if (PYTHONINTERP_FOUND)
list(APPEND CheckOptions CheckBaselineTests) #CheckManpage CheckTexinfo
foreach(_class ${CheckOptions})
add_test(NAME ${_class}
- COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/test/${_class}.py
+ COMMAND ${Python_EXECUTABLE} ${PROJECT_SOURCE_DIR}/test/${_class}.py
--ledger $<TARGET_FILE:ledger> --source ${PROJECT_SOURCE_DIR})
set_tests_properties(${_class}
PROPERTIES ENVIRONMENT "TZ=${Ledger_TEST_TIMEZONE}")
diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt
index 3611b00a..1bd5e4b3 100644
--- a/test/unit/CMakeLists.txt
+++ b/test/unit/CMakeLists.txt
@@ -9,15 +9,15 @@ include_directories(${PROJECT_SOURCE_DIR}/src)
if (BUILD_LIBRARY)
add_executable(UtilTests t_times.cc)
- if (CMAKE_SYSTEM_NAME STREQUAL Darwin AND HAVE_BOOST_PYTHON)
- target_link_libraries(UtilTests ${PYTHON_LIBRARIES})
+ if (HAVE_BOOST_PYTHON)
+ target_link_libraries(UtilTests ${Python_LIBRARIES})
endif()
add_ledger_test(UtilTests)
add_executable(MathTests t_amount.cc t_commodity.cc t_balance.cc t_expr.cc t_value.cc)
set_source_files_properties(t_amount.cc t_value.cc PROPERTIES COMPILE_FLAGS "-Wno-unused-comparison")
- if (CMAKE_SYSTEM_NAME STREQUAL Darwin AND HAVE_BOOST_PYTHON)
- target_link_libraries(MathTests ${PYTHON_LIBRARIES})
+ if (HAVE_BOOST_PYTHON)
+ target_link_libraries(MathTests ${Python_LIBRARIES})
endif()
add_ledger_test(MathTests)
endif()