Skip to content
Snippets Groups Projects
Commit 785625f6 authored by Studer Gabriel's avatar Studer Gabriel
Browse files

Merge branch 'release-4.2.0'

parents 7a92ceff 6ca236b0
Branches
Tags 4.2.0
No related merge requests found
Changes in Release 4.2.0
--------------------------------------------------------------------------------
* Detect Boost and Python using functionality provided by CMake instead of our
own code. You might have to adapt CMake flags when building QMEAN to
variables specified here:
https://cmake.org/cmake/help/latest/module/FindPython.html
* Several minor bug fixes, improvements
Changes in Release 4.1.0 Changes in Release 4.1.0
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
......
...@@ -11,7 +11,7 @@ cmake_minimum_required(VERSION 3.12.1 FATAL_ERROR) ...@@ -11,7 +11,7 @@ cmake_minimum_required(VERSION 3.12.1 FATAL_ERROR)
cmake_policy(SET CMP0060 NEW) cmake_policy(SET CMP0060 NEW)
set (QMEAN_VERSION_MAJOR 4) set (QMEAN_VERSION_MAJOR 4)
set (QMEAN_VERSION_MINOR 1) set (QMEAN_VERSION_MINOR 2)
set (QMEAN_VERSION_PATCH 0) set (QMEAN_VERSION_PATCH 0)
set (QMEAN_VERSION_STRING ${QMEAN_VERSION_MAJOR}.${QMEAN_VERSION_MINOR}.${QMEAN_VERSION_PATCH} ) set (QMEAN_VERSION_STRING ${QMEAN_VERSION_MAJOR}.${QMEAN_VERSION_MINOR}.${QMEAN_VERSION_PATCH} )
...@@ -64,50 +64,20 @@ file(MAKE_DIRECTORY ${STAGE_DIR} ${HEADER_STAGE_PATH} ${LIB_STAGE_PATH}) ...@@ -64,50 +64,20 @@ file(MAKE_DIRECTORY ${STAGE_DIR} ${HEADER_STAGE_PATH} ${LIB_STAGE_PATH})
setup_compiler_flags() setup_compiler_flags()
# Python needed before Boost # Python needed before Boost
find_package(Python 3.6.0 REQUIRED) find_package(Python 3.6 REQUIRED COMPONENTS Interpreter Development)
# Split version string # Split version string
string(REPLACE "." ";" _python_version_list ${PYTHON_VERSION}) string(REPLACE "." ";" _python_version_list ${Python_VERSION})
list(GET _python_version_list 0 PYTHON_VERSION_MAJOR) list(GET _python_version_list 0 Python_VERSION_MAJOR)
list(GET _python_version_list 1 PYTHON_VERSION_MINOR) list(GET _python_version_list 1 Python_VERSION_MINOR)
# where Python modules live
find_package(OPENSTRUCTURE 2.1.0 REQUIRED set(PYTHON_MODULE_PATH "python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages/")
COMPONENTS mol seq seq_alg mol_alg conop)
setup_boost()
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY)
set(_BOOST_MIN_VERSION 1.53) find_package(OPENSTRUCTURE 2.2.0 REQUIRED
find_package(Boost ${_BOOST_MIN_VERSION} COMPONENTS mol seq seq_alg mol_alg conop db)
COMPONENTS filesystem iostreams system REQUIRED)
set(BOOST_LIBRARIES ${Boost_LIBRARIES})
set(Boost_LIBRARIES)
find_package(Boost ${_BOOST_MIN_VERSION}
COMPONENTS unit_test_framework REQUIRED)
set(BOOST_UNIT_TEST_LIBRARIES ${Boost_LIBRARIES})
set(Boost_LIBRARIES)
# starting with CMake 3.11 we could use the following instead of the foreach
# find_package(Boost ${_BOOST_MIN_VERSION} COMPONENTS
# python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR} REQUIRED)
# set(BOOST_PYTHON_LIBRARIES ${Boost_LIBRARIES})
# see https://cmake.org/cmake/help/v3.11/module/FindBoost.html
foreach(_python_lib_name python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}
python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}
python${PYTHON_VERSION_MAJOR}
python)
find_package(Boost ${_BOOST_MIN_VERSION} COMPONENTS ${_python_lib_name} QUIET)
if(Boost_FOUND)
message(STATUS "Found Boost package: " ${_python_lib_name})
set(BOOST_PYTHON_LIBRARIES ${Boost_LIBRARIES})
break()
else()
message(STATUS "Boost package not found: " ${_python_lib_name}
". Trying alternative names!")
endif()
endforeach(_python_lib_name)
if(NOT BOOST_PYTHON_LIBRARIES)
message(FATAL_ERROR "Failed to find any Boost Python library!")
endif()
set(Boost_LIBRARIES)
include_directories(${Boost_INCLUDE_DIRS} include_directories(${Boost_INCLUDE_DIRS}
${OST_INCLUDE_DIR}) ${OST_INCLUDE_DIR})
add_subdirectory(data) add_subdirectory(data)
......
This diff is collapsed.
...@@ -27,7 +27,7 @@ macro(find_OPENSTRUCTURE OST_ROOT HEADER_NAMES PYMOD_NAME) ...@@ -27,7 +27,7 @@ macro(find_OPENSTRUCTURE OST_ROOT HEADER_NAMES PYMOD_NAME)
set(FOUND_LIB FOUND_LIB-NOTFOUND) set(FOUND_LIB FOUND_LIB-NOTFOUND)
find_library(FOUND_LIB find_library(FOUND_LIB
NAMES ost_${LIB} NAMES ost_${LIB}
HINTS "${PYTHON_ROOT}" HINTS "${Python_ROOT_DIR}"
PATH ${OST_ROOT} PATH ${OST_ROOT}
PATH_SUFFIXES lib lib64 PATH_SUFFIXES lib lib64
NO_SYSTEM_ENVIRONMENT_PATH NO_DEFAULT_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_DEFAULT_PATH
......
#-------------------------------------------------------------------------------
# Check for Python Libraries
#
# PYTHON_IGNORE_FRAMEWORKS if set, do not check for python frameworks.
# has meaning on MacOS X only
# PYTHON_ROOT Prefix for python libraries
# PYTHON_MIN_VERSION minimal python version required
#
# When Python is found, the result is placed in the following variables:
#
# PYTHON_LIBRARIES is set to the library and linker flags used to
# link against python
# PYTHON_VERSION is set to the version of python
# PYTHON_INCLUDE_PATH is set to the path that contains Python.h
# PYTHON_BINARY is set to the path to the python executable
# PYTHON_MODULE_PATH is set as path-component where modules should live
#
# Author: Marco Biasini/ Stefan Bienert
#-------------------------------------------------------------------------------
set(PYTHON_VERSIONS 3.8 3.7 3.6 )
set(PYTHON_MIN_VERSION 3.6.0)
#-------------------------------------------------------------------------------
# check for python framework
# this macro honours the values of PYTHON_ROOT
#-------------------------------------------------------------------------------
macro(check_for_python_framework)
set(_FRAMEWORK_SEARCH_PATHS /Library/Frameworks/ /System/Library/Frameworks)
if(PYTHON_ROOT)
set(_FRAMEWORK_SEARCH_PATHS ${PYTHON_ROOT}/Library/Frameworks)
endif()
foreach(_PATH ${_FRAMEWORK_SEARCH_PATHS})
set(_FULL_FRAMEWORK_NAME "${_PATH}/Python.framework")
if(EXISTS ${_FULL_FRAMEWORK_NAME})
set(PYTHON_FRAMEWORK ON)
set(PYTHON_INCLUDE_PATH "${_FULL_FRAMEWORK_NAME}/Headers")
set(PYTHON_FRAMEWORK_PATH "${_FULL_FRAMEWORK_NAME}/Python")
endif()
endforeach()
endmacro()
macro(_find_python PYTHON_ROOT VERSION)
string(REPLACE "." "" _VERSION_NO_DOTS "${VERSION}")
if(PYTHON_ROOT)
find_library(PYTHON_LIBRARIES
NAMES "python${_VERSION_NO_DOTS}" "python${VERSION}"
"python${_VERSION_NO_DOTS}m" "python${VERSION}m"
HINTS "${PYTHON_ROOT}"
PATH_SUFFIXES lib libs
NO_SYSTEM_ENVIRONMENT_PATH NO_DEFAULT_PATH
)
find_path(PYTHON_INCLUDE_PATH
NAMES Python.h
HINTS "${PYTHON_ROOT}/include"
PATH_SUFFIXES include "python${_VERSION_NO_DOTS}" "python${VERSION}"
"python${_VERSION_NO_DOTS}m" "python${VERSION}m"
NO_SYSTEM_ENVIRONMENT_PATH NO_DEFAULT_PATH
)
else()
find_library(PYTHON_LIBRARIES
NAMES "python${_VERSION_NO_DOTS}" "python${VERSION}"
"python${_VERSION_NO_DOTS}m" "python${VERSION}m"
PATH_SUFFIXES lib
)
find_path(PYTHON_INCLUDE_PATH
NAMES Python.h
PATH_SUFFIXES include "python${_VERSION_NO_DOTS}" "python${VERSION}"
"python${_VERSION_NO_DOTS}m" "python${VERSION}m"
)
endif()
endmacro()
macro(_find_python_bin PYTHON_ROOT VERSION)
string(REPLACE "." "" _VERSION_NO_DOTS "${VERSION}")
if(PYTHON_ROOT)
find_program(PYTHON_BINARY
NAMES "python${_VERSION_NO_DOTS}" "python${VERSION}" python.exe
HINTS "${PYTHON_ROOT}"
PATH_SUFFIXES bin
NO_SYSTEM_ENVIRONMENT_PATH NO_DEFAULT_PATH
)
else()
find_program(PYTHON_BINARY
NAMES "python${_VERSION_NO_DOTS}" "python${VERSION}"
HINTS "${CMAKE_PREFIX_PATH}"
PATH_SUFFIXES bin
)
endif()
endmacro()
#-------------------------------------------------------------------------------
# check for python lib
#
# this macro honours the values of PYTHON_ROOT and PYTHON_VERSION
#-------------------------------------------------------------------------------
macro(check_for_python_lib)
if(PYTHON_VERSION)
_find_python("${PYTHON_ROOT}" "${PYTHON_VERSION}")
else()
foreach(_VERSION ${PYTHON_VERSIONS})
if((${PYTHON_MIN_VERSION} VERSION_LESS ${_VERSION}) OR
(${PYTHON_MIN_VERSION} VERSION_EQUAL ${_VERSION}))
_find_python("${PYTHON_ROOT}" "${_VERSION}")
if(PYTHON_LIBRARIES)
set(PYTHON_VERSION "${_VERSION}")
break()
endif()
endif()
endforeach()
endif()
# fallback to non-versioned naming scheme
if (NOT $PYTHON_LIBRARIES)
_find_python("${PYTHON_ROOT}" "")
endif()
endmacro()
macro(check_for_python_binary)
if(PYTHON_VERSION)
_find_python_bin("${PYTHON_ROOT}" "${PYTHON_VERSION}")
else()
foreach(_VERSION ${PYTHON_VERSIONS})
if((${PYTHON_MIN_VERSION} VERSION_LESS ${_VERSION}) OR
(${PYTHON_MIN_VERSION} VERSION_EQUAL ${_VERSION}))
_find_python_bin("${PYTHON_ROOT}" "${_VERSION}")
if(PYTHON_BINARY)
set(PYTHON_VERSION "${_VERSION}")
# disallow all versions except for the one we just found. This makes
# sure we don't mismatch the python binary and the libraries.
set(PYTHON_VERSIONS "${_VERSION}")
break()
endif()
endif()
endforeach()
endif()
if (NOT PYTHON_BINARY)
_find_python("${PYTHON_ROOT}" "")
endif()
endmacro()
if(NOT PYTHON_ROOT)
if(WIN32)
set(PYTHON_ROOT "${CMAKE_PREFIX_PATH}")
else()
set(PYTHON_ROOT "/usr")
endif()
endif()
if(APPLE AND NOT PYTHON_IGNORE_FRAMEWORKS)
check_for_python_framework()
endif()
# first check for python binary.
check_for_python_binary()
if(NOT PYTHON_FRAMEWORK_FOUND)
check_for_python_lib()
endif()
set(PYTHON_MODULE_PATH "python${PYTHON_VERSION}/site-packages/")
mark_as_advanced(
PYTHON_LIBRARIES
PYTHON_INCLUDE_PATH
PYTHON_VERSION
PYTHON_BINARY
PYTHON_MODULE_PATH
)
if(PYTHON_LIBRARIES)
if(PYTHON_FRAMEWORK)
set(PYTHON_LIBRARIES "${PYTHON_FRAMEWORK_PATH}"
CACHE FILEPATH "Python Libraries" FORCE)
else()
set(PYTHON_LIBRARIES "${PYTHON_LIBRARIES}"
CACHE FILEPATH "Python Libraries" FORCE)
endif()
set(PYTHON_INCLUDE_PATH "${PYTHON_INCLUDE_PATH}"
CACHE FILEPATH "Python Include Path" FORCE)
endif()
if (PYTHON_BINARY)
set(PYTHON_VERSION "${PYTHON_VERSION}"
CACHE STRING "Python Version" FORCE)
set(PYTHON_BINARY "${PYTHON_BINARY}"
CACHE FILEPATH "Python Binary" FORCE)
endif()
...@@ -83,7 +83,7 @@ macro(compile_py_files module out_dir compiled_files_name) ...@@ -83,7 +83,7 @@ macro(compile_py_files module out_dir compiled_files_name)
get_filename_component(_in_name ${input_file} NAME) get_filename_component(_in_name ${input_file} NAME)
file(MAKE_DIRECTORY ${out_dir}) file(MAKE_DIRECTORY ${out_dir})
add_custom_command(TARGET ${module} add_custom_command(TARGET ${module}
COMMAND ${PYTHON_BINARY} -c "import py_compile;py_compile.compile(\"${_in_file}\",\"${_out_file}\",\"${_in_name}\",doraise=True)" COMMAND ${Python_EXECUTABLE} -c "import py_compile;py_compile.compile(\"${_in_file}\",\"${_out_file}\",\"${_in_name}\",doraise=True)"
VERBATIM DEPENDS ${input_file} VERBATIM DEPENDS ${input_file}
) )
endforeach() endforeach()
...@@ -467,7 +467,7 @@ macro(pymod) ...@@ -467,7 +467,7 @@ macro(pymod)
set(PYMOD_STAGE_DIR "${LIB_STAGE_PATH}/${PYMOD_DIR}") set(PYMOD_STAGE_DIR "${LIB_STAGE_PATH}/${PYMOD_DIR}")
file(MAKE_DIRECTORY ${PYMOD_STAGE_DIR}) file(MAKE_DIRECTORY ${PYMOD_STAGE_DIR})
include_directories(${PYTHON_INCLUDE_PATH}) include_directories(${Python_INCLUDE_DIRS})
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# compile and link C++ wrappers # compile and link C++ wrappers
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
...@@ -487,7 +487,7 @@ macro(pymod) ...@@ -487,7 +487,7 @@ macro(pymod)
endif() endif()
target_link_libraries("_${_LIB_NAME}" ${_PARENT_LIB_NAME} target_link_libraries("_${_LIB_NAME}" ${_PARENT_LIB_NAME}
${PYTHON_LIBRARIES} ${BOOST_PYTHON_LIBRARIES}) ${Python_LIBRARIES} ${BOOST_PYTHON_LIBRARIES})
set_target_properties("_${_LIB_NAME}" set_target_properties("_${_LIB_NAME}"
PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PYMOD_STAGE_DIR}) PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PYMOD_STAGE_DIR})
...@@ -603,7 +603,7 @@ add_dependencies(check codetest) ...@@ -603,7 +603,7 @@ add_dependencies(check codetest)
# #
# Set variable VAR (in parent scope) to an updated PYTHONPATH env. variable # Set variable VAR (in parent scope) to an updated PYTHONPATH env. variable
# which includes OST path. This can then be used to call python scripts # which includes OST path. This can then be used to call python scripts
# with commands such as: sh -c "PYTHONPATH=${VAR} ${PYTHON_BINARY} ..." # with commands such as: sh -c "PYTHONPATH=${VAR} ${Python_EXECUTABLE} ..."
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
macro(get_python_path VAR) macro(get_python_path VAR)
set(${VAR} $ENV{PYTHONPATH}) set(${VAR} $ENV{PYTHONPATH})
...@@ -728,7 +728,7 @@ macro(qmean_unittest) ...@@ -728,7 +728,7 @@ macro(qmean_unittest)
get_python_path(python_path) get_python_path(python_path)
set (PY_TESTS_CMD "PYTHONPATH=${python_path} QMEAN_PYTHON_BINARY=${PYTHON_BINARY} ${PYTHON_BINARY}") set (PY_TESTS_CMD "PYTHONPATH=${python_path} QMEAN_PYTHON_BINARY=${Python_EXECUTABLE} ${Python_EXECUTABLE}")
add_custom_target("${py_test}_run" add_custom_target("${py_test}_run"
sh -c "${PY_TESTS_CMD} ${py_twp}" sh -c "${PY_TESTS_CMD} ${py_twp}"
...@@ -763,7 +763,7 @@ endmacro(qmean_unittest) ...@@ -763,7 +763,7 @@ endmacro(qmean_unittest)
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
macro(qmean_find_python_module MODULE) macro(qmean_find_python_module MODULE)
if (NOT PYTHON_MODULE_${MODULE}) if (NOT PYTHON_MODULE_${MODULE})
execute_process(COMMAND ${PYTHON_BINARY} -c "import ${MODULE}" execute_process(COMMAND ${Python_EXECUTABLE} -c "import ${MODULE}"
OUTPUT_QUIET ERROR_QUIET OUTPUT_QUIET ERROR_QUIET
RESULT_VARIABLE _IMPORT_ERROR) RESULT_VARIABLE _IMPORT_ERROR)
if (_IMPORT_ERROR) if (_IMPORT_ERROR)
...@@ -798,7 +798,7 @@ macro(qmean_match_boost_python_version) ...@@ -798,7 +798,7 @@ macro(qmean_match_boost_python_version)
list(GET _BOOST_PYTHON_LIBRARY ${_LIB_INDEX} _BP_LIB_PATH) list(GET _BOOST_PYTHON_LIBRARY ${_LIB_INDEX} _BP_LIB_PATH)
set(_BOOST_PYTHON_LIBRARY ${_BP_LIB_PATH}) set(_BOOST_PYTHON_LIBRARY ${_BP_LIB_PATH})
endif() endif()
set(CMAKE_REQUIRED_FLAGS "-I${PYTHON_INCLUDE_PATH} -I${Boost_INCLUDE_DIR} ${PYTHON_LIBRARIES} ${_BOOST_PYTHON_LIBRARY}") set(CMAKE_REQUIRED_FLAGS "-I${Python_INCLUDE_DIRS} -I${Boost_INCLUDE_DIR} ${Python_LIBRARIES} ${_BOOST_PYTHON_LIBRARY}")
check_cxx_source_runs( check_cxx_source_runs(
"#include <boost/python.hpp> "#include <boost/python.hpp>
...@@ -932,3 +932,34 @@ macro(setup_compiler_flags) ...@@ -932,3 +932,34 @@ macro(setup_compiler_flags)
endif() endif()
endmacro(setup_compiler_flags) endmacro(setup_compiler_flags)
set(_BOOST_MIN_VERSION 1.53)
macro(setup_boost)
# starting with CMake 3.11 we could use the following instead of the foreach
# find_package(Boost ${_BOOST_MIN_VERSION} COMPONENTS
# python${Python_VERSION_MAJOR}${Python_VERSION_MINOR} REQUIRED)
# set(BOOST_PYTHON_LIBRARIES ${Boost_LIBRARIES})
# see https://cmake.org/cmake/help/v3.11/module/FindBoost.html
foreach(_python_lib_name python${Python_VERSION_MAJOR}${Python_VERSION_MINOR}
python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}
python${Python_VERSION_MAJOR}
python)
find_package(Boost ${_BOOST_MIN_VERSION} COMPONENTS ${_python_lib_name} QUIET)
if(Boost_FOUND)
message(STATUS "Found Boost package: " ${_python_lib_name})
set(BOOST_PYTHON_LIBRARIES ${Boost_LIBRARIES})
break()
else()
message(STATUS "Boost package not found: " ${_python_lib_name}
". Trying alternative names!")
endif()
endforeach(_python_lib_name)
if(NOT BOOST_PYTHON_LIBRARIES)
message(FATAL_ERROR "Failed to find any Boost Python library!")
endif()
set(Boost_LIBRARIES)
find_package(Boost ${_BOOST_MIN_VERSION}
COMPONENTS filesystem system REQUIRED)
set(BOOST_LIBRARIES ${Boost_LIBRARIES})
endmacro(setup_boost)
...@@ -70,9 +70,9 @@ copyright = u'2016-2020, Gabriel Studer' ...@@ -70,9 +70,9 @@ copyright = u'2016-2020, Gabriel Studer'
# built documents. # built documents.
# #
# The short X.Y version. # The short X.Y version.
release = '4.1.0' release = '4.2.0'
# The full version, including alpha/beta/rc tags. # The full version, including alpha/beta/rc tags.
release = '4.1.0' release = '4.2.0'
# The language for content autogenerated by Sphinx. Refer to documentation # The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages. # for a list of supported languages.
......
...@@ -61,15 +61,6 @@ CMake in there by giving it the path to your OpenStructure installation ...@@ -61,15 +61,6 @@ CMake in there by giving it the path to your OpenStructure installation
cd build cd build
cmake ../ -DOST_ROOT=path_to_ost_build/stage -DOPTIMIZE=1 cmake ../ -DOST_ROOT=path_to_ost_build/stage -DOPTIMIZE=1
If you're working on a Debian based system, cmake might have trouble
to find the appropriate Python library. This can manually be specified.
Following additional cmake flag does the job on Ubuntu 18.04 and
Debian 9, you might have to adapt if your Python version differs:
.. code-block:: bash
-DPYTHON_LIBRARIES=/usr/lib/x86_64-linux-gnu/libpython3.6m.so
build and run unit tests: build and run unit tests:
.. code-block:: bash .. code-block:: bash
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include <vector> #include <vector>
#include <ost/geom/vec3.hh> #include <ost/geom/vec3.hh>
#include <boost/shared_ptr.hpp>
namespace qmean { namespace qmean {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment