Drop some redundant vars and improve arch detection in CMake.
This commit is contained in:
parent
7242cdc4ec
commit
38d273ea03
|
@ -173,9 +173,11 @@ endforeach()
|
||||||
enable_testing()
|
enable_testing()
|
||||||
add_subdirectory(utest)
|
add_subdirectory(utest)
|
||||||
|
|
||||||
# Add threading library to linker
|
if (USE_THREAD)
|
||||||
find_package(Threads)
|
# Add threading library to linker
|
||||||
target_link_libraries(${OpenBLAS_LIBNAME} ${CMAKE_THREAD_LIBS_INIT})
|
find_package(Threads)
|
||||||
|
target_link_libraries(${OpenBLAS_LIBNAME} ${CMAKE_THREAD_LIBS_INIT})
|
||||||
|
endif()
|
||||||
|
|
||||||
if (NOT MSVC)
|
if (NOT MSVC)
|
||||||
# Build test and ctest
|
# Build test and ctest
|
||||||
|
|
|
@ -26,14 +26,8 @@
|
||||||
|
|
||||||
# N.B. c_check (and ctest.c) is not cross-platform, so instead try to use CMake variables.
|
# N.B. c_check (and ctest.c) is not cross-platform, so instead try to use CMake variables.
|
||||||
set(FU "")
|
set(FU "")
|
||||||
if(APPLE)
|
if (APPLE OR (MSVC AND NOT ${CMAKE_C_COMPILER_ID} MATCHES "Clang"))
|
||||||
set(FU "_")
|
set(FU "_")
|
||||||
elseif(MSVC AND ${CMAKE_C_COMPILER_ID} MATCHES "Clang")
|
|
||||||
set(FU "")
|
|
||||||
elseif(MSVC)
|
|
||||||
set(FU "_")
|
|
||||||
elseif(UNIX)
|
|
||||||
set(FU "")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Convert CMake vars into the format that OpenBLAS expects
|
# Convert CMake vars into the format that OpenBLAS expects
|
||||||
|
@ -42,43 +36,59 @@ if (${HOST_OS} STREQUAL "WINDOWS")
|
||||||
set(HOST_OS WINNT)
|
set(HOST_OS WINNT)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# added by hpa - check size of void ptr to detect 64-bit compile
|
if(CMAKE_COMPILER_IS_GNUCC AND WIN32)
|
||||||
if (NOT DEFINED BINARY)
|
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpmachine
|
||||||
set(BINARY 32)
|
OUTPUT_VARIABLE OPENBLAS_GCC_TARGET_MACHINE
|
||||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
set(BINARY 64)
|
if(OPENBLAS_GCC_TARGET_MACHINE MATCHES "amd64|x86_64|AMD64")
|
||||||
endif ()
|
set(MINGW64 1)
|
||||||
endif ()
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
if (BINARY EQUAL 64)
|
# Pretty thorough determination of arch. Add more if needed
|
||||||
set(BINARY64 1)
|
if(CMAKE_CL_64 OR MINGW64)
|
||||||
else ()
|
set(X86_64 1)
|
||||||
set(BINARY32 1)
|
elseif(MINGW OR (MSVC AND NOT CMAKE_CROSSCOMPILING))
|
||||||
endif ()
|
set(X86 1)
|
||||||
|
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc")
|
||||||
|
set(PPC 1)
|
||||||
|
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*")
|
||||||
|
set(X86_64 1)
|
||||||
|
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i686.*|i386.*|x86.*|amd64.*|AMD64.*")
|
||||||
|
set(X86 1)
|
||||||
|
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm.*|ARM.*)")
|
||||||
|
set(ARM 1)
|
||||||
|
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*)")
|
||||||
|
set(ARM64 1)
|
||||||
|
endif()
|
||||||
|
|
||||||
# CMake docs define these:
|
if (X86_64)
|
||||||
# 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.
|
|
||||||
#
|
|
||||||
# TODO: CMAKE_SYSTEM_PROCESSOR doesn't seem to be correct - instead get it from the compiler a la c_check
|
|
||||||
set(ARCH ${CMAKE_SYSTEM_PROCESSOR} CACHE STRING "Target Architecture")
|
|
||||||
|
|
||||||
if (${ARCH} STREQUAL "AMD64")
|
|
||||||
set(ARCH "x86_64")
|
set(ARCH "x86_64")
|
||||||
|
elseif(X86)
|
||||||
|
set(ARCH "x86")
|
||||||
|
elseif(PPC)
|
||||||
|
set(ARCH "power")
|
||||||
|
elseif(ARM)
|
||||||
|
set(ARCH "arm")
|
||||||
|
elseif(ARM64)
|
||||||
|
set(ARCH "arm64")
|
||||||
|
else()
|
||||||
|
set(ARCH ${CMAKE_SYSTEM_PROCESSOR} CACHE STRING "Target Architecture")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# If you are using a 32-bit compiler on a 64-bit system CMAKE_SYSTEM_PROCESSOR will be wrong
|
if (NOT BINARY)
|
||||||
if (${ARCH} STREQUAL "x86_64" AND BINARY EQUAL 32)
|
if (X86_64 OR ARM64 OR PPC OR ARCH STREQUAL "mips64")
|
||||||
set(ARCH x86)
|
set(BINARY 64)
|
||||||
endif ()
|
else ()
|
||||||
|
set(BINARY 32)
|
||||||
|
endif ()
|
||||||
|
endif()
|
||||||
|
|
||||||
if (${ARCH} STREQUAL "X86")
|
if(BINARY EQUAL 64)
|
||||||
set(ARCH x86)
|
set(BINARY64 1)
|
||||||
endif ()
|
else()
|
||||||
|
set(BINARY32 1)
|
||||||
if (${ARCH} MATCHES "ppc")
|
endif()
|
||||||
set(ARCH power)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
set(COMPILER_ID ${CMAKE_CXX_COMPILER_ID})
|
set(COMPILER_ID ${CMAKE_CXX_COMPILER_ID})
|
||||||
if (${COMPILER_ID} STREQUAL "GNU")
|
if (${COMPILER_ID} STREQUAL "GNU")
|
||||||
|
|
|
@ -78,7 +78,7 @@ if (CYGWIN)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows" AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Interix" AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Android")
|
if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows" AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Interix" AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Android")
|
||||||
if (SMP)
|
if (USE_THREAD)
|
||||||
set(EXTRALIB "${EXTRALIB} -lpthread")
|
set(EXTRALIB "${EXTRALIB} -lpthread")
|
||||||
endif ()
|
endif ()
|
||||||
endif ()
|
endif ()
|
||||||
|
|
|
@ -56,11 +56,6 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
set(GETARCH_FLAGS "${GETARCH_FLAGS} -g")
|
set(GETARCH_FLAGS "${GETARCH_FLAGS} -g")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# TODO: let CMake handle this? -hpa
|
|
||||||
#if (${QUIET_MAKE})
|
|
||||||
# set(MAKE "${MAKE} -s")
|
|
||||||
#endif()
|
|
||||||
|
|
||||||
if (NOT DEFINED NO_PARALLEL_MAKE)
|
if (NOT DEFINED NO_PARALLEL_MAKE)
|
||||||
set(NO_PARALLEL_MAKE 0)
|
set(NO_PARALLEL_MAKE 0)
|
||||||
endif ()
|
endif ()
|
||||||
|
@ -79,30 +74,18 @@ endif ()
|
||||||
|
|
||||||
include("${PROJECT_SOURCE_DIR}/cmake/prebuild.cmake")
|
include("${PROJECT_SOURCE_DIR}/cmake/prebuild.cmake")
|
||||||
|
|
||||||
|
# N.B. this is NUM_THREAD in Makefile.system which is probably a bug -hpa
|
||||||
if (NOT DEFINED NUM_THREADS)
|
if (NOT DEFINED NUM_THREADS)
|
||||||
set(NUM_THREADS ${NUM_CORES})
|
set(NUM_THREADS ${NUM_CORES})
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (${NUM_THREADS} EQUAL 1)
|
if (${NUM_THREADS} EQUAL 1)
|
||||||
set(USE_THREAD 0)
|
set(USE_THREAD 0)
|
||||||
|
elseif(NOT DEFINED USE_THREAD)
|
||||||
|
set(USE_THREAD 1)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (DEFINED USE_THREAD)
|
if (USE_THREAD)
|
||||||
if (NOT ${USE_THREAD})
|
|
||||||
unset(SMP)
|
|
||||||
else ()
|
|
||||||
set(SMP 1)
|
|
||||||
endif ()
|
|
||||||
else ()
|
|
||||||
# N.B. this is NUM_THREAD in Makefile.system which is probably a bug -hpa
|
|
||||||
if (${NUM_THREADS} EQUAL 1)
|
|
||||||
unset(SMP)
|
|
||||||
else ()
|
|
||||||
set(SMP 1)
|
|
||||||
endif ()
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if (${SMP})
|
|
||||||
message(STATUS "SMP enabled.")
|
message(STATUS "SMP enabled.")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
@ -182,7 +165,7 @@ if (NO_AVX2)
|
||||||
set(CCOMMON_OPT "${CCOMMON_OPT} -DNO_AVX2")
|
set(CCOMMON_OPT "${CCOMMON_OPT} -DNO_AVX2")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (SMP)
|
if (USE_THREAD)
|
||||||
set(CCOMMON_OPT "${CCOMMON_OPT} -DSMP_SERVER")
|
set(CCOMMON_OPT "${CCOMMON_OPT} -DSMP_SERVER")
|
||||||
|
|
||||||
if (${ARCH} STREQUAL "mips64")
|
if (${ARCH} STREQUAL "mips64")
|
||||||
|
@ -386,7 +369,7 @@ if (NOT DEFINED LIBSUFFIX)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (DYNAMIC_ARCH)
|
if (DYNAMIC_ARCH)
|
||||||
if (DEFINED SMP)
|
if (USE_THREAD)
|
||||||
set(LIBNAME "${LIBPREFIX}p${REVISION}.${LIBSUFFIX}")
|
set(LIBNAME "${LIBPREFIX}p${REVISION}.${LIBSUFFIX}")
|
||||||
set(LIBNAME_P "${LIBPREFIX}p${REVISION}_p.${LIBSUFFIX}")
|
set(LIBNAME_P "${LIBPREFIX}p${REVISION}_p.${LIBSUFFIX}")
|
||||||
else ()
|
else ()
|
||||||
|
@ -394,7 +377,7 @@ if (DYNAMIC_ARCH)
|
||||||
set(LIBNAME_P "${LIBPREFIX}${REVISION}_p.${LIBSUFFIX}")
|
set(LIBNAME_P "${LIBPREFIX}${REVISION}_p.${LIBSUFFIX}")
|
||||||
endif ()
|
endif ()
|
||||||
else ()
|
else ()
|
||||||
if (DEFINED SMP)
|
if (USE_THREAD)
|
||||||
set(LIBNAME "${LIBPREFIX}_${LIBCORE}p${REVISION}.${LIBSUFFIX}")
|
set(LIBNAME "${LIBPREFIX}_${LIBCORE}p${REVISION}.${LIBSUFFIX}")
|
||||||
set(LIBNAME_P "${LIBPREFIX}_${LIBCORE}p${REVISION}_p.${LIBSUFFIX}")
|
set(LIBNAME_P "${LIBPREFIX}_${LIBCORE}p${REVISION}_p.${LIBSUFFIX}")
|
||||||
else ()
|
else ()
|
||||||
|
|
Loading…
Reference in New Issue