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.
37 # Convert CMake vars into the format that OpenBLAS expects
38 string(TOUPPER ${CMAKE_SYSTEM_NAME} HOST_OS)
39 if (${HOST_OS} STREQUAL "WINDOWS")
43 # added by hpa - check size of void ptr to detect 64-bit compile
44 if (NOT DEFINED BINARY)
46 if (CMAKE_SIZEOF_VOID_P EQUAL 8)
57 # CMake docs define these:
58 # CMAKE_SYSTEM_PROCESSOR - The name of the CPU CMake is building for.
59 # CMAKE_HOST_SYSTEM_PROCESSOR - The name of the CPU CMake is running on.
61 # TODO: CMAKE_SYSTEM_PROCESSOR doesn't seem to be correct - instead get it from the compiler a la c_check
62 set(ARCH ${CMAKE_SYSTEM_PROCESSOR})
63 if (${ARCH} STREQUAL "AMD64")
67 # If you are using a 32-bit compiler on a 64-bit system CMAKE_SYSTEM_PROCESSOR will be wrong
68 if (${ARCH} STREQUAL "x86_64" AND BINARY EQUAL 32)
72 if (${ARCH} STREQUAL "X86")
76 if (${ARCH} MATCHES "ppc")
80 set(COMPILER_ID ${CMAKE_CXX_COMPILER_ID})
81 if (${COMPILER_ID} STREQUAL "GNU")
82 set(COMPILER_ID "GCC")
85 string(TOUPPER ${ARCH} UC_ARCH)
87 file(WRITE ${TARGET_CONF}
88 "#define OS_${HOST_OS}\t1\n"
89 "#define ARCH_${UC_ARCH}\t1\n"
90 "#define C_${COMPILER_ID}\t1\n"
91 "#define __${BINARY}BIT__\t1\n"
92 "#define FUNDERSCORE\t${FU}\n")