Skip to content

Commit

Permalink
Squashed 'modules/rmf/dependency/RMF/' changes from 8e289687e5..312f7…
Browse files Browse the repository at this point in the history
…8eb95

312f78eb95 Don't force-set Python cache variables
ffd3ff3704 Any newer version of HDF5 should work
58637b4811 We now require Python 3
99d3cdeb8e Update minimum CMake version to 3.14

git-subtree-dir: modules/rmf/dependency/RMF
git-subtree-split: 312f78eb95285e4ec8662b98098798b9c013b8ac
  • Loading branch information
benmwebb committed Nov 14, 2024
1 parent 87506e6 commit 6cf53a0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 90 deletions.
2 changes: 1 addition & 1 deletion modules/rmf/dependency/RMF/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8.12...3.6.0)
cmake_minimum_required(VERSION 3.14.0)
project(RMF)

# needs to be in main CMakeLists.txt
Expand Down
100 changes: 17 additions & 83 deletions modules/rmf/dependency/RMF/cmake_modules/IMPFindPython.cmake
Original file line number Diff line number Diff line change
@@ -1,88 +1,22 @@
# Like cmake's FindPython but allows the user to override; should also
# work (to some degree) with older cmake
# Like cmake's FindPython but allows the user to override
function(imp_find_python)
if (${CMAKE_VERSION} VERSION_LESS "3.14.0")
message(WARNING "Using old Python detection logic. Recommended to upgrade to cmake 3.14.0 or later")
if(NOT DEFINED PYTHON_INCLUDE_DIRS)
set(_SEARCH_PYTHON_BINARIES python3 python)

foreach(pybinary ${_SEARCH_PYTHON_BINARIES})
execute_process(COMMAND ${pybinary} -c "import sys; print(sys.executable)"
RESULT_VARIABLE retval
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
OUTPUT_VARIABLE python_full_path
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(${retval} EQUAL 0)
break()
endif()
endforeach()

if(NOT ${retval} EQUAL 0)
message(FATAL_ERROR "Could not find a suitable Python binary - looked for ${_SEARCH_PYTHON_BINARIES}")
endif()
set(PYTHON_EXECUTABLE ${python_full_path} CACHE INTERNAL "" FORCE)
set(PYTHON_TEST_EXECUTABLE ${python_full_path} CACHE STRING "")
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import sys; print('%d.%d.%d' % sys.version_info[:3])"
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
OUTPUT_VARIABLE python_full_version
OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REGEX REPLACE "^([0-9])+\\.[0-9]+.*" "\\1" major
"${python_full_version}")
string(REGEX REPLACE "^[0-9]+\\.([0-9]+).*" "\\1" minor
"${python_full_version}")
string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" patch
"${python_full_version}")
set(PYTHON_VERSION ${python_full_version} CACHE INTERNAL "" FORCE)
set(PYTHON_VERSION_MAJOR ${major} CACHE INTERNAL "" FORCE)
set(PYTHON_VERSION_MINOR ${minor} CACHE INTERNAL "" FORCE)
set(PYTHON_VERSION_PATCH ${patch} CACHE INTERNAL "" FORCE)
message(STATUS "Python binary is " ${python_full_path} " (version " ${python_full_version} ")")
if(${major} EQUAL 2)
message(FATAL_ERROR "Only Python 2 was found; Python 3 is required to build")
endif()

find_package(PythonLibs ${python_full_version} EXACT REQUIRED)
# Make sure PYTHON_INCLUDE_DIRS is in the cache so it can be
# used elsewhere
set(PYTHON_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS} CACHE INTERNAL "")
endif()
if(NOT DEFINED PYTHON_NUMPY_INCLUDE_DIR)
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c
"try: import numpy; print(numpy.get_include());\nexcept: pass"
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
OUTPUT_VARIABLE __numpy_path
OUTPUT_STRIP_TRAILING_WHITESPACE)
find_path(PYTHON_NUMPY_INCLUDE_DIR numpy/arrayobject.h
HINTS "${__numpy_path}" "${PYTHON_INCLUDE_PATH}"
NO_DEFAULT_PATH)
if(PYTHON_NUMPY_INCLUDE_DIR)
set(PYTHON_NUMPY_FOUND 1 CACHE INTERNAL "Python numpy found")
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(NumPy
REQUIRED_VARS PYTHON_NUMPY_INCLUDE_DIR
VERSION_VAR __numpy_version)
endif()
find_package(Python3 COMPONENTS Interpreter Development NumPy)

