From: Hank Anderson Date: Wed, 28 Jan 2015 21:47:47 +0000 (-0600) Subject: Updated c_check OS/compiler/bits detection. X-Git-Tag: v0.2.15^2~9^2~11^2~1^2~97 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c5f5c7a0769c852b569d734fe03e7559039820ea;p=platform%2Fupstream%2Fopenblas.git Updated c_check OS/compiler/bits detection. --- diff --git a/cmake/c_check.cmake b/cmake/c_check.cmake index 07ed8a1..d8facfe 100644 --- a/cmake/c_check.cmake +++ b/cmake/c_check.cmake @@ -7,30 +7,47 @@ ## This is triggered by prebuild.cmake and runs before any of the code is built. ## Creates config.h and Makefile.conf. -# N.B. c_check is not cross-platform, so instead try to use CMake variables. Alternatively, could use try_compile to get some of this info the same way c_check does. +# N.B. c_check (and ctest.c) is not cross-platform, so instead try to use CMake variables. -# run c_check (creates the TARGET files) -# message(STATUS "Running c_check...") -# execute_process(COMMAND perl c_check ${TARGET_MAKE} ${TARGET_CONF} ${CMAKE_CXX_COMPILER} -# WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}) - -# TODO: is ${BINARY} sufficient for the __32BIT__ define? -# TODO: CMAKE_SYSTEM_PROCESSOR is not set by CMake, need to set it manually when doing a cross-compile -# TODO: CMAKE_CXX_COMPILER_ID and CMAKE_SYSTEM_NAME are probably not the same strings as OpenBLAS is expecting # TODO: detect NEED_FU set(NEED_FU 1) # Convert CMake vars into the format that OpenBLAS expects string(TOUPPER ${CMAKE_SYSTEM_NAME} HOST_OS) +if (${HOST_OS} STREQUAL "WINDOWS") + set(HOST_OS WINNT) +endif () + +# added by hpa - check size of void ptr to detect 64-bit compile +if (NOT DEFINED BINARY) + set(BINARY 32) + if (CMAKE_SIZEOF_VOID_P EQUAL 8) + set(BINARY 64) + endif () +endif () + +# CMake docs define these: +# CMAKE_SYSTEM_PROCESSOR - The name of the CPU CMake is building for. +# CMAKE_HOST_SYSTEM_PROCESSOR - The name of the CPU CMake is running on. set(HOST_ARCH ${CMAKE_SYSTEM_PROCESSOR}) if (${HOST_ARCH} STREQUAL "AMD64") set(HOST_ARCH "X86_64") endif () +# If you are using a 32-bit compiler on a 64-bit system CMAKE_SYSTEM_PROCESSOR will be wrong +if (${HOST_ARCH} STREQUAL "X86_64" AND BINARY EQUAL 32) + set(HOST_ARCH X86) +endif () + +set(COMPILER_ID ${CMAKE_CXX_COMPILER_ID}) +if (${COMPILER_ID} STREQUAL "GNU") + set(COMPILER_ID "GCC") +endif () + file(WRITE ${TARGET_CONF} "#define OS_${HOST_OS}\t1\n" "#define ARCH_${HOST_ARCH}\t1\n" - "#define C_${CMAKE_CXX_COMPILER_ID}\t1\n" + "#define C_${COMPILER_ID}\t1\n" "#define __${BINARY}BIT__\t1\n" "#define FUNDERSCORE\t${NEED_FU}\n") diff --git a/cmake/prebuild.cmake b/cmake/prebuild.cmake index ded9f2c..a4faa13 100644 --- a/cmake/prebuild.cmake +++ b/cmake/prebuild.cmake @@ -78,7 +78,7 @@ try_compile(GETARCH_RESULT ${GETARCH_DIR} message(STATUS "GETARCH RESULT: ${GETARCH_RESULT}") message(STATUS "GETARCH LOG: ${GETARCH_LOG}") -# TODO: need to append output of getarch binary to TARGET_CONF, not sure if I can get at it after using try_compile - may need to create CMakeLists.txt on the fly and build/execute +# TODO: need to append output of getarch binary to TARGET_CONF, use COPY_FILE param (look at try_compile docs) to copy the resulting binary somewhere then run it #add_executable(getarch getarch.c cpuid.S ${CPUIDEMU} # WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})