-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
43 lines (32 loc) · 1.09 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
cmake_minimum_required(VERSION 3.12)
project(calc11
VERSION 1.0
DESCRIPTION "CALC11 module"
LANGUAGES C Fortran
)
find_package(Python 3.8 REQUIRED)
find_package(PythonExtensions REQUIRED)
find_package(NumPy)
find_package(F2PY REQUIRED)
# Generate param11.in file in cmake build directory
file(READ ${CMAKE_SOURCE_DIR}/calc11/src/param11.i.in CONTENTS)
file(WRITE ${CMAKE_SOURCE_DIR}/calc11/src/param11.i ${CONTENTS})
set(f2py_module_name "calc11")
set(fortran_src_file "${CMAKE_BINARY_DIR}/calc11/src/calc11.f90")
set(generated_module_file ${CMAKE_CURRENT_BINARY_DIR}/${f2py_module_name}${PYTHON_EXTENSION_MODULE_SUFFIX})
add_subdirectory(calc11)
# get include files
file(GLOB includes ${CMAKE_SOURCE_DIR}"/calc11/src/*.i")
list(PREPEND includes ${generated_module_file})
add_custom_target(${f2py_module_name} ALL
DEPENDS ${includes}
)
add_custom_command(
OUTPUT ${generated_module_file}
COMMAND ${F2PY_EXECUTABLE}
-m ${f2py_module_name}
-c
${fortran_src_file}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
install(FILES ${generated_module_file} DESTINATION pycalc11)