Created CMake files

This commit is contained in:
Adam Parler 2023-12-08 02:10:19 -08:00
parent 5b78278c74
commit 215b07da5d
10 changed files with 546 additions and 0 deletions

156
CMakeLists.txt Normal file
View file

@ -0,0 +1,156 @@
cmake_minimum_required(VERSION 3.12)
project(BLAS C)
set(BLAS_MAJOR_VERSION 3)
set(BLAS_MINOR_VERSION 12)
set(BLAS_PATCH_VERSION 0)
set(
BLAS_VERSION
${BLAS_MAJOR_VERSION}.${BLAS_MINOR_VERSION}.${BLAS_PATCH_VERSION}
)
# Add the CMake directory for custom CMake modules
set(CMAKE_MODULE_PATH "${BLAS_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
# Export all symbols on Windows when building shared libraries
SET(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
# Set a default build type if none was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo" "Coverage")
endif()
# Coverage
set(_is_coverage_build 0)
set(_msg "Checking if build type is 'Coverage'")
message(STATUS "${_msg}")
if(NOT CMAKE_CONFIGURATION_TYPES)
string(TOLOWER ${CMAKE_BUILD_TYPE} _build_type_lc)
if(${_build_type_lc} STREQUAL "coverage")
set(_is_coverage_build 1)
endif()
endif()
message(STATUS "${_msg}: ${_is_coverage_build}")
if(_is_coverage_build)
message(STATUS "Adding coverage")
find_package(codecov)
endif()
# By default static library
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
# By default build index32 library
option(BUILD_INDEX64 "Build Index-64 API libraries" OFF)
if(BUILD_INDEX64)
set(BLASLIB "blas64")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWeirdNEC -DLAPACK_ILP64 -DHAVE_LAPACK_CONFIG_H")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fdefault-integer-8")
else()
set(BLASLIB "blas")
endif()
# --------------------------------------------------
set(BLAS_INSTALL_EXPORT_NAME ${BLASLIB}-targets)
macro(blas_install_library lib)
install(TARGETS ${lib}
EXPORT ${BLAS_INSTALL_EXPORT_NAME}
ARCHIVE DESTINATION lib COMPONENT Development
LIBRARY DESTINATION lib COMPONENT RuntimeLibraries
RUNTIME DESTINATION lib COMPONENT RuntimeLibraries
)
endmacro()
set(PKG_CONFIG_DIR lib/pkgconfig)
# --------------------------------------------------
# Precision to build
# By default all precisions are generated
option(BUILD_SINGLE "Build single precision real" ON)
option(BUILD_DOUBLE "Build double precision real" ON)
option(BUILD_COMPLEX "Build single precision complex" ON)
option(BUILD_COMPLEX16 "Build double precision complex" ON)
message(STATUS "Build single precision real: ${BUILD_SINGLE}")
message(STATUS "Build double precision real: ${BUILD_DOUBLE}")
message(STATUS "Build single precision complex: ${BUILD_COMPLEX}")
message(STATUS "Build double precision complex: ${BUILD_COMPLEX16}")
if(NOT (BUILD_SINGLE OR BUILD_DOUBLE OR BUILD_COMPLEX OR BUILD_COMPLEX16))
message(FATAL_ERROR "Nothing to build, no precision selected.
Please enable at least one of these:
BUILD_SINGLE, BUILD_DOUBLE, BUILD_COMPLEX, BUILD_COMPLEX16.")
endif()
include(GNUInstallDirs)
# Updated OSX RPATH settings
# In response to CMake 3.0 generating warnings regarding policy CMP0042,
# the OSX RPATH settings have been updated per recommendations found
# in the CMake Wiki:
# http://www.cmake.org/Wiki/CMake_RPATH_handling#Mac_OS_X_and_the_RPATH
set(CMAKE_MACOSX_RPATH ON)
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES ${CMAKE_INSTALL_FULL_LIBDIR} isSystemDir)
if("${isSystemDir}" STREQUAL "-1")
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR})
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
endif()
include(PreventInSourceBuilds)
include(PreventInBuildInstalls)
# --------------------------------------------------
# Check for any necessary platform specific compiler flags
include(CheckLAPACKCompilerFlags)
CheckLAPACKCompilerFlags("-recursive" _recursiveFlag)
CheckLAPACKCompilerFlags("-frecursive" _frecursiveFlag)
CheckLAPACKCompilerFlags("-Mrecursive" _MrecursiveFlag)
# Add recursive flag
if(_recursiveFlag)
string(REGEX MATCH "-recursive" output_test <string> "${CMAKE_Fortran_FLAGS}")
if(NOT output_test)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -recursive"
CACHE STRING "Recursive flag must be set" FORCE)
endif()
elseif(_frecursiveFlag)
string(REGEX MATCH "-frecursive" output_test <string> "${CMAKE_Fortran_FLAGS}")
if(NOT output_test)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -frecursive"
CACHE STRING "Recursive flag must be set" FORCE)
endif()
elseif(_MrecursiveFlag)
string(REGEX MATCH "-Mrecursive" output_test <string> "${CMAKE_Fortran_FLAGS}")
if(NOT output_test)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Mrecursive"
CACHE STRING "Recursive flag must be set" FORCE)
endif()
endif()
set(BLAS_LIBRARIES ${BLASLIB})
add_subdirectory(src)
# --------------------------------------------------
# Testing
option(BUILD_TESTING "Build tests" ${_is_coverage_build})
include(CTest)
message(STATUS "Build tests: ${BUILD_TESTING}")
if(BUILD_TESTING)
add_subdirectory(TESTING)
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/blas.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${BLASLIB}.pc @ONLY)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/${BLASLIB}.pc
DESTINATION ${PKG_CONFIG_DIR}
COMPONENT Development
)

