Fixed cmake building bugs on Linux. Disable LAPACK by default.

This commit is contained in:
Zhang Xianyi 2015-08-04 04:37:05 +08:00
parent a55377e9a4
commit 7ac7e147d4
4 changed files with 47 additions and 13 deletions

View File

@ -6,10 +6,29 @@ cmake_minimum_required(VERSION 2.8.4)
project(OpenBLAS)
set(OpenBLAS_MAJOR_VERSION 0)
set(OpenBLAS_MINOR_VERSION 2)
set(OpenBLAS_PATCH_VERSION 13)
set(OpenBLAS_PATCH_VERSION 14)
set(OpenBLAS_VERSION "${OpenBLAS_MAJOR_VERSION}.${OpenBLAS_MINOR_VERSION}.${OpenBLAS_PATCH_VERSION}")
enable_language(ASM)
enable_language(C)
set(OpenBLAS_LIBNAME openblas)
#######
option(BUILD_WITHOUT_LAPACK "Without LAPACK and LAPACKE (Only BLAS and CBLAS)" ON)
option(BUILD_DEBUG "Build Debug Version" OFF)
#######
if(BUILD_WITHOUT_LAPACK)
set(NO_LAPACK 1)
endif()
if(BUILD_DEBUG)
set(CMAKE_BUILD_TYPE Debug)
else()
set(CMAKE_BUILD_TYPE Release)
endif()
#######
message(WARNING "CMake support is experimental. This will not produce the same Makefiles that OpenBLAS ships with. Only x86 support is currently available.")
@ -32,6 +51,7 @@ endif ()
set(SUBDIRS ${BLASDIRS})
if (NOT NO_LAPACK)
message ("error 1")
list(APPEND SUBDIRS lapack)
endif ()
@ -90,15 +110,29 @@ endforeach ()
# Can't just use lapack-netlib's CMake files, since they are set up to search for BLAS, build and install a binary. We just want to build a couple of lib files out of lapack and lapacke.
# Not using add_subdirectory here because lapack-netlib already has its own CMakeLists.txt. Instead include a cmake script with the sources we want.
if (NOT NOFORTRAN)
if (NOT NOFORTRAN AND NOT NO_LAPACK)
message ("error 2")
include("${CMAKE_SOURCE_DIR}/cmake/lapack.cmake")
endif ()
if (NOT NO_LAPACKE)
include("${CMAKE_SOURCE_DIR}/cmake/lapacke.cmake")
endif ()
endif ()
# add objects to the openblas lib
add_library(openblas ${LA_SOURCES} ${LAPACKE_SOURCES} ${TARGET_OBJS})
add_library(${OpenBLAS_LIBNAME} SHARED ${LA_SOURCES} ${LAPACKE_SOURCES} ${TARGET_OBJS})
#only build shared library for MSVC
if(NOT MSVC)
add_library(${OpenBLAS_LIBNAME}_static STATIC ${LA_SOURCES} ${LAPACKE_SOURCES} ${TARGET_OBJS})
set_target_properties(${OpenBLAS_LIBNAME}_static PROPERTIES OUTPUT_NAME ${OpenBLAS_LIBNAME})
set_target_properties(${OpenBLAS_LIBNAME}_static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
endif()
set_target_properties(${OpenBLAS_LIBNAME} PROPERTIES
VERSION ${OpenBLAS_MAJOR_VERSION}.${OpenBLAS_MINOR_VERSION}
SOVERSION ${OpenBLAS_MAJOR_VERSION}
)
# TODO: Why is the config saved here? Is this necessary with CMake?
#Save the config files for installation

View File

@ -79,10 +79,10 @@ try_compile(GETARCH_RESULT ${GETARCH_DIR}
message(STATUS "Running getarch")
# use the cmake binary w/ the -E param to run a shell command in a cross-platform way
execute_process(COMMAND ${GETARCH_BIN} 0 OUTPUT_VARIABLE GETARCH_MAKE_OUT)
execute_process(COMMAND ${GETARCH_BIN} 1 OUTPUT_VARIABLE GETARCH_CONF_OUT)
execute_process(COMMAND ${PROJECT_BINARY_DIR}/${GETARCH_BIN} 0 OUTPUT_VARIABLE GETARCH_MAKE_OUT)
execute_process(COMMAND ${PROJECT_BINARY_DIR}/${GETARCH_BIN} 1 OUTPUT_VARIABLE GETARCH_CONF_OUT)
#message(STATUS "GETARCH results:\n${GETARCH_MAKE_OUT}")
message(STATUS "GETARCH results:\n${GETARCH_MAKE_OUT}")
# append config data from getarch to the TARGET file and read in CMake vars
file(APPEND ${TARGET_CONF} ${GETARCH_CONF_OUT})
@ -99,8 +99,8 @@ try_compile(GETARCH2_RESULT ${GETARCH2_DIR}
)
# use the cmake binary w/ the -E param to run a shell command in a cross-platform way
execute_process(COMMAND ${GETARCH2_BIN} 0 OUTPUT_VARIABLE GETARCH2_MAKE_OUT)
execute_process(COMMAND ${GETARCH2_BIN} 1 OUTPUT_VARIABLE GETARCH2_CONF_OUT)
execute_process(COMMAND ${PROJECT_BINARY_DIR}/${GETARCH2_BIN} 0 OUTPUT_VARIABLE GETARCH2_MAKE_OUT)
execute_process(COMMAND ${PROJECT_BINARY_DIR}/${GETARCH2_BIN} 1 OUTPUT_VARIABLE GETARCH2_CONF_OUT)
# append config data from getarch_2nd to the TARGET file and read in CMake vars
file(APPEND ${TARGET_CONF} ${GETARCH2_CONF_OUT})

View File

@ -16,8 +16,9 @@ else ()
endif ()
SetDefaultL1()
ParseMakefileVars("${KERNELDIR}/KERNEL.${TARGET_CORE}")
SetDefaultL2()
ParseMakefileVars("${KERNELDIR}/KERNEL")
ParseMakefileVars("${KERNELDIR}/KERNEL.${TARGET_CORE}")
if (${ARCH} STREQUAL "x86")
GenerateNamedObjects("${KERNELDIR}/cpuid.S" "" "" false "" "" true)
@ -67,7 +68,6 @@ foreach (float_type ${FLOAT_TYPES})
endforeach ()
# Makefile.L2
SetDefaultL2()
GenerateCombinationObjects("generic/symv_k.c" "LOWER" "U" "" 1 "" "" 3)
GenerateNamedObjects("generic/ger.c" "" "ger_k" false "" "" "" 3)
foreach (float_type ${FLOAT_TYPES})

View File

@ -119,11 +119,11 @@ XCOPYKERNEL = zcopy.S
endif
ifndef SDOTKERNEL
SDOTKERNEL = ../generic/dot.c
SDOTKERNEL = ../generic/dot.c
endif
ifndef DSDOTKERNEL
DSDOTKERNEL = ../generic/dot.c
DSDOTKERNEL = ../generic/dot.c
endif
ifndef DDOTKERNEL