|
| 1 | +# there is a lot of custom directories to circonvent the deletion of the |
| 2 | +# CMakeLists.txt contained in the DDalphaAMG directory. CMake will clone the |
| 3 | +# source code and build it with the default options used in the ci/cd. More |
| 4 | +# options are available in the main CMakeLists.txt. |
| 5 | + |
| 6 | +include(GNUInstallDirs) |
| 7 | + |
| 8 | +set(DDalphaAMG_SRC_DIR ${CMAKE_SOURCE_DIR}/DDalphaAMG/deps) |
| 9 | + |
| 10 | +FetchContent_Declare( |
| 11 | + DDalphaAMG |
| 12 | + GIT_REPOSITORY https://github.com/etmc/DDalphaAMG.git |
| 13 | + SOURCE_DIR ${DDalphaAMG_SRC_DIR}) |
| 14 | + |
| 15 | +FetchContent_MakeAvailable(DDalphaAMG) |
| 16 | + |
| 17 | +list( |
| 18 | + APPEND |
| 19 | + DDalphaAMG_SRC_GENERIC |
| 20 | + interpolation_generic.c |
| 21 | + gathering_generic.c |
| 22 | + sse_interpolation_generic.c |
| 23 | + coarse_oddeven_generic.c |
| 24 | + operator_generic.c |
| 25 | + oddeven_generic.c |
| 26 | + linalg_generic.c |
| 27 | + init_generic.c |
| 28 | + vcycle_generic.c |
| 29 | + dirac_generic.c |
| 30 | + coarse_operator_generic.c |
| 31 | + coarsening_generic.c |
| 32 | + schwarz_generic.c |
| 33 | + ghost_generic.c |
| 34 | + vectorization_dirac_generic.c |
| 35 | + linsolve_generic.c |
| 36 | + sse_coarse_operator_generic.c |
| 37 | + data_generic.c |
| 38 | + setup_generic.c |
| 39 | + sse_linalg_generic.c) |
| 40 | + |
| 41 | +list( |
| 42 | + APPEND |
| 43 | + DDalphaAMG_HEADER_GENERIC |
| 44 | + interpolation_generic.h |
| 45 | + gathering_generic.h |
| 46 | + sse_interpolation_generic.h |
| 47 | + coarse_oddeven_generic.h |
| 48 | + operator_generic.h |
| 49 | + oddeven_generic.h |
| 50 | + linalg_generic.h |
| 51 | + init_generic.h |
| 52 | + vcycle_generic.h |
| 53 | + dirac_generic.h |
| 54 | + coarse_operator_generic.h |
| 55 | + coarsening_generic.h |
| 56 | + schwarz_generic.h |
| 57 | + ghost_generic.h |
| 58 | + vectorization_dirac_generic.h |
| 59 | + linsolve_generic.h |
| 60 | + sse_coarse_operator_generic.h |
| 61 | + data_generic.h |
| 62 | + setup_generic.h |
| 63 | + sse_linalg_generic.h |
| 64 | + main_pre_def_generic.h |
| 65 | + main_post_def_generic.h) |
| 66 | + |
| 67 | +list( |
| 68 | + APPEND |
| 69 | + DDalphaAMG_SRC_GENERAL |
| 70 | + ${DDalphaAMG_SRC_DIR}/src/preconditioner.c |
| 71 | + ${DDalphaAMG_SRC_DIR}/src/threading.c |
| 72 | + ${DDalphaAMG_SRC_DIR}/src/main.c |
| 73 | + ${DDalphaAMG_SRC_DIR}/src/sse_dirac.c |
| 74 | + ${DDalphaAMG_SRC_DIR}/src/var_table.c |
| 75 | + ${DDalphaAMG_SRC_DIR}/src/data_layout.c |
| 76 | + ${DDalphaAMG_SRC_DIR}/src/linsolve.c |
| 77 | + ${DDalphaAMG_SRC_DIR}/src/ghost.c |
| 78 | + ${DDalphaAMG_SRC_DIR}/src/top_level.c |
| 79 | + ${DDalphaAMG_SRC_DIR}/src/dirac.c |
| 80 | + ${DDalphaAMG_SRC_DIR}/src/linalg.c |
| 81 | + ${DDalphaAMG_SRC_DIR}/src/init.c |
| 82 | + ${DDalphaAMG_SRC_DIR}/src/DDalphaAMG_interface.c |
| 83 | + ${DDalphaAMG_SRC_DIR}/src/lime_io.c |
| 84 | + ${DDalphaAMG_SRC_DIR}/src/sse_linalg.c |
| 85 | + ${DDalphaAMG_SRC_DIR}/src/solver_analysis.c |
| 86 | + ${DDalphaAMG_SRC_DIR}/src/io.c) |
| 87 | + |
| 88 | +foreach(f IN LISTS DDalphaAMG_SRC_GENERIC) |
| 89 | + string(REPLACE "_generic" "_float" f_float "${f}") |
| 90 | + |
| 91 | + add_custom_command( |
| 92 | + OUTPUT "${CMAKE_BINARY_DIR}/DDalphaAMG/${f_float}.sed-done" |
| 93 | + COMMAND |
| 94 | + sed -f "${DDalphaAMG_SRC_DIR}/float.sed" "${DDalphaAMG_SRC_DIR}/src/${f}" |
| 95 | + > "${CMAKE_BINARY_DIR}/DDalphaAMG/${f_float}" |
| 96 | + COMMAND ${CMAKE_COMMAND} -E touch |
| 97 | + "${CMAKE_BINARY_DIR}/DDalphaAMG/${f_float}.sed-done" |
| 98 | + DEPENDS "${DDalphaAMG_SRC_DIR}/src/${f}" "${DDalphaAMG_SRC_DIR}/float.sed" |
| 99 | + VERBATIM) |
| 100 | + list(APPEND SED_MARKERS "${CMAKE_BINARY_DIR}/DDalphaAMG/${f_float}.sed-done") |
| 101 | + list(APPEND DDalphaAMG_SRC_SINGLE_DOUBLE ${f_float}) |
| 102 | + |
| 103 | + string(REPLACE "_generic" "_double" f_double "${f}") |
| 104 | + add_custom_command( |
| 105 | + OUTPUT "${CMAKE_BINARY_DIR}/DDalphaAMG/${f_double}.sed-done" |
| 106 | + COMMAND |
| 107 | + sed -f "${DDalphaAMG_SRC_DIR}/double.sed" "${DDalphaAMG_SRC_DIR}/src/${f}" |
| 108 | + > "${CMAKE_BINARY_DIR}/DDalphaAMG/${f_double}" |
| 109 | + COMMAND ${CMAKE_COMMAND} -E touch |
| 110 | + "${CMAKE_BINARY_DIR}/DDalphaAMG/${f_double}.sed-done" |
| 111 | + DEPENDS "${DDalphaAMG_SRC_DIR}/src/${f}" "${DDalphaAMG_SRC_DIR}/double.sed" |
| 112 | + VERBATIM) |
| 113 | + list(APPEND SED_MARKERS "${CMAKE_BINARY_DIR}/DDalphaAMG/${f_double}.sed-done") |
| 114 | + list(APPEND DDalphaAMG_SRC_SINGLE_DOUBLE ${f_double}) |
| 115 | +endforeach() |
| 116 | + |
| 117 | +# now parse the header |
| 118 | +foreach(f IN LISTS DDalphaAMG_HEADER_GENERIC) |
| 119 | + string(REPLACE "_generic" "_float" f_float "${f}") |
| 120 | + add_custom_command( |
| 121 | + OUTPUT "${CMAKE_BINARY_DIR}/DDalphaAMG/${f_float}.sed-done" |
| 122 | + COMMAND |
| 123 | + sed -f "${DDalphaAMG_SRC_DIR}/float.sed" "${DDalphaAMG_SRC_DIR}/src/${f}" |
| 124 | + > "${CMAKE_BINARY_DIR}/DDalphaAMG/${f_float}" |
| 125 | + COMMAND ${CMAKE_COMMAND} -E touch |
| 126 | + "${CMAKE_BINARY_DIR}/DDalphaAMG/${f_float}.sed-done" |
| 127 | + DEPENDS "${DDalphaAMG_SRC_DIR}/src/${f}" "${DDalphaAMG_SRC_DIR}/float.sed" |
| 128 | + VERBATIM) |
| 129 | + list(APPEND SED_MARKERS "${CMAKE_BINARY_DIR}/DDalphaAMG/${f_float}.sed-done") |
| 130 | + list(APPEND DDalphaAMG_HEADER_SINGLE_DOUBLE ${f_float}) |
| 131 | + |
| 132 | + string(REPLACE "_generic" "_double" f_double "${f}") |
| 133 | + add_custom_command( |
| 134 | + OUTPUT "${CMAKE_BINARY_DIR}/DDalphaAMG/${f_double}.sed-done" |
| 135 | + COMMAND |
| 136 | + sed -f "${DDalphaAMG_SRC_DIR}/double.sed" "${DDalphaAMG_SRC_DIR}/src/${f}" |
| 137 | + > "${CMAKE_BINARY_DIR}/DDalphaAMG/${f_double}" |
| 138 | + COMMAND ${CMAKE_COMMAND} -E touch |
| 139 | + "${CMAKE_BINARY_DIR}/DDalphaAMG/${f_double}.sed-done" |
| 140 | + DEPENDS "${DDalphaAMG_SRC_DIR}/src/${f}" "${DDalphaAMG_SRC_DIR}/double.sed" |
| 141 | + VERBATIM) |
| 142 | + |
| 143 | + list(APPEND SED_MARKERS "${CMAKE_BINARY_DIR}/DDalphaAMG/${f_double}.sed-done") |
| 144 | + list(APPEND DDalphaAMG_HEADER_SINGLE_DOUBLE ${f_double}) |
| 145 | +endforeach() |
| 146 | + |
| 147 | +foreach(outfile IN LISTS DDalphaAMG_SRC_SINGLE_DOUBLE |
| 148 | + DDalphaAMG_HEADER_SINGLE_DOUBLE) |
| 149 | + set_source_files_properties("${CMAKE_BINARY_DIR}/DDalphaAMG/${outfile}" |
| 150 | + PROPERTIES GENERATED TRUE) |
| 151 | +endforeach() |
| 152 | + |
| 153 | +add_custom_target(run_sed ALL DEPENDS ${SED_MARKERS}) |
| 154 | + |
| 155 | +add_library(DDalphaAMG ${DDalphaAMG_SRC_GENERAL} |
| 156 | + ${DDalphaAMG_SRC_SINGLE_DOUBLE}) |
| 157 | + |
| 158 | +target_compile_options(DDalphaAMG |
| 159 | + PRIVATE "$<$<COMPILE_LANG_AND_ID:C,GNU>:-O3;-ffast-math;-mavx2;-mfma>") |
| 160 | + |
| 161 | +add_dependencies(DDalphaAMG run_sed) |
| 162 | + |
| 163 | +target_link_libraries( |
| 164 | + DDalphaAMG |
| 165 | + PUBLIC MPI::MPI_C $<$<BOOL:${DDalphaAMG_ENABLE_HDF5}>:hdf5:hdf5> |
| 166 | + $<$<BOOL:${DDalphaAMG_ENABLE_OMP}>:OpenMP::OpenMP_C> tmlqcd::clime) |
| 167 | + |
| 168 | +target_include_directories( |
| 169 | + DDalphaAMG |
| 170 | + PUBLIC $<INSTALL_INTERFACE:include> |
| 171 | + $<BUILD_INTERFACE:${DDalphaAMG_SRC_DIR}/src> |
| 172 | + $<BUILD_INTERFACE:${DDalphaAMG_SRC_DIR}/include> |
| 173 | + $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/DDalphaAMG>) |
| 174 | + |
| 175 | +target_compile_definitions( |
| 176 | + DDalphaAMG |
| 177 | + PUBLIC |
| 178 | + $<$<BOOL:${DDalphaAMG_ENABLE_PARAMOUNT_OUTPUT}>:PARAMOUNTOUTPUT> |
| 179 | + $<$<BOOL:${DDalphaAMG_ENABLE_FGMRES_RESTEST}>:FGMRES_RESTEST> |
| 180 | + $<$<BOOL:${DDalphaAMG_ENABLE_PROFILING}>:PROFILING> |
| 181 | + $<$<BOOL:${DDalphaAMG_ENABLE_SINGLE_ALLREDUCE_ARNOLDI}>:SINGLE_ALLREDUCE_ARNOLDI> |
| 182 | + $<$<BOOL:${DDalphaAMG_ENABLE_COARSE_RES}>:COARSE_RES> |
| 183 | + $<$<BOOL:${DDalphaAMG_ENABLE_SCHWARZ_RES}>:SCHWARZ_RES> |
| 184 | + $<$<BOOL:${DDalphaAMG_ENABLE_OMP}>:OPENMP> |
| 185 | + $<$<BOOL:${DDalphaAMG_ENABLE_TRACK_RES}>:TRACK_RES> |
| 186 | + $<$<BOOL:${DDalphaAMG_ENABLE_TESTVECTOR_ANALYSIS}>:TESTVECTOR_ANALYSIS> |
| 187 | + $<$<BOOL:${DDalphaAMG_ENABLE_HDF5}>:HAVE_HDF5> |
| 188 | + $<$<CONFIG:Debug>:DEBUG> |
| 189 | + SSE) |
| 190 | + |
| 191 | +install(FILES "${CMAKE_SOURCE_DIR}/deps/DDalphaAMG/DDalphaAMG.h" |
| 192 | + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}") |
| 193 | + |
| 194 | +write_basic_package_version_file( |
| 195 | + "${PROJECT_BINARY_DIR}/DDalphaAMGonfigVersion.cmake" |
| 196 | + VERSION "0.0.0" |
| 197 | + COMPATIBILITY SameMajorVersion) |
| 198 | + |
| 199 | +install(TARGETS DDalphaAMG |
| 200 | + EXPORT DDalphaAMG_targets |
| 201 | + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") |
| 202 | + |
| 203 | +install(EXPORT DDalphaAMG_targets |
| 204 | + FILE DDalphaAMG-Targets.cmake |
| 205 | + NAMESPACE DDalphaAMG:: |
| 206 | + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") |
| 207 | + |
| 208 | +configure_file("${PROJECT_SOURCE_DIR}/cmake/DDalphaAMG-Config.cmake.in" |
| 209 | + "${PROJECT_BINARY_DIR}/DDalphaAMG-Config.cmake" @ONLY) |
| 210 | + |
| 211 | +install(FILES "${PROJECT_BINARY_DIR}/DDalphaAMG-Config.cmake" |
| 212 | + "${PROJECT_BINARY_DIR}/DDalphaAMG-ConfigVersion.cmake" |
| 213 | + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/tmlQCD") |
| 214 | + |
| 215 | + |
| 216 | +# add_library(tmlqcd::DDalphaAMG alias DDalphaAMG) |
0 commit comments