View file

@ -0,0 +1,84 @@
# This module checks against various known compilers and their respective
# flags to determine any specific flags needing to be set.
#
# 1. If FPE traps are enabled either abort or disable them
# 2. Specify fixed form if needed
# 3. Ensure that Release builds use O2 instead of O3
#
#=============================================================================
# Author: Chuck Atkins
# Copyright 2011
#=============================================================================
macro( CheckLAPACKCompilerFlags )
set( FPE_EXIT FALSE )
# GNU Fortran
if( CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" )
if( "${CMAKE_Fortran_FLAGS}" MATCHES "-ffpe-trap=[izoupd]")
set( FPE_EXIT TRUE )
endif()
# Intel Fortran
elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "Intel" )
if( "${CMAKE_Fortran_FLAGS}" MATCHES "[-/]fpe(-all=|)0" )
set( FPE_EXIT TRUE )
endif()
# SunPro F95
elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "SunPro" )
if( ("${CMAKE_Fortran_FLAGS}" MATCHES "-ftrap=") AND
NOT ("${CMAKE_Fortran_FLAGS}" MATCHES "-ftrap=(%|)none") )
set( FPE_EXIT TRUE )
elseif( NOT (CMAKE_Fortran_FLAGS MATCHES "-ftrap=") )
message( STATUS "Disabling FPE trap handlers with -ftrap=%none" )
set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ftrap=%none"
CACHE STRING "Flags for Fortran compiler." FORCE )
endif()
# IBM XL Fortran
elseif( (CMAKE_Fortran_COMPILER_ID STREQUAL "VisualAge" ) OR # CMake 2.6
(CMAKE_Fortran_COMPILER_ID STREQUAL "XL" ) ) # CMake 2.8
if( "${CMAKE_Fortran_FLAGS}" MATCHES "-qflttrap=[a-zA-Z:]:enable" )
set( FPE_EXIT TRUE )
endif()
# HP Fortran
elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "HP" )
if( "${CMAKE_Fortran_FLAGS}" MATCHES "\\+fp_exception" )
set( FPE_EXIT TRUE )
endif()
if( NOT ("${CMAKE_Fortran_FLAGS}" MATCHES "\\+fltconst_strict") )
message( STATUS "Enabling strict float conversion with +fltconst_strict" )
set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} +fltconst_strict"
CACHE STRING "Flags for Fortran compiler." FORCE )
endif()
# Most versions of cmake don't have good default options for the HP compiler
set( CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} -g"
CACHE STRING "Flags used by the compiler during debug builds" FORCE )
set( CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_MINSIZEREL} +Osize"
CACHE STRING "Flags used by the compiler during release minsize builds" FORCE )
set( CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_RELEASE} +O2"
CACHE STRING "Flags used by the compiler during release builds" FORCE )
set( CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_RELWITHDEBINFO} +O2 -g"
CACHE STRING "Flags used by the compiler during release with debug info builds" FORCE )
else()
endif()
if( "${CMAKE_Fortran_FLAGS_RELEASE}" MATCHES "O[3-9]" )
message( STATUS "Reducing RELEASE optimization level to O2" )
string( REGEX REPLACE "O[3-9]" "O2" CMAKE_Fortran_FLAGS_RELEASE
"${CMAKE_Fortran_FLAGS_RELEASE}" )
set( CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE}"
CACHE STRING "Flags used by the compiler during release builds" FORCE )
endif()
if( FPE_EXIT )
message( FATAL_ERROR "Floating Point Exception (FPE) trap handlers are currently explicitly enabled in the compiler flags. LAPACK is designed to check for and handle these cases internally and enabling these traps will likely cause LAPACK to crash. Please re-configure with floating point exception trapping disabled." )
endif()
endmacro()

