New upstream version 1.4.0+ds1

parent 3303844f
......@@ -2,39 +2,49 @@
# http://www.appveyor.com/docs/appveyor-yml
version: "{build}"
os: Visual Studio 2015
os: Visual Studio 2017
clone_folder: C:\projects\ompl
clone_depth: 1
shallow_clone: true
branches:
only:
- master
platform: x64
environment:
CTEST_OUTPUT_ON_FAILURE: 1
BOOST_ROOT: C:\Libraries\boost_1_59_0
BOOST_LIBRARYDIR: C:\Libraries\boost_1_59_0\lib64-msvc-14.0
CMAKE_TOOLCHAIN_FILE: -DCMAKE_TOOLCHAIN_FILE="C:\tools\vcpkg\scripts\buildsystems\vcpkg.cmake"
CMAKE_GENERATOR: -G"Visual Studio 15 2017 Win64"
VCPKG_ARCH: x64-windows
cache:
- C:\tools\vcpkg\installed -> .appveyor.yml
configuration: Release
before_build:
- cmd: set
- cmd: vcpkg install boost-disjoint-sets:%VCPKG_ARCH%
- cmd: vcpkg install boost-dynamic-bitset:%VCPKG_ARCH%
- cmd: vcpkg install boost-filesystem:%VCPKG_ARCH%
- cmd: vcpkg install boost-graph:%VCPKG_ARCH%
- cmd: vcpkg install boost-odeint:%VCPKG_ARCH%
- cmd: vcpkg install boost-program-options:%VCPKG_ARCH%
- cmd: vcpkg install boost-serialization:%VCPKG_ARCH%
- cmd: vcpkg install boost-system:%VCPKG_ARCH%
- cmd: vcpkg install boost-test:%VCPKG_ARCH%
- cmd: vcpkg install boost-ublas:%VCPKG_ARCH%
- cmd: vcpkg install eigen3:%VCPKG_ARCH%
- cmd: mkdir build
- cmd: cd build
- cmd: cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=%configuration% -DOMPL_REGISTRATION=OFF -DOMPL_BUILD_DEMOS=OFF -DBOOST_ROOT="%BOOST_ROOT%" -DBOOST_LIBRARYDIR="%BOOST_LIBRARYDIR%" ..
- cmd: cmake %CMAKE_GENERATOR% -DCMAKE_BUILD_TYPE=%configuration% %CMAKE_TOOLCHAIN_FILE% -DOMPL_REGISTRATION=OFF ..
build:
project: C:\projects\ompl\build\ompl.sln
parallel: true
after_build:
- cmd: cmake --build . --target package --config %configuration%
- cmd: cmake --build . --config %configuration% --target package
# tests seem to hang
#test_script:
# - cmd: ctest -C %configuration%
test_script:
- cmd: ctest -C %configuration%
artifacts:
- path: 'build\ompl*.zip'
......@@ -7,8 +7,9 @@ AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortFunctionsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortBlocksOnASingleLine: false
AlwaysBreakTemplateDeclarations: true
AlwaysBreakBeforeMultilineStrings: false
BreakBeforeBinaryOperators: false
......@@ -33,6 +34,7 @@ PenaltyReturnTypeOnItsOwnLine: 90
PointerBindsToType: false
SpacesBeforeTrailingComments: 2
Cpp11BracedListStyle: true
Language: Cpp
Standard: Cpp11
IndentWidth: 4
TabWidth: 4
......@@ -46,4 +48,5 @@ SpacesInCStyleCastParentheses: false
SpaceAfterControlStatementKeyword: true
SpaceBeforeAssignmentOperators: true
ContinuationIndentWidth: 4
SortIncludes: false
...
......@@ -2,45 +2,40 @@ language: cpp
matrix:
include:
# On Linux, exclude test_machine_specs; started to fail when we switched to g++-5
- os: linux
dist: trusty
sudo: required
compiler: gcc
env: PYTHONPATH=/usr/local/lib/python2.7/dist-packages PATH=${PATH}:${HOME}/castxml/bin JOBS=4 TEST_EXCLUDE='test_machine_spec'
addons:
apt:
packages:
- libboost1.55-all-dev
- python-dev
- libboost-serialization1.55-dev
- libboost-filesystem1.55-dev
- libboost-system1.55-dev
- libboost-program-options1.55-dev
- libboost-test1.55-dev
- libode-dev
- libeigen3-dev
- python-pip
cache:
apt: true
directories:
- ${HOME}/castxml
- /usr/local
# On OS X, exclude test_machine_specs; fails due to "lazy" memory freeing in Release mode
# (test passes in Debug builds).
# On OS X, exclude test_random; fails due to bug in Boost.Random in 1.56.
- os: osx
osx_image: xcode9.1
compiler: clang
env: JOBS=2 TEST_EXCLUDE='test_(machine_specs|random)'
cache:
directories:
- /usr/local
- os: linux
sudo: required
services:
- docker
env: DOCKERFILE="debian-jessie" JOBS=4
env: DOCKERFILE="debian-stretch" PYTHON=/usr/bin/python
- os: linux
sudo: required
services:
- docker
env: DOCKERFILE="ubuntu-xenial" PYTHON=/usr/bin/python
- os: linux
sudo: required
services:
- docker
env: DOCKERFILE="ubuntu-xenial" JOBS=4 TEST_EXCLUDE='test_(machine_specs|random)'
env: DOCKERFILE="ubuntu-bionic" PYTHON=/usr/bin/python3
install:
- if [ -n "$DOCKERFILE" ]; then
......@@ -48,30 +43,22 @@ install:
fi
- if [ -z "$DOCKERFILE" -a "$TRAVIS_OS_NAME" = "osx" ]; then
brew update;
brew install boost-python ode eigen castxml;
brew install eigen;
fi
- if [ -z "$DOCKERFILE" -a "$TRAVIS_OS_NAME" = "linux" ]; then
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test;
sudo apt-get -y update;
sudo apt-get -y install g++-5;
export CXX=g++-5;
wget -O - https://midas3.kitware.com/midas/download/item/318227/castxml-linux.tar.gz | tar zxf - -C ${HOME};
fi
- if [ -z "$DOCKERFILE" ]; then
sudo -H pip -v install pygccxml pyplusplus;
fi
script:
- if [ -n "$DOCKERFILE" ]; then
docker run "$DOCKERFILE" /bin/sh -c "mkdir /root/ompl/build && cd /root/ompl/build && cmake -DOMPL_REGISTRATION=OFF -DCMAKE_INSTALL_PREFIX=tmp .. && make -j $JOBS && ctest -E '$TEST_EXCLUDE'";
docker run "$DOCKERFILE" /bin/sh -c "mkdir /root/ompl/build && cd /root/ompl/build && cmake -DPYTHON_EXEC=$PYTHON -DOMPL_REGISTRATION=OFF -DCMAKE_INSTALL_PREFIX=tmp .. && make -j `nproc` && ctest";
else
mkdir -p build &&
cd build &&
cmake -DOMPL_REGISTRATION=OFF -DCMAKE_INSTALL_PREFIX=tmp -DCASTXML=${HOME}/castxml/bin/castxml .. &&
make -j $JOBS &&
ctest -E "$TEST_EXCLUDE";
cmake -DOMPL_REGISTRATION=OFF -DCMAKE_INSTALL_PREFIX=tmp .. &&
make -j `nproc 2>/dev/null || sysctl -n hw.ncpu` &&
ctest;
fi
# disabled because this takes several hours to complete:
#make -j $JOBS update_bindings &&
{
"variant": null,
"activeEnvironments": [],
"codeModel": null
}
\ No newline at end of file
{
"configurations": [
{
"name": "Mac",
"browse": {
"path": [
"${workspaceFolder}",
"/opt/local/include"
],
"limitSymbolsToIncludedHeaders": true
},
"includePath": [
"${workspaceFolder}",
"/opt/local/include"
],
"defines": [],
"macFrameworkPath": [
"/System/Library/Frameworks",
"/Library/Frameworks"
],
"compilerPath": "/usr/bin/clang",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
\ No newline at end of file
{
"files.associations": {
"iterator": "cpp",
"chrono": "cpp",
"__bit_reference": "cpp",
"__hash_table": "cpp",
"__split_buffer": "cpp",
"__tree": "cpp",
"array": "cpp",
"bitset": "cpp",
"deque": "cpp",
"initializer_list": "cpp",
"list": "cpp",
"map": "cpp",
"memory": "cpp",
"queue": "cpp",
"set": "cpp",
"stack": "cpp",
"string": "cpp",
"string_view": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"vector": "cpp",
"ios": "cpp",
"valarray": "cpp",
"functional": "cpp",
"random": "cpp",
"utility": "cpp",
"__config": "cpp",
"__nullptr": "cpp",
"cstddef": "cpp",
"exception": "cpp",
"new": "cpp",
"stdexcept": "cpp",
"type_traits": "cpp",
"typeinfo": "cpp",
"algorithm": "cpp",
"cctype": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"ctime": "cpp",
"*.tcc": "cpp",
"cmath": "cpp",
"complex": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"ostream": "cpp",
"sstream": "cpp",
"streambuf": "cpp",
"__locale": "cpp",
"__functional_03": "cpp"
}
}
\ No newline at end of file
......@@ -29,6 +29,7 @@ set(CMAKE_MODULE_PATH
"${CMAKE_ROOT_DIR}/cmake/Modules"
"${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules")
include(GNUInstallDirs)
include(FeatureSummary)
include(CompilerSettings)
include(OMPLVersion)
include(OMPLUtils)
......@@ -55,7 +56,10 @@ else(IS_ICPC)
add_definitions(-DBOOST_TEST_DYN_LINK)
endif(IS_ICPC)
find_package(Boost 1.54 COMPONENTS serialization filesystem system program_options REQUIRED)
set_package_properties(Boost PROPERTIES
URL "http://boost.org"
PURPOSE "Used throughout OMPL for data serialization, graphs, etc.")
find_package(Boost 1.54 QUIET REQUIRED COMPONENTS serialization filesystem system program_options)
include_directories(${Boost_INCLUDE_DIR})
# Add support in Boost::Python for std::shared_ptr
......@@ -66,7 +70,7 @@ if(Boost_VERSION VERSION_LESS "106300")
endif()
# on OS X we need to check whether to use libc++ or libstdc++ with clang++
# on macOS we need to check whether to use libc++ or libstdc++ with clang++
if(APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
include(GetPrerequisites)
get_prerequisites("${Boost_SYSTEM_LIBRARY}" _libs 0 0 "/" "")
......@@ -83,43 +87,41 @@ if(APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
endif()
endif()
# pthread is sometimes needed, depending on OS / compiler
set_package_properties(Threads PROPERTIES
URL "https://en.wikipedia.org/wiki/POSIX_Threads"
PURPOSE "Pthreads is sometimes needed, depending on OS / compiler.")
find_package(Threads QUIET)
enable_testing()
set_package_properties(Python PROPERTIES
URL "http://python.org"
PURPOSE "Used for python bindings.")
find_package(Python QUIET)
find_boost_python()
if(PYTHON_FOUND)
# PyPy is more than an order of magnitude faster in generating the Python
# bindings than CPython, so use it if available.
find_program(PYPY NAMES pypy${PYTHON_VERSION_MAJOR} pypy)
if(PYPY)
option(OMPL_USE_PYPY "Use PyPy for generating Python bindings" ON)
else()
option(OMPL_USE_PYPY "Use PyPy for generating Python bindings" OFF)
endif()
if(OMPL_USE_PYPY)
set(PYTHON_BINDING_EXEC "${PYPY}")
else()
set(PYTHON_BINDING_EXEC "${PYTHON_EXEC}")
endif()
set_package_properties(pypy PROPERTIES
URL "http://pypy.org"
PURPOSE "Used to speed up the generation of python bindings.")
find_package(pypy QUIET)
endif()
# Eigen is needed for the InformedStateSampler
find_package(Eigen3 QUIET)
if (EIGEN3_FOUND)
set(OMPL_HAVE_EIGEN3 1)
include_directories("${EIGEN3_INCLUDE_DIR}")
endif()
set_package_properties(Eigen3 PROPERTIES
URL "http://eigen.tuxfamily.org"
PURPOSE "A linear algebra library used throughout OMPL.")
find_package(Eigen3 REQUIRED)
include_directories("${EIGEN3_INCLUDE_DIR}")
# MORSE is only needed for Modular OpenRobots Simulation Engine bindings
set_package_properties(MORSE PROPERTIES
URL "https://www.openrobots.org/wiki/morse"
PURPOSE "OMPL includes a plugin for the MORSE Robot Simulation engine.")
find_package(MORSE QUIET)
set(OMPL_EXTENSION_MORSE ${MORSE_FOUND})
# OpenDE is only needed for Open Dynamics Engine bindings
set_package_properties(OpenDE PROPERTIES
URL "http://ode.org"
PURPOSE "The Open Dynamics Engine can be used as a \"black box\" for kinodynamic planning.")
find_package(OpenDE QUIET)
set(OMPL_EXTENSION_OPENDE ${OPENDE_FOUND})
if (OPENDE_FOUND)
......@@ -127,13 +129,18 @@ if (OPENDE_FOUND)
include_directories(${OPENDE_INCLUDE_DIR})
endif()
set_package_properties(Triangle PROPERTIES
URL "http://www.cs.cmu.edu/~quake/triangle.html"
PURPOSE "Used to create triangular decompositions of polygonal 2D environments.")
find_package(Triangle QUIET)
set(OMPL_EXTENSION_TRIANGLE ${TRIANGLE_FOUND})
if (TRIANGLE_FOUND)
include_directories(${TRIANGLE_INCLUDE_DIR})
endif()
# If FLANN is installed, a wrapper for its nearest neighbor data structures can be used
set_package_properties(flann PROPERTIES
URL "https://github.com/mariusmuja/flann"
PURPOSE "If detetected, FLANN can be used for nearest neighbor queries by OMPL.")
find_package(flann 1.8.3 QUIET)
if (FLANN_FOUND)
set(OMPL_HAVE_FLANN 1)
......@@ -141,6 +148,28 @@ if (FLANN_FOUND)
link_directories(${FLANN_LIBRARY_DIRS})
endif()
set_package_properties(spot PROPERTIES
URL "http://spot.lrde.epita.fr"
PURPOSE "Used for constructing finite automata from LTL formulae.")
find_package(spot)
if (SPOT_FOUND)
set(OMPL_HAVE_SPOT 1)
include_directories("${SPOT_INCLUDE_DIRS}")
link_directories(${SPOT_LIBRARY_DIRS})
endif()
# Numpy is used to convert Eigen matrices/vectors to numpy arrays
if(PYTHON_FOUND AND NOT Boost_VERSION VERSION_LESS "106300")
find_python_module(numpy)
if (PY_NUMPY)
find_boost_numpy()
if(Boost_NUMPY_LIBRARY)
set(OMPL_HAVE_NUMPY 1)
include_directories("${PY_NUMPY}/core/include")
endif()
endif()
endif()
# R is needed for running Planner Arena locally
find_program(R_EXEC R)
......@@ -168,16 +197,16 @@ if (NOT ${CMAKE_VERSION} VERSION_LESS 2.8.8)
set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR})
set(LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR})
configure_package_config_file(omplConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/OMPLConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/omplConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/ompl/cmake
PATH_VARS INCLUDE_INSTALL_DIR LIB_INSTALL_DIR
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/OMPLConfigVersion.cmake
${CMAKE_CURRENT_BINARY_DIR}/omplConfigVersion.cmake
VERSION ${OMPL_VERSION}
COMPATIBILITY SameMajorVersion)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/OMPLConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/OMPLConfigVersion.cmake
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/omplConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/omplConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/ompl/cmake
COMPONENT ompl)
endif()
......@@ -212,3 +241,30 @@ if (OMPL_REGISTRATION)
endif()
endif()
endif()
# needed for ROS installation
if (EXISTS "package.xml")
# install catkin package.xml
install(FILES package.xml DESTINATION "share/ompl")
endif()
set_package_properties(PkgConfig PROPERTIES
URL "https://www.freedesktop.org/wiki/Software/pkg-config/"
PURPOSE "Used to find (compilation flags for) dependencies.")
set_package_properties(castxml PROPERTIES
URL "https://github.com/CastXML/CastXML"
PURPOSE "Used to generate Python bindings.")
feature_summary(DESCRIPTION INCLUDE_QUIET_PACKAGES WHAT ALL)
# additional feature info: show which Python modules were found and weren't found
get_property(PY_MODULES_FOUND GLOBAL PROPERTY PY_MODULES_FOUND)
if(PY_MODULES_FOUND)
list(REMOVE_DUPLICATES PY_MODULES_FOUND)
string(REPLACE ";" " " PY_MODULES_FOUND_STR "${PY_MODULES_FOUND}")
message(STATUS "The following Python modules were found:\n\n * ${PY_MODULES_FOUND_STR}\n")
endif()
get_property(PY_MODULES_NOTFOUND GLOBAL PROPERTY PY_MODULES_NOTFOUND)
if(PY_MODULES_NOTFOUND)
list(REMOVE_DUPLICATES PY_MODULES_NOTFOUND)
string(REPLACE ";" " " PY_MODULES_NOTFOUND_STR "${PY_MODULES_NOTFOUND}")
message(STATUS "The following Python modules were NOT found:\n\n * ${PY_MODULES_NOTFOUND_STR}\n")
endif()
......@@ -23,6 +23,7 @@ set(CPACK_COMPONENT_OMPL_REQUIRED TRUE)
set(CPACK_SOURCE_IGNORE_FILES
"/.hg"
"/.vscode"
"/build/"
".pyc$"
".pyo$"
......@@ -58,7 +59,7 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
OUTPUT_VARIABLE UBUNTU_RELEASE
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(CPACK_PACKAGE_FILE_NAME "omplapp_${OMPL_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}-Ubuntu${UBUNTU_RELEASE}")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "python${PYTHON_VERSION}, libboost-all-dev, libode-dev, libtriangle-dev")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "python${PYTHON_VERSION}, libboost-serialization-dev, libboost-filesystem-dev, libboost-system-dev, libboost-program-options-dev, libboost-test-dev, libode-dev, libtriangle-dev")
endif()
if(APPLE)
......
......@@ -17,12 +17,14 @@ if(CMAKE_COMPILER_IS_GNUCXX)
-Wcast-qual -Wwrite-strings -Wunreachable-code -Wpointer-arith
-Winit-self -Wredundant-decls
-Wno-unused-parameter -Wno-unused-function
-fext-numeric-literals)
-fext-numeric-literals
-Wno-noexcept-type
-Wno-deprecated-declarations)
# prepend optimizion flag (in case the default setting doesn't include one)
set(CMAKE_CXX_FLAGS_RELEASE "-O3 ${CMAKE_CXX_FLAGS_RELEASE}")
endif(CMAKE_COMPILER_IS_GNUCXX)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_definitions(-W -Wall -Wextra -Wno-missing-field-initializers -Wno-unused -Wno-unused-parameter -Wno-delete-non-virtual-dtor -Wno-overloaded-virtual -Wno-unknown-pragmas -Qunused-arguments -Wno-deprecated-register -Wno-mismatched-tags)
add_definitions(-W -Wall -Wextra -Wno-missing-field-initializers -Wno-unused -Wno-unused-parameter -Wno-delete-non-virtual-dtor -Wno-overloaded-virtual -Wno-unknown-pragmas -Qunused-arguments -Wno-deprecated-register -Wno-mismatched-tags -Wno-deprecated-declarations)
# prepend optimizion flag (in case the default setting doesn't include one)
set(CMAKE_CXX_FLAGS_RELEASE "-O3 ${CMAKE_CXX_FLAGS_RELEASE}")
endif()
......
......@@ -27,6 +27,12 @@
# If no output should be displayed about whether the module is found, use the
# QUIET argument:
# find_python_module(numpy QUIET)
#
# Finally, this module defines a number of macros:
# - find_boost_python(): Find the version of Boost.Python that matches the python interpreter
# - find_boost_numpy(): Find the version of Boost.Numpy that matches the python interpreter
# - install_python(PROGRAMS ...): Similar to install(PROGRAMS...), but replaces
# "#!/usr/bin/env python" with "#!${PYTHON_EXEC}"
include(FindPackageHandleStandardArgs)
......@@ -38,27 +44,15 @@ endif (NOT PYTHON_EXEC)
if (NOT PYTHON_EXEC)
find_program(PYTHON_EXEC "python${Python_FIND_VERSION}"
PATHS
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\3.6\\InstallPath]
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\3.5\\InstallPath]
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\3.4\\InstallPath]
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\3.3\\InstallPath]
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\3.2\\InstallPath]
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\3.1\\InstallPath]
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\3.0\\InstallPath]
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.7\\InstallPath]
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.6\\InstallPath]
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.5\\InstallPath]
DOC "Location of python executable to use")
endif(NOT PYTHON_EXEC)
# if Python is still not found, return
if (NOT PYTHON_EXEC)
# dummy function
function(find_python_module module)
return()
endfunction(find_python_module)
return()
endif()
# On OS X the python executable might be symlinked to the "real" location
# On macOS the python executable might be symlinked to the "real" location
# of the python executable. The header files and libraries are found relative
# to that path.
# For CMake 2.6 and below, the REALPATH option is included in the ABSOLUTE option
......@@ -72,15 +66,17 @@ set(PYTHON_EXEC "${PYTHON_EXEC_}" CACHE FILEPATH "Path to Python interpreter")
string(REGEX REPLACE "/bin/python.*" "" PYTHON_PREFIX "${PYTHON_EXEC_}")
string(REGEX REPLACE "/bin/python.*" "" PYTHON_PREFIX2 "${PYTHON_EXEC}")
execute_process(COMMAND "${PYTHON_EXEC}" "-c"
"import sys; print('%d;%d;%d' % (sys.version_info[0],sys.version_info[1],sys.version_info[2]))"
OUTPUT_VARIABLE PYTHON_VERSION_INFO
OUTPUT_STRIP_TRAILING_WHITESPACE)
list(GET PYTHON_VERSION_INFO 0 PYTHON_VERSION_MAJOR)
list(GET PYTHON_VERSION_INFO 1 PYTHON_VERSION_MINOR)
list(GET PYTHON_VERSION_INFO 2 PYTHON_VERSION_MICRO)
set(PYTHON_VERSION "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}")
set(PYTHON_VERSION_NO_DOTS "${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}")
if(PYTHON_EXEC)
execute_process(COMMAND "${PYTHON_EXEC}" "-c"
"import sys; print('%d;%d;%d' % (sys.version_info[0],sys.version_info[1],sys.version_info[2]))"
OUTPUT_VARIABLE PYTHON_VERSION_INFO
OUTPUT_STRIP_TRAILING_WHITESPACE)
list(GET PYTHON_VERSION_INFO 0 PYTHON_VERSION_MAJOR)
list(GET PYTHON_VERSION_INFO 1 PYTHON_VERSION_MINOR)
list(GET PYTHON_VERSION_INFO 2 PYTHON_VERSION_MICRO)
set(PYTHON_VERSION "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}")
set(PYTHON_VERSION_NO_DOTS "${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}")
endif()
find_library(PYTHON_LIBRARIES
NAMES "python${PYTHON_VERSION_NO_DOTS}" "python${PYTHON_VERSION}" "python${PYTHON_VERSION}m"
......@@ -122,7 +118,7 @@ function(find_python_module module)
set(_minversion ${ARGV1})
endif()
endif()
if(NOT PY_${module_upper})
if(PYTHON_EXEC AND NOT PY_${module_upper})
# A module's location is usually a directory, but for binary modules
# it's a .so file.
if (_minversion STREQUAL "")
......@@ -161,8 +157,13 @@ function(find_python_module module)
endif()
endif(NOT _status)
endif (_minversion STREQUAL "")
endif(NOT PY_${module_upper})
endif(PYTHON_EXEC AND NOT PY_${module_upper})
find_package_handle_standard_args(PY_${module} DEFAULT_MSG PY_${module_upper})
if(PY_${module_upper})
set_property(GLOBAL APPEND PROPERTY PY_MODULES_FOUND "${module}")
else()
set_property(GLOBAL APPEND PROPERTY PY_MODULES_NOTFOUND "${module}")
endif()
endfunction(find_python_module)
# macro to attempt to find the *correct* Boost.Python library (i.e., the
......@@ -172,6 +173,7 @@ macro(find_boost_python)
if (PYTHON_FOUND)
foreach(_bp_libname
"python-py${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}"
"python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}"
"python${PYTHON_VERSION_MAJOR}" "python")
string(TOUPPER ${_bp_libname} _bp_upper)
set(_Boost_${_bp_upper}_HEADERS "boost/python.hpp")
......@@ -185,6 +187,43 @@ macro(find_boost_python)
endif()
endmacro(find_boost_python)
# macro to attempt to find the *correct* Boost.Numpy library (i.e., the
# one that matches the version number of the python interpreter that was
# found).
macro(find_boost_numpy)
if (PYTHON_FOUND)
foreach(_bn_libname
"numpy${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}"
"numpy${PYTHON_VERSION_MAJOR}" "numpy")
string(TOUPPER ${_bn_libname} _bn_upper)
set(_Boost_${_bn_upper}_HEADERS "boost/numpy.hpp")
find_package(Boost COMPONENTS ${_bn_libname} QUIET)
set(_bnlib "${Boost_${_bn_upper}_LIBRARY}")
if (_bnlib)
set(Boost_NUMPY_LIBRARY "${_bnlib}")
break()
endif()
endforeach()