2 ## Author: Hank Anderson <hank@statease.com>
3 ## Description: Ported from the OpenBLAS/c_check perl script.
4 ## This is triggered by prebuild.cmake and runs before any of the code is built.
5 ## Creates config.h and Makefile.conf.
7 # CMake vars set by this file:
8 # OSNAME (use CMAKE_SYSTEM_NAME)
10 # C_COMPILER (use CMAKE_C_COMPILER)
18 # Defines set by this file:
27 # N.B. c_check (and ctest.c) is not cross-platform, so instead try to use CMake variables.
29 # TODO: detect NEED_FU/FU
32 # Convert CMake vars into the format that OpenBLAS expects
33 string(TOUPPER ${CMAKE_SYSTEM_NAME} HOST_OS)
34 if (${HOST_OS} STREQUAL "WINDOWS")
38 # added by hpa - check size of void ptr to detect 64-bit compile
39 if (NOT DEFINED BINARY)
41 if (CMAKE_SIZEOF_VOID_P EQUAL 8)
52 # CMake docs define these:
53 # CMAKE_SYSTEM_PROCESSOR - The name of the CPU CMake is building for.
54 # CMAKE_HOST_SYSTEM_PROCESSOR - The name of the CPU CMake is running on.
56 # TODO: CMAKE_SYSTEM_PROCESSOR doesn't seem to be correct - instead get it from the compiler a la c_check
57 set(ARCH ${CMAKE_SYSTEM_PROCESSOR})
58 if (${ARCH} STREQUAL "AMD64")
62 # If you are using a 32-bit compiler on a 64-bit system CMAKE_SYSTEM_PROCESSOR will be wrong
63 if (${ARCH} STREQUAL "X86_64" AND BINARY EQUAL 32)
67 set(COMPILER_ID ${CMAKE_CXX_COMPILER_ID})
68 if (${COMPILER_ID} STREQUAL "GNU")
69 set(COMPILER_ID "GCC")
72 file(WRITE ${TARGET_CONF}
73 "#define OS_${HOST_OS}\t1\n"
74 "#define ARCH_${ARCH}\t1\n"
75 "#define C_${COMPILER_ID}\t1\n"
76 "#define __${BINARY}BIT__\t1\n"
77 "#define FUNDERSCORE\t${NEED_FU}\n")