Changed strategy for setting preprocessor definitions.
Instead of generating separate object files for each permutation of defines for a source file, GenerateNamedObjects now writes an entirely new source file and inserts the defines as #define c statements. This solves a problem I ran into with ar.exe where it was refusing to link objects that had the same filename despite having different paths.
This commit is contained in:
parent
12d1fb2e40
commit
0d8e227ea7
|
@ -75,24 +75,16 @@ if (NOT DEFINED CORE OR "${CORE}" STREQUAL "UNKNOWN")
|
|||
message(FATAL_ERROR "Detecting CPU failed. Please set TARGET explicitly, e.g. make TARGET=your_cpu_target. Please read README for details.")
|
||||
endif ()
|
||||
|
||||
# Let CMake handle this
|
||||
#if (${NOFORTRAN})
|
||||
# message(ERROR "OpenBLAS: Detecting fortran compiler failed. Please install fortran compiler, e.g. gfortran, ifort, openf90.")
|
||||
#endif ()
|
||||
|
||||
if (${NO_STATIC} AND ${NO_SHARED})
|
||||
message(FATAL_ERROR "Neither static nor shared are enabled.")
|
||||
endif ()
|
||||
|
||||
set(DBLAS_OBJS "")
|
||||
foreach (SUBDIR ${SUBDIRS})
|
||||
add_subdirectory(${SUBDIR})
|
||||
endforeach ()
|
||||
|
||||
# get obj vars into format that add_library likes: $<TARGET_OBJS:objlib> (see http://www.cmake.org/cmake/help/v3.0/command/add_library.html)
|
||||
set(TARGET_OBJS "")
|
||||
foreach (DBLAS_OBJ ${DBLAS_OBJS})
|
||||
list(APPEND TARGET_OBJS "$<TARGET_OBJECTS:${DBLAS_OBJ}>")
|
||||
foreach (SUBDIR ${SUBDIRS})
|
||||
add_subdirectory(${SUBDIR})
|
||||
string(REPLACE "/" "_" subdir_obj ${SUBDIR})
|
||||
list(APPEND TARGET_OBJS "$<TARGET_OBJECTS:${subdir_obj}>")
|
||||
endforeach ()
|
||||
|
||||
# netlib:
|
||||
|
|
|
@ -13,7 +13,6 @@ function(ParseGetArchVars GETARCH_IN)
|
|||
endfunction ()
|
||||
|
||||
# Reads a Makefile into CMake vars.
|
||||
# TODO: respect IFDEF/IFNDEF?
|
||||
macro(ParseMakefileVars MAKEFILE_IN)
|
||||
message(STATUS "Reading vars from ${MAKEFILE_IN}...")
|
||||
file(STRINGS ${MAKEFILE_IN} makefile_contents)
|
||||
|
@ -215,16 +214,30 @@ function(GenerateNamedObjects sources_in)
|
|||
endif ()
|
||||
endif ()
|
||||
|
||||
add_library(${obj_name} OBJECT ${source_file})
|
||||
set_target_properties(${obj_name} PROPERTIES COMPILE_DEFINITIONS "${obj_defines}")
|
||||
if (VERBOSE_GEN)
|
||||
message(STATUS "${obj_name}:${source_file}")
|
||||
message(STATUS "${obj_defines}")
|
||||
endif ()
|
||||
|
||||
list(APPEND OBJ_LIST_OUT ${obj_name})
|
||||
# create a copy of the source to avoid duplicate obj filename problem with ar.exe
|
||||
get_filename_component(source_extension ${source_file} EXT)
|
||||
set(new_source_file "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${obj_name}${source_extension}")
|
||||
if (IS_ABSOLUTE ${source_file})
|
||||
set(old_source_file ${source_file})
|
||||
else ()
|
||||
set(old_source_file "${CMAKE_CURRENT_LIST_DIR}/${source_file}")
|
||||
endif ()
|
||||
|
||||
string(REPLACE ";" "\n#define " define_source "${obj_defines}")
|
||||
string(REPLACE "=" " " define_source "${define_source}")
|
||||
file(WRITE ${new_source_file} "#define ${define_source}\n#include \"${old_source_file}\"")
|
||||
list(APPEND SRC_LIST_OUT ${new_source_file})
|
||||
|
||||
endforeach ()
|
||||
endforeach ()
|
||||
|
||||
list(APPEND DBLAS_OBJS ${OBJ_LIST_OUT})
|
||||
set(DBLAS_OBJS ${DBLAS_OBJS} PARENT_SCOPE)
|
||||
list(APPEND OPENBLAS_SRC ${SRC_LIST_OUT})
|
||||
set(OPENBLAS_SRC ${OPENBLAS_SRC} PARENT_SCOPE)
|
||||
endfunction ()
|
||||
|
||||
# generates object files for each of the sources for each of the combinations of the preprocessor definitions passed in
|
||||
|
@ -260,7 +273,6 @@ function(GenerateCombinationObjects sources_in defines_in absent_codes_in all_de
|
|||
set(define_combos ${LIST_OUT})
|
||||
set(define_codes ${CODES_OUT})
|
||||
|
||||
set(COMBO_OBJ_LIST_OUT "")
|
||||
list(LENGTH define_combos num_combos)
|
||||
math(EXPR num_combos "${num_combos} - 1")
|
||||
|
||||
|
@ -322,10 +334,9 @@ function(GenerateCombinationObjects sources_in defines_in absent_codes_in all_de
|
|||
endif ()
|
||||
|
||||
GenerateNamedObjects("${source_file}" "${cur_defines}" "${alternate_name}" false "${replace_code}" "${append_code}" "${no_float_type}" "${complex_filename_scheme}")
|
||||
list(APPEND COMBO_OBJ_LIST_OUT "${OBJ_LIST_OUT}")
|
||||
endforeach ()
|
||||
endforeach ()
|
||||
|
||||
set(DBLAS_OBJS ${DBLAS_OBJS} PARENT_SCOPE)
|
||||
set(OPENBLAS_SRC ${OPENBLAS_SRC} PARENT_SCOPE)
|
||||
endfunction ()
|
||||
|
||||
|
|
|
@ -115,5 +115,4 @@ if (SMP)
|
|||
|
||||
endif ()
|
||||
|
||||
set(DBLAS_OBJS ${DBLAS_OBJS} PARENT_SCOPE) # list append removes the scope from DBLAS_OBJS
|
||||
|
||||
add_library(driver_level2 OBJECT ${OPENBLAS_SRC})
|
||||
|
|
|
@ -69,5 +69,4 @@ endforeach ()
|
|||
#endif
|
||||
#
|
||||
|
||||
set(DBLAS_OBJS ${DBLAS_OBJS} PARENT_SCOPE) # list append removes the scope from DBLAS_OBJS
|
||||
|
||||
add_library(driver_level3 OBJECT ${OPENBLAS_SRC})
|
||||
|
|
|
@ -62,14 +62,6 @@ endif ()
|
|||
#COMMONOBJS += profile.$(SUFFIX)
|
||||
#endif
|
||||
|
||||
add_library(COMMON_OBJS OBJECT
|
||||
${MEMORY}
|
||||
${SMP_SOURCES}
|
||||
${COMMON_SOURCES}
|
||||
)
|
||||
|
||||
list(APPEND DBLAS_OBJS "COMMON_OBJS")
|
||||
|
||||
#LIBOTHERS = libothers.$(LIBSUFFIX)
|
||||
|
||||
#ifeq ($(DYNAMIC_ARCH), 1)
|
||||
|
@ -78,5 +70,4 @@ list(APPEND DBLAS_OBJS "COMMON_OBJS")
|
|||
#HPLOBJS = memory.$(SUFFIX) xerbla.$(SUFFIX) parameter.$(SUFFIX)
|
||||
#endif
|
||||
|
||||
set(DBLAS_OBJS ${DBLAS_OBJS} PARENT_SCOPE) # list append removes the scope from DBLAS_OBJS
|
||||
|
||||
add_library(driver_others OBJECT ${OPENBLAS_SRC} ${MEMORY} ${SMP_SOURCES} ${COMMON_SOURCES})
|
||||
|
|
|
@ -117,5 +117,4 @@ if (NOT DEFINED NO_LAPACK)
|
|||
GenerateNamedObjects("${LAPACK_MANGLED_SOURCES}" "" "" 0 "" "" 0 3)
|
||||
endif ()
|
||||
|
||||
set(DBLAS_OBJS ${DBLAS_OBJS} PARENT_SCOPE) # list append removes the scope from DBLAS_OBJS
|
||||
|
||||
add_library(interface OBJECT ${OPENBLAS_SRC})
|
||||
|
|
|
@ -251,4 +251,4 @@ endforeach ()
|
|||
# Makefile.LA
|
||||
#DBLASOBJS += dneg_tcopy$(TSUFFIX).$(SUFFIX) dlaswp_ncopy$(TSUFFIX).$(SUFFIX)
|
||||
|
||||
set(DBLAS_OBJS ${DBLAS_OBJS} PARENT_SCOPE) # list append removes the scope from DBLAS_OBJS
|
||||
add_library(kernel OBJECT ${OPENBLAS_SRC})
|
||||
|
|
|
@ -99,5 +99,5 @@ GenerateCombinationObjects("${TRANS_SOURCES}" "TRANS" "N" "" 4 "" "" 3)
|
|||
GenerateCombinationObjects("${UNIT_SOURCES}" "UNIT" "N" "" 4)
|
||||
GenerateCombinationObjects("${UNIT_SOURCES2}" "UNIT" "N" "" 0 "" "" 3)
|
||||
|
||||
set(DBLAS_OBJS ${DBLAS_OBJS} PARENT_SCOPE) # list append removes the scope from DBLAS_OBJS
|
||||
add_library(lapack OBJECT ${OPENBLAS_SRC})
|
||||
|
||||
|
|
Loading…
Reference in New Issue