View file

@ -0,0 +1,9 @@
string(TOLOWER "${CMAKE_INSTALL_PREFIX}" _PREFIX)
string(TOLOWER "${ITK_BINARY_DIR}" _BUILD)
if("${_PREFIX}" STREQUAL "${_BUILD}")
message(FATAL_ERROR
"The current CMAKE_INSTALL_PREFIX points at the build tree:\n"
" ${CMAKE_INSTALL_PREFIX}\n"
"This is not supported."
)
endif()

View file

@ -0,0 +1,45 @@
#
# This function will prevent in-source builds
function(AssureOutOfSourceBuilds)
# make sure the user doesn't play dirty with symlinks
get_filename_component(srcdir "${CMAKE_SOURCE_DIR}" REALPATH)
get_filename_component(bindir "${CMAKE_BINARY_DIR}" REALPATH)
# disallow in-source builds
if("${srcdir}" STREQUAL "${bindir}")
message("######################################################")
message("# lapack should not be configured & built in the lapack source directory")
message("# You must run cmake in a build directory.")
message("# For example:")
message("# mkdir lapack-Sandbox ; cd lapack-sandbox")
message("# git clone https://github.com/Reference-LAPACK/lapack.git # or download & unpack the source tarball")
message("# mkdir lapack-build")
message("# this will create the following directory structure")
message("#")
message("# lapack-Sandbox")
message("# +--lapack")
message("# +--lapack-build")
message("#")
message("# Then you can proceed to configure and build")
message("# by using the following commands")
message("#")
message("# cd lapack-build")
message("# cmake ../lapack # or ccmake, or cmake-gui ")
message("# make")
message("#")
message("# NOTE: Given that you already tried to make an in-source build")
message("# CMake have already created several files & directories")
message("# in your source tree. run 'git status' to find them and")
message("# remove them by doing:")
message("#")
message("# cd lapack-Sandbox/lapack")
message("# git clean -n -d")
message("# git clean -f -d")
message("# git checkout --")
message("#")
message("######################################################")
message(FATAL_ERROR "Quitting configuration")
endif()
endfunction()
AssureOutOfSourceBuilds()

39
src/CMakeLists.txt Normal file
View file

