|
| 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/arch/${arch}/cpu-feats.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})
|
@@ -306,18 +320,7 @@ function(ggml_add_cpu_backend_variant_impl tag_name)
|
306 | 320 | # the feature check relies on ARCH_DEFINITIONS, but it is not set with GGML_NATIVE
|
307 | 321 | message(FATAL_ERROR "GGML_NATIVE is not compatible with GGML_BACKEND_DL, consider using GGML_CPU_ALL_VARIANTS")
|
308 | 322 | endif()
|
309 |
| - |
310 |
| - # The feature detection code is compiled as a separate target so that |
311 |
| - # it can be built without the architecture flags |
312 |
| - # Since multiple variants of the CPU backend may be included in the same |
313 |
| - # build, using set_source_files_properties() to set the arch flags is not possible |
314 |
| - set(GGML_CPU_FEATS_NAME ${GGML_CPU_NAME}-feats) |
315 |
| - add_library(${GGML_CPU_FEATS_NAME} OBJECT ggml-cpu/arch/x86/cpu-feats.cpp) |
316 |
| - target_include_directories(${GGML_CPU_FEATS_NAME} PRIVATE . .. ../include) |
317 |
| - target_compile_definitions(${GGML_CPU_FEATS_NAME} PRIVATE ${ARCH_DEFINITIONS}) |
318 |
| - target_compile_definitions(${GGML_CPU_FEATS_NAME} PRIVATE GGML_BACKEND_DL GGML_BACKEND_BUILD GGML_BACKEND_SHARED) |
319 |
| - set_target_properties(${GGML_CPU_FEATS_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON) |
320 |
| - target_link_libraries(${GGML_CPU_NAME} PRIVATE ${GGML_CPU_FEATS_NAME}) |
| 323 | + ggml_add_cpu_backend_features(${GGML_CPU_NAME} x86 ${ARCH_DEFINITIONS}) |
321 | 324 | endif()
|
322 | 325 | elseif (GGML_SYSTEM_ARCH STREQUAL "PowerPC")
|
323 | 326 | message(STATUS "PowerPC detected")
|
|
0 commit comments