Skip to content

Commit

Permalink
mump_common: separate C and Fortran object internal for compiler comp…
Browse files Browse the repository at this point in the history
…atibility
  • Loading branch information
scivision committed May 17, 2024
1 parent 880d235 commit 651e4f1
Showing 1 changed file with 53 additions and 39 deletions.
92 changes: 53 additions & 39 deletions cmake/mumps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,111 +30,125 @@ else()
endif()

# -- Mumps COMMON
set(COMM_SRC ${_s}mumps_ooc_common.F ${_s}mumps_static_mapping.F)
set(COMM_SRC_Fortran ${_s}mumps_ooc_common.F ${_s}mumps_static_mapping.F)

if(MUMPS_UPSTREAM_VERSION VERSION_LESS 5.0)
list(APPEND COMM_SRC ${_s}mumps_part9.F)
list(APPEND COMM_SRC_Fortran ${_s}mumps_part9.F)
endif()
if(MUMPS_UPSTREAM_VERSION VERSION_GREATER_EQUAL 5.0)
foreach(i IN ITEMS ana_omp_m.F double_linked_list.F fac_asm_build_sort_index_ELT_m.F fac_asm_build_sort_index_m.F fac_descband_data_m.F fac_future_niv2_mod.F fac_ibct_data_m.F fac_maprow_data_m.F front_data_mgt_m.F mumps_comm_ibcast.F mumps_l0_omp_m.F omp_tps_common_m.F)
list(APPEND COMM_SRC ${_s}${i})
list(APPEND COMM_SRC_Fortran ${_s}${i})
endforeach()
endif()
if(MUMPS_UPSTREAM_VERSION VERSION_GREATER_EQUAL 5.1)
foreach(i IN ITEMS ana_orderings_wrappers_m.F lr_common.F mumps_memory_mod.F)
list(APPEND COMM_SRC ${_s}${i})
list(APPEND COMM_SRC_Fortran ${_s}${i})
endforeach()
endif()
if(MUMPS_UPSTREAM_VERSION VERSION_GREATER_EQUAL 5.2)
list(APPEND COMM_SRC ${_s}mumps_mpitoomp_m.F)
list(APPEND COMM_SRC_Fortran ${_s}mumps_mpitoomp_m.F)
endif()
if(MUMPS_UPSTREAM_VERSION VERSION_GREATER_EQUAL 5.3)
list(APPEND COMM_SRC ${_s}ana_blk_m.F)
list(APPEND COMM_SRC_Fortran ${_s}ana_blk_m.F)
endif()
if(MUMPS_UPSTREAM_VERSION VERSION_GREATER_EQUAL 5.6)
list(APPEND COMM_SRC ${_s}mumps_pivnul_mod.F)
list(APPEND COMM_SRC_Fortran ${_s}mumps_pivnul_mod.F)
endif()
if(MUMPS_UPSTREAM_VERSION VERSION_GREATER_EQUAL 5.7)
list(APPEND COMM_SRC ${_s}sol_ds_common_m.F)
list(APPEND COMM_SRC_Fortran ${_s}sol_ds_common_m.F)
endif()

set(COMM_OTHER_SRC)
set(COMM_OTHER_C)
set(COMM_OTHER_Fortran)
foreach(i IN ITEMS mumps_common.c mumps_io_basic.c mumps_io_thread.c mumps_io_err.c mumps_io.c)
list(APPEND COMM_OTHER_SRC ${_s}${i})
list(APPEND COMM_OTHER_C ${_s}${i})
endforeach()
if(MUMPS_UPSTREAM_VERSION VERSION_GREATER_EQUAL 4.9 AND MUMPS_UPSTREAM_VERSION VERSION_LESS 5.6)
list(APPEND COMM_OTHER_SRC ${_s}mumps_size.c)
list(APPEND COMM_OTHER_C ${_s}mumps_size.c)
endif()
if(MUMPS_UPSTREAM_VERSION VERSION_GREATER_EQUAL 4.9 AND MUMPS_UPSTREAM_VERSION VERSION_LESS 5.1)
list(APPEND COMM_OTHER_SRC ${_s}tools_common_mod.F)
list(APPEND COMM_OTHER_Fortran ${_s}tools_common_mod.F)
endif()
if(MUMPS_UPSTREAM_VERSION VERSION_GREATER_EQUAL 4.10 AND MUMPS_UPSTREAM_VERSION VERSION_LESS 5.2)
list(APPEND COMM_OTHER_SRC ${_s}mumps_sol_es.F)
list(APPEND COMM_OTHER_Fortran ${_s}mumps_sol_es.F)
endif()
if(MUMPS_UPSTREAM_VERSION VERSION_GREATER_EQUAL 5.6)
list(APPEND COMM_SRC ${_s}mumps_addr.c)
list(APPEND COMM_OTHER_C ${_s}mumps_addr.c)
endif()

