Added override for function names in GenerateNamedObjects.

The BLAS interface folder should now be generated the correct objects
for the DOUBLE case.
This commit is contained in:
Hank Anderson 2015-02-04 10:52:19 -06:00
parent a0aeda6187
commit 5690cf3f0e
2 changed files with 40 additions and 24 deletions

View File

@ -92,21 +92,26 @@ endfunction ()
# @param sources_in the source files to build from # @param sources_in the source files to build from
# @param float_type_in the float type to define for this build (e.g. SINGLE/DOUBLE/etc) # @param float_type_in the float type to define for this build (e.g. SINGLE/DOUBLE/etc)
# @param defines_in (optional) preprocessor definitions that will be applied to all objects # @param defines_in (optional) preprocessor definitions that will be applied to all objects
function(GenerateNamedObjects sources_in float_type_in defines_in) # @param name_in (optional) if this is set this name will be used instead of the filename. Use a * to indicate where the float character should go, if no star the character will be prepended.
# e.g. with DOUBLE set, "i*max" will generate the name "idmax", and "max" will be "dmax"
function(GenerateNamedObjects sources_in float_type_in defines_in name_in)
set(OBJ_LIST_OUT "") set(OBJ_LIST_OUT "")
foreach (source_file ${sources_in}) foreach (source_file ${sources_in})
get_filename_component(source_name ${source_file} NAME_WE)
string(SUBSTRING ${float_type_in} 0 1 float_char) string(SUBSTRING ${float_type_in} 0 1 float_char)
string(TOLOWER ${float_char} float_char) string(TOLOWER ${float_char} float_char)
# build a unique variable name for this obj file by picking two letters from the defines (can't use one in this case) if (NOT name_in)
set(obj_name "${float_char}${source_name}") get_filename_component(source_name ${source_file} NAME_WE)
set(obj_name "${float_char}${source_name}")
# parse file name else ()
string(REGEX MATCH "^[a-zA-Z_0-9]+" source_name ${source_file}) # replace * with float_char
string(TOUPPER ${source_name} source_name) if (${name_in} MATCHES "\\*")
string(REPLACE "*" ${float_char} obj_name ${name_in})
else ()
set(obj_name "${float_char}${name_in}")
endif ()
endif ()
# now add the object and set the defines # now add the object and set the defines
add_library(${obj_name} OBJECT ${source_file}) add_library(${obj_name} OBJECT ${source_file})

View File

@ -30,25 +30,36 @@ set(BLAS3_SOURCES
if (NOT DEFINED NO_FBLAS) if (NOT DEFINED NO_FBLAS)
# N.B. The original Makefile passed in -UUSE_MIN and -UUSE_ABS (where appropriate), no way to do that at a source-level in cmake. REMOVE_DEFINITIONS removes a definition for the rest of the compilation. GenerateNamedObjects("${BLAS1_SOURCES}" "DOUBLE" "" "")
add_library(AMAX_OBJ OBJECT max.c) list(APPEND DBLAS_OBJS ${OBJ_LIST_OUT})
set_target_properties(AMAX_OBJ PROPERTIES COMPILE_DEFINITIONS "USE_ABS") GenerateNamedObjects("${BLAS2_SOURCES}" "DOUBLE" "" "")
add_library(AMIN_OBJ OBJECT max.c) list(APPEND DBLAS_OBJS ${OBJ_LIST_OUT})
set_target_properties(AMIN_OBJ PROPERTIES COMPILE_DEFINITIONS "USE_ABS;USE_MIN") GenerateNamedObjects("${BLAS3_SOURCES}" "DOUBLE" "" "")
add_library(MIN_OBJ OBJECT max.c)
set_target_properties(MIN_OBJ PROPERTIES COMPILE_DEFINITIONS "USE_MIN")
add_library(MAX_OBJ OBJECT max.c)
GenerateNamedObjects("${BLAS1_SOURCES}" "DOUBLE" "")
GenerateNamedObjects("${BLAS2_SOURCES}" "DOUBLE" "")
GenerateNamedObjects("${BLAS3_SOURCES}" "DOUBLE" "")
list(APPEND DBLAS_OBJS ${OBJ_LIST_OUT}) list(APPEND DBLAS_OBJS ${OBJ_LIST_OUT})
# trmm is trsm with a compiler flag set # trmm is trsm with a compiler flag set
add_library(TRMM_OBJ OBJECT trsm.c) GenerateNamedObjects("trsm.c" "DOUBLE" "TRMM" "trmm")
set_target_properties(TRMM_OBJ PROPERTIES COMPILE_DEFINITIONS "TRMM") list(APPEND DBLAS_OBJS ${OBJ_LIST_OUT})
# max and imax are compiled 4 times
GenerateNamedObjects("max.c" "DOUBLE" "" "")
list(APPEND DBLAS_OBJS ${OBJ_LIST_OUT})
GenerateNamedObjects("max.c" "DOUBLE" "USE_ABS" "amax")
list(APPEND DBLAS_OBJS ${OBJ_LIST_OUT})
GenerateNamedObjects("max.c" "DOUBLE" "USE_ABS;USE_MIN" "amin")
list(APPEND DBLAS_OBJS ${OBJ_LIST_OUT})
GenerateNamedObjects("max.c" "DOUBLE" "USE_MIN" "min")
list(APPEND DBLAS_OBJS ${OBJ_LIST_OUT})
GenerateNamedObjects("imax.c" "DOUBLE" "" "i*max")
list(APPEND DBLAS_OBJS ${OBJ_LIST_OUT})
GenerateNamedObjects("imax.c" "DOUBLE" "USE_ABS" "i*amax")
list(APPEND DBLAS_OBJS ${OBJ_LIST_OUT})
GenerateNamedObjects("imax.c" "DOUBLE" "USE_ABS;USE_MIN" "i*amin")
list(APPEND DBLAS_OBJS ${OBJ_LIST_OUT})
GenerateNamedObjects("imax.c" "DOUBLE" "USE_MIN" "i*min")
list(APPEND DBLAS_OBJS ${OBJ_LIST_OUT})
list(APPEND DBLAS_OBJS "AMAX_OBJ;AMIN_OBJ;MIN_OBJ;MAX_OBJ;TRMM_OBJ")
endif () endif ()
if (NOT DEFINED NO_CBLAS) if (NOT DEFINED NO_CBLAS)