C_LAPACK: Fixes to make it compile with MSVC (#3605)
[platform/upstream/openblas.git] / cmake / f_check.cmake
1 ##
2 ## Author: Hank Anderson <hank@statease.com>
3 ## Copyright: (c) Stat-Ease, Inc.
4 ## Created: 12/29/14
5 ## Last Modified: 12/29/14
6 ## Description: Ported from the OpenBLAS/f_check perl script.
7 ##              This is triggered by prebuild.cmake and runs before any of the code is built.
8 ##              Appends Fortran information to config.h and Makefile.conf.
9
10 # CMake vars set by this file:
11 # F_COMPILER
12 # FC
13 # BU
14 # NOFORTRAN
15 # NEED2UNDERSCORES
16 # FEXTRALIB
17
18 # Defines set by this file:
19 # BUNDERSCORE
20 # NEEDBUNDERSCORE
21 # NEED2UNDERSCORES
22
23 include(CheckLanguage)
24 check_language(Fortran)
25 if(CMAKE_Fortran_COMPILER)
26   enable_language(Fortran)
27 else()
28   set (NOFORTRAN 1)
29   if (NOT NO_LAPACK)
30      if (NOT XXXXX)
31         message(STATUS "No Fortran compiler found, can build only BLAS and f2c-converted LAPACK")
32         set(C_LAPACK 1)
33         if (INTERFACE64)
34           set (CCOMMON_OPT "${CCOMMON_OPT} -DLAPACK_ILP64")
35         endif ()
36         set(TIMER "NONE")
37      else ()
38        message(STATUS "No Fortran compiler found, can build only BLAS")
39      endif()  
40   endif()
41 endif()
42
43 if (NOT ONLY_CBLAS)
44   # run f_check (appends to TARGET files)
45
46   # TODO: detect whether underscore needed, set #defines and BU appropriately - use try_compile
47   # TODO: set FEXTRALIB flags a la f_check?
48
49   set(BU "_")
50   file(APPEND ${TARGET_CONF_TEMP}
51     "#define BUNDERSCORE _\n"
52     "#define NEEDBUNDERSCORE 1\n"
53     "#define NEED2UNDERSCORES 0\n")
54
55 else ()
56
57   #When we only build CBLAS, we set NOFORTRAN=2
58   set(NOFORTRAN 2)
59   set(NO_FBLAS 1)
60   #set(F_COMPILER GFORTRAN) # CMake handles the fortran compiler
61   set(BU "_")
62   file(APPEND ${TARGET_CONF_TEMP}
63     "#define BUNDERSCORE _\n"
64     "#define NEEDBUNDERSCORE 1\n")
65 endif()
66
67 get_filename_component(F_COMPILER ${CMAKE_Fortran_COMPILER} NAME_WE)
68 string(TOUPPER ${F_COMPILER} F_COMPILER)
69