if(MUMPS_UPSTREAM_VERSION VERSION_GREATER_EQUAL 5.0)
foreach(i IN ITEMS ana_orderings.F ana_set_ordering.F ana_AMDMF.F bcast_errors.F estim_flops.F mumps_type2_blocking.F mumps_version.F mumps_print_defined.F mumps_numa.c tools_common.F)
list(APPEND COMM_OTHER_SRC ${_s}${i})
foreach(i IN ITEMS ana_orderings.F ana_set_ordering.F ana_AMDMF.F bcast_errors.F estim_flops.F mumps_type2_blocking.F mumps_version.F mumps_print_defined.F tools_common.F)
list(APPEND COMM_OTHER_Fortran ${_s}${i})
endforeach()
list(APPEND COMM_OTHER_C ${_s}mumps_numa.c)
endif()
if(MUMPS_UPSTREAM_VERSION VERSION_LESS 5.1)
list(APPEND COMM_OTHER_SRC ${_s}mumps_orderings.c)
list(APPEND COMM_OTHER_C ${_s}mumps_orderings.c)
endif()
if(MUMPS_UPSTREAM_VERSION VERSION_GREATER_EQUAL 5.1)
foreach(i IN ITEMS mumps_pord.c mumps_thread.c mumps_save_restore_C.c)
list(APPEND COMM_OTHER_SRC ${_s}${i})
list(APPEND COMM_OTHER_C ${_s}${i})
endforeach()
endif()
if(MUMPS_UPSTREAM_VERSION VERSION_GREATER_EQUAL 5.2)
foreach(i IN ITEMS mumps_config_file_C.c mumps_thread_affinity.c sol_common.F)
list(APPEND COMM_OTHER_SRC ${_s}${i})
foreach(i IN ITEMS mumps_config_file_C.c mumps_thread_affinity.c)
list(APPEND COMM_OTHER_C ${_s}${i})
endforeach()
list(APPEND COMM_OTHER_Fortran ${_s}sol_common.F)
endif()
if(MUMPS_UPSTREAM_VERSION VERSION_GREATER_EQUAL 5.3)
list(APPEND COMM_OTHER_SRC ${_s}ana_blk.F)
list(APPEND COMM_OTHER_Fortran ${_s}ana_blk.F)
endif()
if(MUMPS_UPSTREAM_VERSION VERSION_GREATER_EQUAL 5.3)
list(APPEND COMM_OTHER_SRC ${_s}mumps_register_thread.c)
list(APPEND COMM_OTHER_C ${_s}mumps_register_thread.c)
endif()
if(MUMPS_UPSTREAM_VERSION VERSION_GREATER_EQUAL 5.0 AND MUMPS_UPSTREAM_VERSION VERSION_LESS 5.7)
list(APPEND COMM_OTHER_SRC ${_s}mumps_type_size.F)
list(APPEND COMM_OTHER_Fortran ${_s}mumps_type_size.F)
endif()

