|
| 1 | +function(ggml_add_cpu_backend_features cpu_name arch) |
| 2 | + # The feature detection code is compiled as a separate target so that |
| 3 | + # it can be built without the architecture flags |
| 4 | + # Since multiple variants of the CPU backend may be included in the same |
| 5 | + # build, using set_source_files_properties() to set the arch flags is not possible |
| 6 | + set(GGML_CPU_FEATS_NAME ${cpu_name}-feats) |
| 7 | + add_library(${GGML_CPU_FEATS_NAME} OBJECT ggml-cpu/cpu-feats-${arch}.cpp) |
| 8 | + target_include_directories(${GGML_CPU_FEATS_NAME} PRIVATE . .. ../include) |
| 9 | + target_compile_definitions(${GGML_CPU_FEATS_NAME} PRIVATE ${ARGN}) |
| 10 | + target_compile_definitions(${GGML_CPU_FEATS_NAME} PRIVATE GGML_BACKEND_DL GGML_BACKEND_BUILD GGML_BACKEND_SHARED) |
| 11 | + set_target_properties(${GGML_CPU_FEATS_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON) |
| 12 | + target_link_libraries(${cpu_name} PRIVATE ${GGML_CPU_FEATS_NAME}) |
| 13 | +endfunction() |
| 14 | + |
1 | 15 | function(ggml_add_cpu_backend_variant_impl tag_name)
|
2 | 16 | if (tag_name)
|
3 | 17 | set(GGML_CPU_NAME ggml-cpu-${tag_name})
|
@@ -296,18 +310,7 @@ function(ggml_add_cpu_backend_variant_impl tag_name)
|
296 | 310 | # the feature check relies on ARCH_DEFINITIONS, but it is not set with GGML_NATIVE
|
297 | 311 | message(FATAL_ERROR "GGML_NATIVE is not compatible with GGML_BACKEND_DL, consider using GGML_CPU_ALL_VARIANTS")
|
298 | 312 | endif()
|
299 |
| - |
300 |
| - # The feature detection code is compiled as a separate target so that |
301 |
| - # it can be built without the architecture flags |
302 |
| - # Since multiple variants of the CPU backend may be included in the same |
303 |
| - # build, using set_source_files_properties() to set the arch flags is not possible |
304 |
| - set(GGML_CPU_FEATS_NAME ${GGML_CPU_NAME}-feats) |
305 |
| - add_library(${GGML_CPU_FEATS_NAME} OBJECT ggml-cpu/cpu-feats-x86.cpp) |
306 |
| - target_include_directories(${GGML_CPU_FEATS_NAME} PRIVATE . .. ../include) |
307 |
| - target_compile_definitions(${GGML_CPU_FEATS_NAME} PRIVATE ${ARCH_DEFINITIONS}) |
308 |
| - target_compile_definitions(${GGML_CPU_FEATS_NAME} PRIVATE GGML_BACKEND_DL GGML_BACKEND_BUILD GGML_BACKEND_SHARED) |
309 |
| - set_target_properties(${GGML_CPU_FEATS_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON) |
310 |
| - target_link_libraries(${GGML_CPU_NAME} PRIVATE ${GGML_CPU_FEATS_NAME}) |
| 313 | + ggml_add_cpu_backend_features(${GGML_CPU_NAME} x86 ${ARCH_DEFINITIONS}) |
311 | 314 | endif()
|
312 | 315 | elseif (GGML_SYSTEM_ARCH STREQUAL "PowerPC")
|
313 | 316 | message(STATUS "PowerPC detected")
|
|
0 commit comments