-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CMake copied from relMT - not adapted yet
- Loading branch information
1 parent
3de6bd8
commit db9ed0c
Showing
1 changed file
with
41 additions
and
0 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,41 @@ | ||
cmake_minimum_required(VERSION 3.17.2...3.29) | ||
project(${SKBUILD_PROJECT_NAME} LANGUAGES 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") | ||
|
||
# Find the FFTW3 installation on your system | ||
find_package(PkgConfig REQUIRED) | ||
pkg_search_module(FFTW REQUIRED fftw3 IMPORTED_TARGET) | ||
include_directories(PkgConfig::FFTW) | ||
link_libraries(PkgConfig::FFTW) | ||
|
||
target_link_libraries(fortranobject PUBLIC Python::NumPy) | ||
target_include_directories(fortranobject PUBLIC "${F2PY_INCLUDE_DIR}") | ||
set_property(TARGET fortranobject PROPERTY POSITION_INDEPENDENT_CODE ON) | ||
|
||
add_custom_command( | ||
OUTPUT mccoremodule.c mccore-f2pywrappers.f | ||
DEPENDS src/relmt/mccore.f90 | ||
VERBATIM | ||
COMMAND "${Python_EXECUTABLE}" -m numpy.f2py | ||
"${CMAKE_CURRENT_SOURCE_DIR}/src/relmt/mccore.f90" -m mccore --lower) | ||
|
||
python_add_library( | ||
mccore MODULE "${CMAKE_CURRENT_BINARY_DIR}/mccoremodule.c" | ||
"${CMAKE_CURRENT_BINARY_DIR}/mccore-f2pywrappers.f" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/src/relmt/mccore.f90" WITH_SOABI) | ||
target_link_libraries(mccore PRIVATE fortranobject) | ||
|
||
install(TARGETS mccore DESTINATION .) |