if(MUMPS_UPSTREAM_VERSION VERSION_GREATER_EQUAL 5.1)
if(scotch)
foreach(i IN ITEMS mumps_scotch.c mumps_scotch64.c mumps_scotch_int.c)
list(APPEND COMM_OTHER_SRC ${_s}${i})
list(APPEND COMM_OTHER_C ${_s}${i})
endforeach()
endif()
if(metis OR parmetis)
foreach(i IN ITEMS mumps_metis.c mumps_metis64.c mumps_metis_int.c)
list(APPEND COMM_OTHER_SRC ${_s}${i})
list(APPEND COMM_OTHER_C ${_s}${i})
endforeach()
endif()
endif()

add_library(mumps_common ${COMM_SRC} ${COMM_OTHER_SRC})
target_link_libraries(mumps_common PUBLIC ${ORDERING_LIBS} ${NUMERIC_LIBS})
target_include_directories(mumps_common PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR};${mumps_SOURCE_DIR}/include;${NUMERIC_INC}>"
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
add_library(mumps_common_C OBJECT ${COMM_OTHER_C})
add_library(mumps_common_Fortran OBJECT ${COMM_SRC_Fortran} ${COMM_OTHER_Fortran})

add_library(mumps_common $<TARGET_OBJECTS:mumps_common_Fortran> $<TARGET_OBJECTS:mumps_common_C>)

target_compile_definitions(mumps_common PRIVATE
${ORDERING_DEFS}
$<$<AND:$<COMPILE_LANGUAGE:Fortran>,$<NOT:$<BOOL:${scalapack}>>>:NOSCALAPACK>
)
set(BLAS_HAVE_GEMMT FALSE)
if(BLAS_HAVE_sGEMMT OR BLAS_HAVE_dGEMMT OR BLAS_HAVE_cGEMMT OR BLAS_HAVE_zGEMMT)
target_compile_definitions(mumps_common PRIVATE $<$<COMPILE_LANGUAGE:Fortran>:GEMMT_AVAILABLE>)
set(BLAS_HAVE_GEMMT TRUE)
endif()

foreach(t IN ITEMS mumps_common mumps_common_C mumps_common_Fortran)
target_include_directories(${t} PUBLIC
"$<BUILD_INTERFACE:${mumps_SOURCE_DIR};${mumps_SOURCE_DIR}/include;${NUMERIC_INC}>"
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

target_link_libraries(${t} PUBLIC ${ORDERING_LIBS} ${NUMERIC_LIBS})

target_compile_definitions(${t} PRIVATE
${ORDERING_DEFS}
$<$<AND:$<COMPILE_LANGUAGE:Fortran>,$<NOT:$<BOOL:${scalapack}>>>:NOSCALAPACK>
)

if(BLAS_HAVE_GEMMT)
target_compile_definitions(${t} PRIVATE $<$<COMPILE_LANGUAGE:Fortran>:GEMMT_AVAILABLE>)
endif()
endforeach()

set_property(TARGET mumps_common PROPERTY EXPORT_NAME COMMON)
set_property(TARGET mumps_common PROPERTY VERSION ${MUMPS_VERSION})
# MUMPS doesn't yet publicly use Fortran .mod files, but does need them somewhere
set_property(TARGET mumps_common PROPERTY Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include)

install(TARGETS mumps_common EXPORT ${PROJECT_NAME}-targets)

Expand Down Expand Up @@ -222,7 +236,7 @@ $<$<AND:$<BOOL:${BLAS_HAVE_${a}GEMMT}>,$<COMPILE_LANGUAGE:Fortran>>:GEMMT_AVAILA
$<$<AND:$<COMPILE_LANGUAGE:Fortran>,$<NOT:$<BOOL:${scalapack}>>>:NOSCALAPACK>
)
target_include_directories(${a}mumps PUBLIC
"$<BUILD_INTERFACE:${mumps_SOURCE_DIR}/include;${NUMERIC_INC};${CMAKE_CURRENT_BINARY_DIR}/include>"
"$<BUILD_INTERFACE:${mumps_SOURCE_DIR}/include;${NUMERIC_INC}>"
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_link_libraries(${a}mumps PUBLIC mumps_common)
Expand Down

0 comments on commit 651e4f1

Please sign in to comment.