if(Python3_Interpreter_FOUND AND Python3_Development_FOUND)
# Use Python 3 tools
set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE} CACHE STRING "")
set(PYTHON_TEST_EXECUTABLE ${Python3_EXECUTABLE} CACHE STRING "")
set(PYTHON_LIBRARIES ${Python3_LIBRARIES} CACHE STRING "")
set(PYTHON_INCLUDE_DIRS ${Python3_INCLUDE_DIRS} CACHE STRING "")
set(PYTHON_LIBRARY_DIRS ${Python3_LIBRARY_DIRS} CACHE STRING "")
set(PYTHON_NUMPY_FOUND ${Python3_NumPy_FOUND} CACHE STRING "")
set(PYTHON_NUMPY_INCLUDE_DIR ${Python3_NumPy_INCLUDE_DIRS}
CACHE STRING "")
set(PYTHON_VERSION ${Python3_VERSION} CACHE STRING "")
set(PYTHON_VERSION_MAJOR ${Python3_VERSION_MAJOR} CACHE STRING "")
set(PYTHON_VERSION_MINOR ${Python3_VERSION_MINOR} CACHE STRING "")
set(PYTHON_VERSION_PATCH ${Python3_VERSION_PATCH} CACHE STRING "")
else()
find_package(Python3 COMPONENTS Interpreter Development NumPy)

if(Python3_Interpreter_FOUND AND Python3_Development_FOUND)
# Use Python 3 tools
set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE} CACHE INTERNAL "" FORCE)
set(PYTHON_TEST_EXECUTABLE ${Python3_EXECUTABLE} CACHE STRING "")
set(PYTHON_LIBRARIES ${Python3_LIBRARIES} CACHE INTERNAL "" FORCE)
set(PYTHON_INCLUDE_DIRS ${Python3_INCLUDE_DIRS} CACHE INTERNAL "" FORCE)
set(PYTHON_LIBRARY_DIRS ${Python3_LIBRARY_DIRS} CACHE INTERNAL "" FORCE)
set(PYTHON_NUMPY_FOUND ${Python3_NumPy_FOUND} CACHE INTERNAL "" FORCE)
set(PYTHON_NUMPY_INCLUDE_DIR ${Python3_NumPy_INCLUDE_DIRS}
CACHE INTERNAL "" FORCE)
set(PYTHON_VERSION ${Python3_VERSION} CACHE INTERNAL "" FORCE)
set(PYTHON_VERSION_MAJOR ${Python3_VERSION_MAJOR} CACHE INTERNAL "" FORCE)
set(PYTHON_VERSION_MINOR ${Python3_VERSION_MINOR} CACHE INTERNAL "" FORCE)
set(PYTHON_VERSION_PATCH ${Python3_VERSION_PATCH} CACHE INTERNAL "" FORCE)
else()
message(FATAL_ERROR "Could not find a Python interpreter and matching headers/libraries. Python is required to build.")
endif()
message(FATAL_ERROR "Could not find a Python interpreter and matching headers/libraries. Python is required to build.")
endif()
endfunction(imp_find_python)
10 changes: 4 additions & 6 deletions modules/rmf/dependency/RMF/doc/Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,15 @@ IMP: Download an IMP binary (which includes RMF) from the

In order to build from source, you will need:

- [CMake](https://cmake.org) (2.8.12 or later; 3.14 or later is recommended)
- [CMake](https://cmake.org) (3.14 or later)
- [Boost](https://www.boost.org) (1.53 or later; Boost.Iostreams must be built
with its [zlib filter enabled](https://www.boost.org/doc/libs/1_67_0/libs/iostreams/doc/installation.html))
- [Python](https://www.python.org) (2.7 or later, or any version of Python 3)
- [SWIG](http://www.swig.org) (1.3.40 or later; 2.0.4 or later is needed
if you want to use Python 3)
- [Python](https://www.python.org) (3.6 or later)
- [SWIG](http://www.swig.org) (2.0.4 or later)

If you want to be able to read older format RMF files, you will also need:

- [HDF5](https://www.hdfgroup.org/solutions/hdf5/) (1.8 or later; 1.10 or 1.12
should also work)
- [HDF5](https://www.hdfgroup.org/solutions/hdf5/) (1.8 or later)

## Download {#installation_download}

Expand Down

0 comments on commit 6cf53a0

Please sign in to comment.