@@ -173,9 +173,11 @@ endforeach() | |||||
enable_testing() | enable_testing() | ||||
add_subdirectory(utest) | add_subdirectory(utest) | ||||
# Add threading library to linker | |||||
find_package(Threads) | |||||
target_link_libraries(${OpenBLAS_LIBNAME} ${CMAKE_THREAD_LIBS_INIT}) | |||||
if (USE_THREAD) | |||||
# Add threading library to linker | |||||
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) | |||||
set(FU "_") | |||||
elseif(MSVC AND ${CMAKE_C_COMPILER_ID} MATCHES "Clang") | |||||
set(FU "") | |||||
elseif(MSVC) | |||||
set(FU "_") | |||||
elseif(UNIX) | |||||
set(FU "") | |||||
if (APPLE OR (MSVC AND NOT ${CMAKE_C_COMPILER_ID} MATCHES "Clang")) | |||||
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 (NOT DEFINED BINARY) | |||||
set(BINARY 32) | |||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8) | |||||
set(BINARY 64) | |||||
endif () | |||||
endif () | |||||
if (BINARY EQUAL 64) | |||||
set(BINARY64 1) | |||||
else () | |||||
set(BINARY32 1) | |||||
endif () | |||||
if(CMAKE_COMPILER_IS_GNUCC AND WIN32) | |||||
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpmachine | |||||
OUTPUT_VARIABLE OPENBLAS_GCC_TARGET_MACHINE | |||||
OUTPUT_STRIP_TRAILING_WHITESPACE) | |||||
if(OPENBLAS_GCC_TARGET_MACHINE MATCHES "amd64|x86_64|AMD64") | |||||
set(MINGW64 1) | |||||
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. | |||||
# | |||||
# 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") | |||||
# Pretty thorough determination of arch. Add more if needed | |||||
if(CMAKE_CL_64 OR MINGW64) | |||||
set(X86_64 1) | |||||
elseif(MINGW OR (MSVC AND NOT CMAKE_CROSSCOMPILING)) | |||||
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() | |||||
if (${ARCH} STREQUAL "AMD64") | |||||
if (X86_64) | |||||
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 (${ARCH} STREQUAL "x86_64" AND BINARY EQUAL 32) | |||||
set(ARCH x86) | |||||
endif () | |||||
if (${ARCH} STREQUAL "X86") | |||||
set(ARCH x86) | |||||
endif () | |||||
if (NOT BINARY) | |||||
if (X86_64 OR ARM64 OR PPC OR ARCH STREQUAL "mips64") | |||||
set(BINARY 64) | |||||
else () | |||||
set(BINARY 32) | |||||
endif () | |||||
endif() | |||||
if (${ARCH} MATCHES "ppc") | |||||
set(ARCH power) | |||||
endif () | |||||
if(BINARY EQUAL 64) | |||||
set(BINARY64 1) | |||||
else() | |||||
set(BINARY32 1) | |||||
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 (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}) | |||||
if (USE_THREAD) | |||||
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 () | ||||