-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switched from meson to scikit-build-core for simpler Fortran builds
- Loading branch information
1 parent
2699dc6
commit 9b1f620
Showing
6 changed files
with
46 additions
and
902 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,43 @@ | ||
cmake_minimum_required(VERSION 3.17.2) | ||
project(${SKBUILD_PROJECT_NAME} LANGUAGES C Fortran) | ||
|
||
find_package( | ||
Python | ||
COMPONENTS Interpreter Development.Module NumPy | ||
REQUIRED) | ||
|
||
# F2PY headers | ||
execute_process( | ||
COMMAND "${PYTHON_EXECUTABLE}" -c | ||
"import numpy.f2py; print(numpy.f2py.get_include())" | ||
OUTPUT_VARIABLE F2PY_INCLUDE_DIR | ||
OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
|
||
add_library(fortranobject OBJECT "${F2PY_INCLUDE_DIR}/fortranobject.c") | ||
target_link_libraries(fortranobject PUBLIC Python::NumPy) | ||
target_include_directories(fortranobject PUBLIC "${F2PY_INCLUDE_DIR}") | ||
set_property(TARGET fortranobject PROPERTY POSITION_INDEPENDENT_CODE ON) | ||
|
||
file(GLOB F90_SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/trustregion/*.f90") | ||
|
||
add_custom_command( | ||
OUTPUT _trsmodule.c _trs-f2pywrappers.f | ||
DEPENDS ${F90_SOURCE_FILES} | ||
VERBATIM | ||
COMMAND "${Python_EXECUTABLE}" -m numpy.f2py | ||
"${CMAKE_CURRENT_SOURCE_DIR}/trustregion/trsapp.f90" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/trustregion/trsbox.f90" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/trustregion/trslin.f90" -m _trs --lower) | ||
|
||
python_add_library(_trs MODULE "${CMAKE_CURRENT_BINARY_DIR}/_trsmodule.c" | ||
"${F90_SOURCE_FILES}" WITH_SOABI) | ||
target_link_libraries(_trs PRIVATE fortranobject) | ||
|
||
install(TARGETS _trs DESTINATION trustregion/) | ||
|
||
# Taken from PRIMA: | ||
# The following are not added to the component because scikit-build-core automatically | ||
# detects files in python/<package_name> and adds them to the wheel. These commands | ||
# are here in case one is building via cmake directly and not via scikit-build-core | ||
file(GLOB SUPPORTING_PY_FILES "${CMAKE_CURRENT_SOURCE_DIR}/trustregion/*.py") | ||
install (FILES ${SUPPORTING_PY_FILES} DESTINATION trustregion) |
This file was deleted.
Oops, something went wrong.
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
Empty file.
Oops, something went wrong.