mips: implement MB and WMB
[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 if (MSVC)
24   # had to do this for MSVC, else CMake automatically assumes I have ifort... -hpa
25   include(CMakeForceCompiler)
26   CMAKE_FORCE_Fortran_COMPILER(gfortran GNU)
27 endif ()
28
29 if (NOT NO_LAPACK)
30   enable_language(Fortran)
31 else()
32   include(CMakeForceCompiler)
33   CMAKE_FORCE_Fortran_COMPILER(gfortran GNU)
34 endif()
35
36 if (NOT ONLY_CBLAS)
37   # N.B. f_check is not cross-platform, so instead try to use CMake variables
38   # run f_check (appends to TARGET files)
39 #  message(STATUS "Running f_check...")
40 #  execute_process(COMMAND perl f_check ${TARGET_MAKE} ${TARGET_CONF} ${CMAKE_Fortran_COMPILER}
41 #    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
42
43   # TODO: detect whether underscore needed, set #defines and BU appropriately - use try_compile
44   # TODO: set FEXTRALIB flags a la f_check?
45
46   set(BU "_")
47   file(APPEND ${TARGET_CONF}
48     "#define BUNDERSCORE _\n"
49     "#define NEEDBUNDERSCORE 1\n"
50     "#define NEED2UNDERSCORES 0\n")
51
52 else ()
53
54   #When we only build CBLAS, we set NOFORTRAN=2
55   set(NOFORTRAN 2)
56   set(NO_FBLAS 1)
57   #set(F_COMPILER GFORTRAN) # CMake handles the fortran compiler
58   set(BU "_")
59   file(APPEND ${TARGET_CONF}
60     "#define BUNDERSCORE _\n"
61     "#define NEEDBUNDERSCORE 1\n")
62 endif()
63
64 get_filename_component(F_COMPILER ${CMAKE_Fortran_COMPILER} NAME_WE)
65 string(TOUPPER ${F_COMPILER} F_COMPILER)
66