@ -0,0 +1,39 @@
#######################################################################
# This is the makefile to create a library for the BLAS.
# The files are grouped as follows:
#
# ALLBLAS -- Auxiliary routines for Level 2 and 3 BLAS
#
#######################################################################
add_subdirectory(double)
add_subdirectory(single)
#---------------------------------------------------------------------
# Auxiliary routines needed by both the Level 2 and Level 3 BLAS
#---------------------------------------------------------------------
set(ALLBLAS lsame.c xerbla.c xerbla_array.c)
set(SOURCES)
if(BUILD_SINGLE)
list(APPEND SOURCES ${SBLAS1} ${ALLBLAS} ${SBLAS2} ${SBLAS3})
endif()
if(BUILD_DOUBLE)
list(APPEND SOURCES ${DBLAS1} ${ALLBLAS} ${DBLAS2} ${DBLAS3})
endif()
if(BUILD_COMPLEX)
list(APPEND SOURCES ${CBLAS1} ${CB1AUX} ${ALLBLAS} ${CBLAS2} ${CBLAS3})
endif()
if(BUILD_COMPLEX16)
list(APPEND SOURCES ${ZBLAS1} ${ZB1AUX} ${ALLBLAS} ${ZBLAS2} ${ZBLAS3})
endif()
list(REMOVE_DUPLICATES SOURCES)
add_library(${BLASLIB} ${SOURCES})
set_target_properties(
${BLASLIB} PROPERTIES
VERSION ${BLAS_VERSION}
SOVERSION ${BLAS_MAJOR_VERSION}
)
blas_install_library(${BLASLIB})

8
src/blas.pc.in Normal file
View file

@ -0,0 +1,8 @@
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
Name: BLAS
Description: FORTRAN reference implementation of BLAS Basic Linear Algebra Subprograms
Version: @BLAS_VERSION@
URL: https://gitlab.adamhome.dev/math-utils/blas
Libs: -L${libdir} -l@BLASLIB@

63
src/double/CMakeLists.txt Normal file
View file

@ -0,0 +1,63 @@
#######################################################################
# This is the makefile to create a library for the BLAS.
# The files are grouped as follows:
#
# DBLAS1 -- Double precision real BLAS routines
# ZBLAS1 -- Double precision complex BLAS routines
#
# ZB1AUX -- D.P. real BLAS routines called by d.p. complex
# routines
#
# DBLAS2 -- Double precision real BLAS2 routines
# ZBLAS2 -- Double precision complex BLAS2 routines
#
# DBLAS3 -- Double precision real BLAS3 routines
# ZBLAS3 -- Double precision complex BLAS3 routines
#
#######################################################################
#---------------------------------------------------------
# Level 1 BLAS
#---------------------------------------------------------
set(DBLAS1 idamax.c dasum.c daxpy.c dcopy.c ddot.c dnrm2.c
drot.c drotg.c dscal.c dsdot.c dswap.c drotmg.c drotm.c)
set(ZBLAS1 dcabs1.c dzasum.c dznrm2.c izamax.c zaxpy.c zcopy.c
zdotc.c zdotu.c zdscal.c zrotg.c zscal.c zswap.c zdrot.c)
set(ZB1AUX idamax.c dasum.c daxpy.c dcopy.c dnrm2.c dscal.c)
#---------------------------------------------------------
# Level 2 BLAS
#---------------------------------------------------------
set(DBLAS2 dgemv.c dgbmv.c dsymv.c dsbmv.c dspmv.c
dtrmv.c dtbmv.c dtpmv.c dtrsv.c dtbsv.c dtpsv.c
dger.c dsyr.c dspr.c dsyr2.c dspr2.c)
set(ZBLAS2 zgemv.c zgbmv.c zhemv.c zhbmv.c zhpmv.c
ztrmv.c ztbmv.c ztpmv.c ztrsv.c ztbsv.c ztpsv.c
zgerc.c zgeru.c zher.c zhpr.c zher2.c zhpr2.c)
#---------------------------------------------------------
# Level 3 BLAS
#---------------------------------------------------------
set(DBLAS3 dgemm.c dsymm.c dsyrk.c dsyr2k.c dtrmm.c dtrsm.c)
set(ZBLAS3 zgemm.c zsymm.c zsyrk.c zsyr2k.c ztrmm.c ztrsm.c
zhemm.c zherk.c zher2k.c)
list(TRANSFORM DBLAS1 PREPEND ${CMAKE_CURRENT_SOURCE_DIR}/)
list(TRANSFORM DBLAS2 PREPEND ${CMAKE_CURRENT_SOURCE_DIR}/)
list(TRANSFORM DBLAS3 PREPEND ${CMAKE_CURRENT_SOURCE_DIR}/)
list(TRANSFORM ZBLAS1 PREPEND ${CMAKE_CURRENT_SOURCE_DIR}/)
list(TRANSFORM ZBLAS2 PREPEND ${CMAKE_CURRENT_SOURCE_DIR}/)
list(TRANSFORM ZBLAS3 PREPEND ${CMAKE_CURRENT_SOURCE_DIR}/)
list(TRANSFORM ZB1AUX PREPEND ${CMAKE_CURRENT_SOURCE_DIR}/)
set(DBLAS1 ${DBLAS1} PARENT_SCOPE)
set(DBLAS2 ${DBLAS2} PARENT_SCOPE)
set(DBLAS3 ${DBLAS3} PARENT_SCOPE)
set(ZBLAS1 ${ZBLAS1} PARENT_SCOPE)
set(ZBLAS2 ${ZBLAS2} PARENT_SCOPE)
set(ZBLAS3 ${ZBLAS3} PARENT_SCOPE)
set(ZB1AUX ${ZB1AUX} PARENT_SCOPE)

