-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from GEOS-ESM/feature/mathomp4/f2py-and-latex-…
…cmake-fixes Fixes for f2py and imagemagick
- Loading branch information
Showing
5 changed files
with
135 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# MAT This code is based, loosely, on the FindF2PY.cmake file from scikit | ||
#.rst: | ||
# | ||
# The purpose of the F2PY –Fortran to Python interface generator– project is to provide a | ||
# connection between Python and Fortran languages. | ||
# | ||
# F2PY is a Python package (with a command line tool f2py and a module f2py2e) that facilitates | ||
# creating/building Python C/API extension modules that make it possible to call Fortran 77/90/95 | ||
# external subroutines and Fortran 90/95 module subroutines as well as C functions; to access Fortran | ||
# 77 COMMON blocks and Fortran 90/95 module data, including allocatable arrays from Python. | ||
# | ||
# For more information on the F2PY project, see http://www.f2py.com/. | ||
# | ||
# The following variables are defined: | ||
# | ||
# :: | ||
# | ||
# F2PY_EXECUTABLE - absolute path to the F2PY executable | ||
# | ||
# :: | ||
# | ||
# F2PY_VERSION_STRING - the version of F2PY found | ||
# F2PY_VERSION_MAJOR - the F2PY major version | ||
# F2PY_VERSION_MINOR - the F2PY minor version | ||
# F2PY_VERSION_PATCH - the F2PY patch version | ||
# | ||
# | ||
# .. note:: | ||
# | ||
# By default, the module finds the F2PY program associated with the installed NumPy package. | ||
# | ||
|
||
# Path to the f2py executable | ||
find_package(Python COMPONENTS Interpreter) | ||
|
||
find_program(F2PY_EXECUTABLE NAMES "f2py${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}" | ||
"f2py-${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}" | ||
"f2py${Python_VERSION_MAJOR}" | ||
"f2py" | ||
) | ||
|
||
if(F2PY_EXECUTABLE) | ||
# extract the version string | ||
execute_process(COMMAND "${F2PY_EXECUTABLE}" -v | ||
OUTPUT_VARIABLE F2PY_VERSION_STRING | ||
OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
if("${F2PY_VERSION_STRING}" MATCHES "^([0-9]+)(.([0-9+]))?(.([0-9+]))?$") | ||
set(F2PY_VERSION_MAJOR "${CMAKE_MATCH_1}") | ||
set(F2PY_VERSION_MINOR "${CMAKE_MATCH_3}") | ||
set(F2PY_VERSION_PATCH "${CMAKE_MATCH_5}") | ||
endif() | ||
|
||
# Now we need to test if we can actually use f2py and what its suffix is | ||
|
||
include(try_f2py_compile) | ||
try_f2py_compile( | ||
${CMAKE_CURRENT_LIST_DIR}/check_compiler_support/test.F90 | ||
DETECT_F2PY_SUFFIX | ||
) | ||
|
||
endif () | ||
|
||
# handle the QUIET and REQUIRED arguments and set F2PY_FOUND to TRUE if | ||
# all listed variables are TRUE | ||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(F2PY | ||
REQUIRED_VARS F2PY_EXECUTABLE F2PY_SUFFIX | ||
VERSION_VAR F2PY_VERSION_STRING | ||
) | ||
|
||
mark_as_advanced(F2PY_EXECUTABLE F2PY_SUFFIX) | ||
|
||
if (F2PY_FOUND) | ||
include(UseF2Py) | ||
endif () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
subroutine test | ||
real x | ||
end subroutine test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Used to determine whether compiler is able to compile and/or run a | ||
# given snippet of source. Useful for compiler bug workarounds and | ||
# unsupported features. | ||
|
||
macro (try_f2py_compile file var) | ||
|
||
if (NOT CMAKE_REQUIRED_QUIET) | ||
message (STATUS "Performing Test ${var}") | ||
endif () | ||
|
||
set( _f2py_check_bindir "${CMAKE_BINARY_DIR}/f2py_tmp") | ||
file(MAKE_DIRECTORY ${_f2py_check_bindir}) | ||
|
||
execute_process( | ||
COMMAND ${F2PY_EXECUTABLE} -m test_ -c ${file} | ||
WORKING_DIRECTORY ${_f2py_check_bindir} | ||
RESULT_VARIABLE result | ||
OUTPUT_QUIET | ||
ERROR_QUIET | ||
) | ||
|
||
if (result EQUAL 0) | ||
file(GLOB F2PY_TEST_OUTPUT_FILE ${_f2py_check_bindir}/*.so) | ||
|
||
get_filename_component(F2PY_FOUND_EXTENSION ${F2PY_TEST_OUTPUT_FILE} EXT) | ||
|
||
set(F2PY_SUFFIX ${F2PY_FOUND_EXTENSION} CACHE STRING "f2py suffix") | ||
message(STATUS "Setting F2PY_SUFFIX to ${F2PY_SUFFIX}") | ||
if (NOT CMAKE_REQUIRED_QUIET) | ||
message(STATUS "Performing Test ${var}: SUCCESS") | ||
endif () | ||
else () | ||
if (NOT CMAKE_REQUIRED_QUIET) | ||
message(STATUS "Performing Test ${var}: FAILURE") | ||
endif () | ||
message(WARNING "Test f2py compile using ${F2PY_EXECUTABLE} failed. F2PY modules will not be built. This usually indicates an incomplete Python/numpy installation.") | ||
endif () | ||
|
||
endmacro (try_f2py_compile) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters