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

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}")