Added override for function names in GenerateNamedObjects.
authorHank Anderson <hank.p.anderson@gmail.com>
Wed, 4 Feb 2015 16:52:19 +0000 (10:52 -0600)
committerHank Anderson <hank.p.anderson@gmail.com>
Wed, 4 Feb 2015 16:52:19 +0000 (10:52 -0600)
The BLAS interface folder should now be generated the correct objects
for the DOUBLE case.

cmake/utils.cmake
interface/CMakeLists.txt

index 6cee749..d02ee1a 100644 (file)
@@ -92,21 +92,26 @@ endfunction ()
 # @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 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 "")
   foreach (source_file ${sources_in})
 
-    get_filename_component(source_name ${source_file} NAME_WE)
-
     string(SUBSTRING ${float_type_in} 0 1 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)
-    set(obj_name "${float_char}${source_name}")
-
-    # parse file name
-    string(REGEX MATCH "^[a-zA-Z_0-9]+" source_name ${source_file})
-    string(TOUPPER ${source_name} source_name)
+    if (NOT name_in)
+      get_filename_component(source_name ${source_file} NAME_WE)
+      set(obj_name "${float_char}${source_name}")
+    else ()
+      # replace * with float_char
+      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
     add_library(${obj_name} OBJECT ${source_file})
index 6082c55..e2f073d 100644 (file)
@@ -30,25 +30,36 @@ set(BLAS3_SOURCES
 
 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.
-  add_library(AMAX_OBJ OBJECT max.c)
-  set_target_properties(AMAX_OBJ PROPERTIES COMPILE_DEFINITIONS "USE_ABS")
-  add_library(AMIN_OBJ OBJECT max.c)
-  set_target_properties(AMIN_OBJ PROPERTIES COMPILE_DEFINITIONS "USE_ABS;USE_MIN")
-  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" "")
+  GenerateNamedObjects("${BLAS1_SOURCES}" "DOUBLE" "" "")
+  list(APPEND DBLAS_OBJS ${OBJ_LIST_OUT})
+  GenerateNamedObjects("${BLAS2_SOURCES}" "DOUBLE" "" "")
+  list(APPEND DBLAS_OBJS ${OBJ_LIST_OUT})
+  GenerateNamedObjects("${BLAS3_SOURCES}" "DOUBLE" "" "")
   list(APPEND DBLAS_OBJS ${OBJ_LIST_OUT})
 
   # trmm is trsm with a compiler flag set
-  add_library(TRMM_OBJ OBJECT trsm.c)
-  set_target_properties(TRMM_OBJ PROPERTIES COMPILE_DEFINITIONS "TRMM")
+  GenerateNamedObjects("trsm.c" "DOUBLE" "TRMM" "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 ()
 
 if (NOT DEFINED NO_CBLAS)