62
src/single/CMakeLists.txt Normal file
View file

@ -0,0 +1,62 @@
#######################################################################
# This is the makefile to create a library for the BLAS.
# The files are grouped as follows:
#
# SBLAS1 -- Single precision real BLAS routines
# CBLAS1 -- Single precision complex BLAS routines
#
# CB1AUX -- Real BLAS routines called by complex routines
#
# SBLAS2 -- Single precision real BLAS2 routines
# CBLAS2 -- Single precision complex BLAS2 routines
#
# SBLAS3 -- Single precision real BLAS3 routines
# CBLAS3 -- Single precision complex BLAS3 routines
#
#######################################################################
#---------------------------------------------------------
# Level 1 BLAS
#---------------------------------------------------------
set(SBLAS1 isamax.c sasum.c saxpy.c scopy.c sdot.c snrm2.c
srot.c srotg.c sscal.c sswap.c sdsdot.c srotmg.c srotm.c)
set(CBLAS1 scabs1.c scasum.c scnrm2.c icamax.c caxpy.c ccopy.c
cdotc.c cdotu.c csscal.c crotg.c cscal.c cswap.c csrot.c)
set(CB1AUX isamax.c sasum.c saxpy.c scopy.c snrm2.c sscal.c)
#---------------------------------------------------------
# Level 2 BLAS
#---------------------------------------------------------
set(SBLAS2 sgemv.c sgbmv.c ssymv.c ssbmv.c sspmv.c
strmv.c stbmv.c stpmv.c strsv.c stbsv.c stpsv.c
sger.c ssyr.c sspr.c ssyr2.c sspr2.c)
set(CBLAS2 cgemv.c cgbmv.c chemv.c chbmv.c chpmv.c
ctrmv.c ctbmv.c ctpmv.c ctrsv.c ctbsv.c ctpsv.c
cgerc.c cgeru.c cher.c chpr.c cher2.c chpr2.c)
#---------------------------------------------------------
# Level 3 BLAS
#---------------------------------------------------------
set(SBLAS3 sgemm.c ssymm.c ssyrk.c ssyr2k.c strmm.c strsm.c)
set(CBLAS3 cgemm.c csymm.c csyrk.c csyr2k.c ctrmm.c ctrsm.c
chemm.c cherk.c cher2k.c)
list(TRANSFORM SBLAS1 PREPEND ${CMAKE_CURRENT_SOURCE_DIR}/)
list(TRANSFORM SBLAS2 PREPEND ${CMAKE_CURRENT_SOURCE_DIR}/)
list(TRANSFORM SBLAS3 PREPEND ${CMAKE_CURRENT_SOURCE_DIR}/)
list(TRANSFORM CBLAS1 PREPEND ${CMAKE_CURRENT_SOURCE_DIR}/)
list(TRANSFORM CBLAS2 PREPEND ${CMAKE_CURRENT_SOURCE_DIR}/)
list(TRANSFORM CBLAS3 PREPEND ${CMAKE_CURRENT_SOURCE_DIR}/)
list(TRANSFORM CB1AUX PREPEND ${CMAKE_CURRENT_SOURCE_DIR}/)
set(SBLAS1 ${SBLAS1} PARENT_SCOPE)
set(SBLAS2 ${SBLAS2} PARENT_SCOPE)
set(SBLAS3 ${SBLAS3} PARENT_SCOPE)
set(CBLAS1 ${CBLAS1} PARENT_SCOPE)
set(CBLAS2 ${CBLAS2} PARENT_SCOPE)
set(CBLAS3 ${CBLAS3} PARENT_SCOPE)
set(CB1AUX ${CB1AUX} PARENT_SCOPE)

