From 8d9b196e0dd3f1230b3f6e610e6a54ead64b514f Mon Sep 17 00:00:00 2001 From: Hank Anderson Date: Fri, 30 Jan 2015 12:14:44 -0600 Subject: [PATCH] Moved loop over define combos into a function. This function takes a set of sources and a set of preprocessor definitions. It will iterate over the sources and build an object file for each combination of preprocessor definitions for each source file. --- driver/level3/CMakeLists.txt | 60 ++++++++++++++++++++---------------- driver/others/CMakeLists.txt | 2 ++ 2 files changed, 35 insertions(+), 27 deletions(-) create mode 100644 driver/others/CMakeLists.txt diff --git a/driver/level3/CMakeLists.txt b/driver/level3/CMakeLists.txt index 3a282a0ae..9059a46d0 100644 --- a/driver/level3/CMakeLists.txt +++ b/driver/level3/CMakeLists.txt @@ -58,35 +58,41 @@ function(AllCombinations list_in) set(LIST_OUT ${LIST_OUT} PARENT_SCOPE) endfunction () +# generates object files for each of the sources for each of the combinations of the preprocessor definitions passed in +function(GenerateObjects sources_in defines_in) + AllCombinations("${defines_in}") + set(define_combos ${LIST_OUT}) + foreach (source_file ${sources_in}) + foreach (def_combo ${define_combos}) + + # replace colon separated list with semicolons, this turns it into a CMake list that we can use foreach with + string(REPLACE ":" ";" def_combo ${def_combo}) + + # 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 "") + foreach (combo_elem ${def_combo}) + string(REGEX MATCH "^[A-Z][A-Z]" letter ${combo_elem}) + set(obj_name "${obj_name}${letter}") + endforeach () + + # parse file name + string(REGEX MATCH "[a-z]+_[LR]" source_name ${source_file}) + string(TOUPPER ${source_name} source_name) + + # prepend the uppercased file name to the obj name + set(obj_name "${source_name}_${obj_name}_OBJS") + + # now add the object and set the defines + add_library(${obj_name} OBJECT ${source_file}) + set_target_properties(${obj_name} PROPERTIES COMPILE_DEFINITIONS "${def_combo}") + endforeach () + endforeach () +endfunction () + # these sources are compiled with combinations of TRANS, UPPER, and UNIT, for 32 combinations total set(TRM_SOURCES trmm_L.c trmm_R.c trsm_L.c trsm_R.c) -AllCombinations("TRANS;UPPER;UNIT") -set(TRM_DEFINE_COMBOS ${LIST_OUT}) -foreach (trm_source ${TRM_SOURCES}) - foreach (trm_defines ${TRM_DEFINE_COMBOS}) - - # replace colon separated list with semicolons, this turns it into a CMake list that we can use foreach with - string(REPLACE ":" ";" trm_defines ${trm_defines}) - - # build a unique variable name for this obj file by picking two letters from the defines (can't use one in this case) - set(trm_obj_name "") - foreach (trm_define ${trm_defines}) - string(REGEX MATCH "^[A-Z][A-Z]" letter ${trm_define}) - set(trm_obj_name "${trm_obj_name}${letter}") - endforeach () - - # parse file name - string(REGEX MATCH "[a-z]+_[LR]" trm_name ${trm_source}) - string(TOUPPER ${trm_name} trm_name) - - # prepend the uppercased file name to the obj name - set(trm_obj_name "${trm_name}_${trm_obj_name}_OBJS") - - # now add the object and set the defines - add_library(${trm_obj_name} OBJECT ${trm_source}) - set_target_properties(${trm_obj_name} PROPERTIES COMPILE_DEFINITIONS "${trm_defines}") - endforeach () -endforeach () +set(TRM_DEFINES TRANS UPPER UNIT) +GenerateObjects("${TRM_SOURCES}" "${TRM_DEFINES}") # dsymm_LU.c dsymm_LL.c dsymm_RU.c dsymm_RL.c # dsyrk_UN.c dsyrk_UT.c dsyrk_LN.c dsyrk_LT.c diff --git a/driver/others/CMakeLists.txt b/driver/others/CMakeLists.txt new file mode 100644 index 000000000..2685d79c8 --- /dev/null +++ b/driver/others/CMakeLists.txt @@ -0,0 +1,2 @@ + +# NYI