blob: d772dc9bba53c5db2d6d142c8f2dd6ce105655a2 (
plain)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
# Macro that defines variables describing the Fortran name mangling
# convention
#
# Sets the following outputs on success:
#
# INTFACE
# Add_
# NoChange
# f77IsF2C
# UpCase
#
macro(FORTRAN_MANGLING CDEFS)
message(STATUS "=========")
get_filename_component(F77_NAME ${CMAKE_Fortran_COMPILER} NAME)
get_filename_component(F77_PATH ${CMAKE_Fortran_COMPILER} PATH)
set(F77 ${F77_NAME} CACHE INTERNAL "Name of the fortran compiler.")
if(${F77} STREQUAL "ifort.exe")
#settings for Intel Fortran
set(F77_OPTION_COMPILE "/c" CACHE INTERNAL
"Fortran compiler option for compiling without linking.")
set(F77_OUTPUT_OBJ "/Fo" CACHE INTERNAL
"Fortran compiler option for setting object file name.")
set(F77_OUTPUT_EXE "/Fe" CACHE INTERNAL
"Fortran compiler option for setting executable file name.")
else()
# in other case, let user specify their fortran configrations.
set(F77_OPTION_COMPILE "-c" CACHE STRING
"Fortran compiler option for compiling without linking.")
set(F77_OUTPUT_OBJ "-o" CACHE STRING
"Fortran compiler option for setting object file name.")
set(F77_OUTPUT_EXE "-o" CACHE STRING
"Fortran compiler option for setting executable file name.")
set(F77_LIB_PATH "" CACHE PATH
"Library path for the fortran compiler")
set(F77_INCLUDE_PATH "" CACHE PATH
"Include path for the fortran compiler")
endif()
message(STATUS "Testing FORTRAN_MANGLING")
message(STATUS "Compiling Finface.f...")
execute_process ( COMMAND ${CMAKE_Fortran_COMPILER} ${F77_OPTION_COMPILE} ${PROJECT_SOURCE_DIR}/lapacke/mangling/Fintface.f
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
OUTPUT_VARIABLE OUTPUT
RESULT_VARIABLE RESULT
ERROR_VARIABLE ERROR)
if(RESULT EQUAL 0)
message(STATUS "Compiling Finface.f successful")
else()
message(FATAL_ERROR " Compiling Finface.f FAILED")
message(FATAL_ERROR " Error:\n ${ERROR}")
endif()
message(STATUS "Compiling Cintface.c...")
execute_process ( COMMAND ${CMAKE_C_COMPILER} ${F77_OPTION_COMPILE} ${PROJECT_SOURCE_DIR}/lapacke/mangling/Cintface.c
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
OUTPUT_VARIABLE OUTPUT
RESULT_VARIABLE RESULT
ERROR_VARIABLE ERROR)
if(RESULT EQUAL 0)
message(STATUS "Compiling Cintface.c successful")
else()
message(FATAL_ERROR " Compiling Cintface.c FAILED")
message(FATAL_ERROR " Error:\n ${ERROR}")
endif()
message(STATUS "Linking Finface.f and Cintface.c...")
execute_process ( COMMAND ${CMAKE_Fortran_COMPILER} ${F77_OUTPUT_OBJ} xintface.exe Fintface.o Cintface.o
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
OUTPUT_VARIABLE OUTPUT
RESULT_VARIABLE RESULT
ERROR_VARIABLE ERROR)
if(RESULT EQUAL 0)
message(STATUS "Linking Finface.f and Cintface.c successful")
else()
message(FATAL_ERROR " Linking Finface.f and Cintface.c FAILED")
message(FATAL_ERROR " Error:\n ${ERROR}")
endif()
message(STATUS "Running ./xintface...")
execute_process ( COMMAND ./xintface.exe
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
RESULT_VARIABLE xintface_RES
OUTPUT_VARIABLE xintface_OUT
ERROR_VARIABLE xintface_ERR)
if (xintface_RES EQUAL 0)
string(REPLACE "\n" "" xintface_OUT "${xintface_OUT}")
message(STATUS "Fortran MANGLING convention: ${xintface_OUT}")
set(CDEFS ${xintface_OUT})
else()
message(FATAL_ERROR "FORTRAN_MANGLING:ERROR ${xintface_ERR}")
endif()
endmacro()
|