42
testing/CMakeLists.txt Normal file
View file

@ -0,0 +1,42 @@
macro(add_blas_test name src)
get_filename_component(baseNAME ${src} NAME_WE)
set(TEST_INPUT "${BLAS_SOURCE_DIR}/testing/${baseNAME}.in")
add_executable(${name} ${src})
target_link_libraries(${name} ${BLASLIB})
if(EXISTS "${TEST_INPUT}")
add_test(NAME BLAS-${name} COMMAND "${CMAKE_COMMAND}"
-DTEST=$<TARGET_FILE:${name}>
-DINPUT=${TEST_INPUT}
-DINTDIR=${CMAKE_CFG_INTDIR}
-P "${BLAS_SOURCE_DIR}/TESTING/runtest.cmake")
else()
add_test(NAME BLAS-${name} COMMAND "${CMAKE_COMMAND}"
-DTEST=$<TARGET_FILE:${name}>
-DINTDIR=${CMAKE_CFG_INTDIR}
-P "${BLAS_SOURCE_DIR}/TESTING/runtest.cmake")
endif()
endmacro()
if(BUILD_SINGLE)
add_blas_test(xblat1s sblat1.c)
add_blas_test(xblat2s sblat2.c)
add_blas_test(xblat3s sblat3.c)
endif()
if(BUILD_DOUBLE)
add_blas_test(xblat1d dblat1.c)
add_blas_test(xblat2d dblat2.c)
add_blas_test(xblat3d dblat3.c)
endif()
if(BUILD_COMPLEX)
add_blas_test(xblat1c cblat1.c)
add_blas_test(xblat2c cblat2.c)
add_blas_test(xblat3c cblat3.c)
endif()
if(BUILD_COMPLEX16)
add_blas_test(xblat1z zblat1.c)
add_blas_test(xblat2z zblat2.c)
add_blas_test(xblat3z zblat3.c)
endif()

38
testing/runtest.cmake Normal file
View file

@ -0,0 +1,38 @@
# Replace INTDIR with the value of $ENV{CMAKE_CONFIG_TYPE} that is set
# by ctest when -C Debug|Releaes|etc is given, and INDIR is passed
# in from the main cmake run and is the variable that is used
# by the build system to specify the build directory
if(NOT "${INTDIR}" STREQUAL ".")
set(TEST_ORIG "${TEST}")
string(REPLACE "${INTDIR}" "$ENV{CMAKE_CONFIG_TYPE}" TEST "${TEST}")
if("$ENV{CMAKE_CONFIG_TYPE}" STREQUAL "")
if(NOT EXISTS "${TEST}")
message("Warning: CMAKE_CONFIG_TYPE not defined did you forget the -C option for ctest?")
message(FATAL_ERROR "Could not find test executable: ${TEST_ORIG}")
endif()
endif()
endif()
set(ARGS )
if(DEFINED OUTPUT)
set(ARGS OUTPUT_FILE "${OUTPUT}" ERROR_FILE "${OUTPUT}.err")
endif()
if(DEFINED INPUT)
list(APPEND ARGS INPUT_FILE "${INPUT}")
endif()
message("Running: ${TEST}")
message("ARGS= ${ARGS}")
execute_process(COMMAND "${TEST}"
${ARGS}
RESULT_VARIABLE RET)
if(DEFINED OUTPUT)
file(READ "${OUTPUT}" TEST_OUTPUT)
file(READ "${OUTPUT}.err" TEST_ERROR)
message("Test OUTPUT:\n${TEST_OUTPUT}")
message("Test ERROR:\n${TEST_ERROR}")
endif()
# if the test does not return 0, then fail it
if(NOT ${RET} EQUAL 0)
message(FATAL_ERROR "Test ${TEST} returned ${RET}")
endif()
message( "Test ${TEST} returned ${RET}")