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.
This commit is contained in:
parent
a6cf8aafc0
commit
8d9b196e0d
|
@ -58,35 +58,41 @@ function(AllCombinations list_in)
|
||||||
set(LIST_OUT ${LIST_OUT} PARENT_SCOPE)
|
set(LIST_OUT ${LIST_OUT} PARENT_SCOPE)
|
||||||
endfunction ()
|
endfunction ()
|
||||||
|
|
||||||
# these sources are compiled with combinations of TRANS, UPPER, and UNIT, for 32 combinations total
|
# generates object files for each of the sources for each of the combinations of the preprocessor definitions passed in
|
||||||
set(TRM_SOURCES trmm_L.c trmm_R.c trsm_L.c trsm_R.c)
|
function(GenerateObjects sources_in defines_in)
|
||||||
AllCombinations("TRANS;UPPER;UNIT")
|
AllCombinations("${defines_in}")
|
||||||
set(TRM_DEFINE_COMBOS ${LIST_OUT})
|
set(define_combos ${LIST_OUT})
|
||||||
foreach (trm_source ${TRM_SOURCES})
|
foreach (source_file ${sources_in})
|
||||||
foreach (trm_defines ${TRM_DEFINE_COMBOS})
|
foreach (def_combo ${define_combos})
|
||||||
|
|
||||||
# replace colon separated list with semicolons, this turns it into a CMake list that we can use foreach with
|
# 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})
|
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)
|
# 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 "")
|
set(obj_name "")
|
||||||
foreach (trm_define ${trm_defines})
|
foreach (combo_elem ${def_combo})
|
||||||
string(REGEX MATCH "^[A-Z][A-Z]" letter ${trm_define})
|
string(REGEX MATCH "^[A-Z][A-Z]" letter ${combo_elem})
|
||||||
set(trm_obj_name "${trm_obj_name}${letter}")
|
set(obj_name "${obj_name}${letter}")
|
||||||
endforeach ()
|
endforeach ()
|
||||||
|
|
||||||
# parse file name
|
# parse file name
|
||||||
string(REGEX MATCH "[a-z]+_[LR]" trm_name ${trm_source})
|
string(REGEX MATCH "[a-z]+_[LR]" source_name ${source_file})
|
||||||
string(TOUPPER ${trm_name} trm_name)
|
string(TOUPPER ${source_name} source_name)
|
||||||
|
|
||||||
# prepend the uppercased file name to the obj name
|
# prepend the uppercased file name to the obj name
|
||||||
set(trm_obj_name "${trm_name}_${trm_obj_name}_OBJS")
|
set(obj_name "${source_name}_${obj_name}_OBJS")
|
||||||
|
|
||||||
# now add the object and set the defines
|
# now add the object and set the defines
|
||||||
add_library(${trm_obj_name} OBJECT ${trm_source})
|
add_library(${obj_name} OBJECT ${source_file})
|
||||||
set_target_properties(${trm_obj_name} PROPERTIES COMPILE_DEFINITIONS "${trm_defines}")
|
set_target_properties(${obj_name} PROPERTIES COMPILE_DEFINITIONS "${def_combo}")
|
||||||
endforeach ()
|
endforeach ()
|
||||||
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)
|
||||||
|
set(TRM_DEFINES TRANS UPPER UNIT)
|
||||||
|
GenerateObjects("${TRM_SOURCES}" "${TRM_DEFINES}")
|
||||||
|
|
||||||
# dsymm_LU.c dsymm_LL.c dsymm_RU.c dsymm_RL.c
|
# dsymm_LU.c dsymm_LL.c dsymm_RU.c dsymm_RL.c
|
||||||
# dsyrk_UN.c dsyrk_UT.c dsyrk_LN.c dsyrk_LT.c
|
# dsyrk_UN.c dsyrk_UT.c dsyrk_LN.c dsyrk_LT.c
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
|
||||||
|
# NYI
|
Loading…
Reference in New Issue