2 ## Author: Hank Anderson <hank@statease.com>
5 cmake_minimum_required(VERSION 2.8.4)
7 set(OpenBLAS_MAJOR_VERSION 0)
8 set(OpenBLAS_MINOR_VERSION 2)
9 set(OpenBLAS_PATCH_VERSION 13)
10 set(OpenBLAS_VERSION "${OpenBLAS_MAJOR_VERSION}.${OpenBLAS_MINOR_VERSION}.${OpenBLAS_PATCH_VERSION}")
12 # is this necessary? lapack-netlib has its own fortran checks in its CMakeLists.txt
13 enable_language(Fortran)
15 message(WARNING "CMake support is experimental. This will not produce the same Makefiles that OpenBLAS ships with.")
17 include("${CMAKE_SOURCE_DIR}/cmake/utils.cmake")
18 include("${CMAKE_SOURCE_DIR}/cmake/system.cmake")
20 set(BLASDIRS interface driver/level2 driver/level3 driver/others)
22 if (NOT ${DYNAMIC_ARCH})
23 list(APPEND BLASDIRS kernel)
26 if (DEFINED UTEST_CHECK)
30 if (DEFINED SANITY_CHECK)
31 list(APPEND BLASDIRS reference)
34 set(SUBDIRS ${BLASDIRS})
36 list(APPEND SUBDIRS lapack)
39 set(SUBDIRS_ALL ${SUBDIRS} test ctest utest exports benchmark ../laswp ../bench)
41 # all :: libs netlib tests shared
44 if (NOT DEFINED CORE OR "${CORE}" STREQUAL "UNKNOWN")
45 message(FATAL_ERROR "Detecting CPU failed. Please set TARGET explicitly, e.g. make TARGET=your_cpu_target. Please read README for details.")
48 # Let CMake handle this
50 # message(ERROR "OpenBLAS: Detecting fortran compiler failed. Please install fortran compiler, e.g. gfortran, ifort, openf90.")
53 if (${NO_STATIC} AND ${NO_SHARED})
54 message(FATAL_ERROR "Neither static nor shared are enabled.")
58 foreach (BLAS_DIR ${BLASDIRS})
59 add_subdirectory(${BLAS_DIR})
62 # get obj vars into format that add_library likes: $<TARGET_OBJS:objlib> (see http://www.cmake.org/cmake/help/v3.0/command/add_library.html)
64 foreach (DBLAS_OBJ ${DBLAS_OBJS})
65 get_target_property(PREV_DEFS ${DBLAS_OBJ} COMPILE_DEFINITIONS)
66 set_target_properties(${DBLAS_OBJ} PROPERTIES COMPILE_DEFINITIONS "${PREV_DEFS};DOUBLE")
67 list(APPEND TARGET_OBJS "$<TARGET_OBJECTS:${DBLAS_OBJ}>")
69 add_library(openblas ${TARGET_OBJS})
71 # TODO: Why is the config saved here? Is this necessary with CMake?
72 #Save the config files for installation
73 # @cp Makefile.conf Makefile.conf_last
74 # @cp config.h config_last.h
76 # @echo "#define QUAD_PRECISION">> config_last.h
78 #ifeq ($(EXPRECISION), 1)
79 # @echo "#define EXPRECISION">> config_last.h
82 #ifeq ($(DYNAMIC_ARCH), 1)
83 # @$(MAKE) -C kernel commonlibs || exit 1
84 # @for d in $(DYNAMIC_CORE) ; \
85 # do $(MAKE) GOTOBLAS_MAKEFILE= -C kernel TARGET_CORE=$$d kernel || exit 1 ;\
87 # @echo DYNAMIC_ARCH=1 >> Makefile.conf_last
90 # @echo USE_THREAD=$(USE_THREAD) >> Makefile.conf_last