Fix bug that required fortran. Fix bug that needed CXX var. Remove redundant set vars. Fix threading detection. Do not attempt to run code if cross compiling.

This commit is contained in:
2017-08-17 03:32:04 +10:00
parent 38d273ea03
commit 7c1acc07f0
5 changed files with 33 additions and 74 deletions

View File

@ -179,10 +179,10 @@ if (USE_THREAD)
target_link_libraries(${OpenBLAS_LIBNAME} ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries(${OpenBLAS_LIBNAME} ${CMAKE_THREAD_LIBS_INIT})
endif() endif()
if (NOT MSVC) if (NOT MSVC AND NOT NOFORTRAN)
# Build test and ctest # Build test and ctest
add_subdirectory(test) add_subdirectory(test)
if(NOT NO_CBLAS) if(NOT NO_CBLAS)
add_subdirectory(ctest) add_subdirectory(ctest)
endif() endif()
endif() endif()

View File

@ -90,7 +90,7 @@ else()
set(BINARY32 1) set(BINARY32 1)
endif() endif()
set(COMPILER_ID ${CMAKE_CXX_COMPILER_ID}) set(COMPILER_ID ${CMAKE_C_COMPILER_ID})
if (${COMPILER_ID} STREQUAL "GNU") if (${COMPILER_ID} STREQUAL "GNU")
set(COMPILER_ID "GCC") set(COMPILER_ID "GCC")
endif () endif ()

View File

@ -3,19 +3,6 @@
## Description: Ported from portion of OpenBLAS/Makefile.system ## Description: Ported from portion of OpenBLAS/Makefile.system
## Detects the OS and sets appropriate variables. ## Detects the OS and sets appropriate variables.
if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
set(ENV{MACOSX_DEPLOYMENT_TARGET} "10.2") # TODO: should be exported as an env var
set(MD5SUM "md5 -r")
endif ()
if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
set(MD5SUM "md5 -r")
endif ()
if (${CMAKE_SYSTEM_NAME} STREQUAL "NetBSD")
set(MD5SUM "md5 -n")
endif ()
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(EXTRALIB "${EXTRALIB} -lm") set(EXTRALIB "${EXTRALIB} -lm")
set(NO_EXPRECISION 1) set(NO_EXPRECISION 1)

View File

@ -37,6 +37,9 @@
# CPUIDEMU = ../../cpuid/table.o # CPUIDEMU = ../../cpuid/table.o
# Cannot run getarch on target if we are cross-compiling
if(NOT CMAKE_CROSSCOMPILING)
if (DEFINED CPUIDEMU) if (DEFINED CPUIDEMU)
set(EXFLAGS "-DCPUIDEMU -DVENDOR=99") set(EXFLAGS "-DCPUIDEMU -DVENDOR=99")
endif () endif ()
@ -157,3 +160,5 @@ if (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
MESSAGE(FATAL_ERROR "Compiling gen_config_h failed ${GEN_CONFIG_H_LOG}") MESSAGE(FATAL_ERROR "Compiling gen_config_h failed ${GEN_CONFIG_H_LOG}")
endif () endif ()
endif () endif ()
endif(NOT CMAKE_CROSSCOMPILING)

View File

@ -53,7 +53,7 @@ if (NO_AVX2)
endif () endif ()
if (CMAKE_BUILD_TYPE STREQUAL "Debug") if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(GETARCH_FLAGS "${GETARCH_FLAGS} -g") set(GETARCH_FLAGS "${GETARCH_FLAGS} ${CMAKE_C_FLAGS_DEBUG}")
endif () endif ()
if (NOT DEFINED NO_PARALLEL_MAKE) if (NOT DEFINED NO_PARALLEL_MAKE)
@ -75,18 +75,25 @@ 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 # N.B. this is NUM_THREAD in Makefile.system which is probably a bug -hpa
if (NOT DEFINED NUM_THREADS) if (NOT CMAKE_CROSSCOMPILING)
set(NUM_THREADS ${NUM_CORES}) if (NOT DEFINED NUM_CORES)
endif () include(ProcessorCount)
ProcessorCount(NUM_CORES)
endif()
if (${NUM_THREADS} EQUAL 1) if (NOT NUM_CORES EQUAL 0)
set(NUM_THREADS ${NUM_CORES})
endif ()
endif()
if (${NUM_THREADS} LESS 2)
set(USE_THREAD 0) set(USE_THREAD 0)
elseif(NOT DEFINED USE_THREAD) elseif(NOT DEFINED USE_THREAD)
set(USE_THREAD 1) set(USE_THREAD 1)
endif () endif ()
if (USE_THREAD) if (USE_THREAD)
message(STATUS "SMP enabled.") message(STATUS "Multi-threading enabled with ${NUM_THREADS} threads.")
endif () endif ()
if (NOT DEFINED NEED_PIC) if (NOT DEFINED NEED_PIC)
@ -95,15 +102,6 @@ endif ()
# TODO: I think CMake should be handling all this stuff -hpa # TODO: I think CMake should be handling all this stuff -hpa
unset(ARFLAGS) unset(ARFLAGS)
set(CPP "${COMPILER} -E")
set(AR "${CROSS_SUFFIX}ar")
set(AS "${CROSS_SUFFIX}as")
set(LD "${CROSS_SUFFIX}ld")
set(RANLIB "${CROSS_SUFFIX}ranlib")
set(NM "${CROSS_SUFFIX}nm")
set(DLLWRAP "${CROSS_SUFFIX}dllwrap")
set(OBJCOPY "${CROSS_SUFFIX}objcopy")
set(OBJCONV "${CROSS_SUFFIX}objconv")
# OS dependent settings # OS dependent settings
include("${PROJECT_SOURCE_DIR}/cmake/os.cmake") include("${PROJECT_SOURCE_DIR}/cmake/os.cmake")
@ -132,11 +130,13 @@ if (NEED_PIC)
set(CCOMMON_OPT "${CCOMMON_OPT} -fPIC") set(CCOMMON_OPT "${CCOMMON_OPT} -fPIC")
endif () endif ()
if (${F_COMPILER} STREQUAL "SUN") if (NOT NOFORTRAN)
set(FCOMMON_OPT "${FCOMMON_OPT} -pic") if (${F_COMPILER} STREQUAL "SUN")
else () set(FCOMMON_OPT "${FCOMMON_OPT} -pic")
set(FCOMMON_OPT "${FCOMMON_OPT} -fPIC") else ()
endif () set(FCOMMON_OPT "${FCOMMON_OPT} -fPIC")
endif ()
endif()
endif () endif ()
if (DYNAMIC_ARCH) if (DYNAMIC_ARCH)
@ -278,52 +278,19 @@ if (MIXED_MEMORY_ALLOCATION)
set(CCOMMON_OPT "${CCOMMON_OPT} -DMIXED_MEMORY_ALLOCATION") set(CCOMMON_OPT "${CCOMMON_OPT} -DMIXED_MEMORY_ALLOCATION")
endif () endif ()
if (${CMAKE_SYSTEM_NAME} STREQUAL "SunOS")
set(TAR gtar)
set(PATCH gpatch)
set(GREP ggrep)
else ()
set(TAR tar)
set(PATCH patch)
set(GREP grep)
endif ()
if (NOT DEFINED MD5SUM)
set(MD5SUM md5sum)
endif ()
set(AWK awk)
set(SED sed)
set(REVISION "-r${OpenBLAS_VERSION}") set(REVISION "-r${OpenBLAS_VERSION}")
set(MAJOR_VERSION ${OpenBLAS_MAJOR_VERSION}) set(MAJOR_VERSION ${OpenBLAS_MAJOR_VERSION})
if (CMAKE_BUILD_TYPE STREQUAL "Debug") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CCOMMON_OPT}")
set(COMMON_OPT "${COMMON_OPT} -g")
endif ()
if (NOT DEFINED COMMON_OPT)
set(COMMON_OPT "-O2")
endif ()
#For x86 32-bit
if (DEFINED BINARY AND BINARY EQUAL 32)
if (NOT MSVC)
set(COMMON_OPT "${COMMON_OPT} -m32")
endif()
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_OPT} ${CCOMMON_OPT}")
if(NOT MSVC) if(NOT MSVC)
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ${COMMON_OPT} ${CCOMMON_OPT}") set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ${CCOMMON_OPT}")
endif() endif()
# TODO: not sure what PFLAGS is -hpa # TODO: not sure what PFLAGS is -hpa
set(PFLAGS "${PFLAGS} ${COMMON_OPT} ${CCOMMON_OPT} -I${TOPDIR} -DPROFILE ${COMMON_PROF}") set(PFLAGS "${PFLAGS} ${CCOMMON_OPT} -I${TOPDIR} -DPROFILE ${COMMON_PROF}")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${COMMON_OPT} ${FCOMMON_OPT}") set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${FCOMMON_OPT}")
# TODO: not sure what FPFLAGS is -hpa # TODO: not sure what FPFLAGS is -hpa
set(FPFLAGS "${FPFLAGS} ${COMMON_OPT} ${FCOMMON_OPT} ${COMMON_PROF}") set(FPFLAGS "${FPFLAGS} ${FCOMMON_OPT} ${COMMON_PROF}")
#For LAPACK Fortran codes. #For LAPACK Fortran codes.
set(LAPACK_FFLAGS "${LAPACK_FFLAGS} ${CMAKE_Fortran_FLAGS}") set(LAPACK_FFLAGS "${LAPACK_FFLAGS} ${CMAKE_Fortran_FLAGS}")