commit 6feabe6fffbd44c16a643159e0dc87bcc8f2282f
parent c61590410510d93a5568855680327c9fd553b706
Author: [email protected] <[email protected]>
Date: Wed, 22 Nov 2023 15:31:42 +0000
Force linking in correct order
Diffstat:
2 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
@@ -201,6 +201,16 @@ if (X86)
target_set_arch(detect_cpu PRIVATE generic)
endif ()
+function (link_as_whole TARGET TYPE LIBRARY)
+ if (APPLE)
+ target_link_options(${TARGET} ${TYPE} -Wl,-force_load $<TARGET_FILE:${LIBRARY}>)
+ elseif (WIN32)
+ target_link_options(${TARGET} ${TYPE} /WHOLEARCHIVE:$<TARGET_FILE:${LIBRARY}>)
+ else ()
+ target_link_options(${TARGET} ${TYPE} -Wl,--push-state,--whole-archive $<TARGET_FILE:${LIBRARY}> -Wl,--pop-state)
+ endif ()
+endfunction()
+
function (add_arch_library NAME ARCH SRCS DEFS)
add_library(${NAME}_${ARCH} ${SRCS})
target_link_libraries(${NAME}_${ARCH} kfr)
@@ -233,6 +243,8 @@ if (KFR_ENABLE_DFT)
add_arch_library(kfr_dft avx2 "${KFR_DFT_SRC}" "${KFR_DFT_DEFS}")
add_arch_library(kfr_dft avx512 "${KFR_DFT_SRC}" "${KFR_DFT_DEFS}")
+ link_as_whole(kfr_dft_all INTERFACE kfr_dft_sse2)
+
else ()
add_library(kfr_dft ${KFR_DFT_SRC})
target_link_libraries(kfr_dft kfr use_arch)
diff --git a/capi/CMakeLists.txt b/capi/CMakeLists.txt
@@ -86,6 +86,11 @@ add_c_library(avx)
add_c_library(avx2)
add_c_library(avx512)
+link_as_whole(kfr_capi_all INTERFACE kfr_capi_sse2)
+if (NOT WIN32)
+ link_as_whole(kfr_capi_all_pic INTERFACE kfr_capi_sse2_pic)
+endif()
+
target_compile_definitions(
kfr_capi
PRIVATE -DKFR_DFT_MULTI=1