Skip to content

Commit 966f585

Browse files
committed
Refactor KFR modules
1 parent b35157f commit 966f585

2 files changed

Lines changed: 54 additions & 15 deletions

File tree

CMakeLists.txt

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,11 @@ if (CLANG)
217217
else ()
218218
option(KFR_ENABLE_DFT "Enable DFT and related algorithms." OFF)
219219
endif ()
220-
option(KFR_ENABLE_ASMTEST "Enable writing disassembly" OFF)
221220
option(KFR_ENABLE_AUDIO "Enable Audio classes" ON)
222221
option(KFR_ENABLE_IO "Enable IO classes" ON)
222+
option(KFR_ENABLE_DSP "Enable DSP module" ON)
223+
224+
option(KFR_ENABLE_ASMTEST "Enable writing disassembly" OFF)
223225
option(KFR_REGENERATE_TESTS "Regenerate auto tests" OFF)
224226
option(KFR_DISABLE_CLANG_EXTENSIONS "Disable Clang vector extensions" OFF)
225227
option(KFR_EXTENDED_TESTS "Extended tests (up to hour)" OFF)
@@ -425,9 +427,24 @@ if (MSVC)
425427
target_compile_options(kfr INTERFACE $<$<CXX_COMPILER_ID:MSVC>:/Zc:lambda>)
426428
endif ()
427429

428-
if (NOT KFR_ENABLE_DFT)
430+
if (KFR_ENABLE_DFT)
431+
target_compile_definitions(kfr INTERFACE $<BUILD_INTERFACE:KFR_HAVE_DFT>)
432+
else ()
429433
target_compile_definitions(kfr INTERFACE $<BUILD_INTERFACE:KFR_NO_DFT>)
430434
endif ()
435+
436+
if (KFR_ENABLE_DSP)
437+
target_compile_definitions(kfr INTERFACE $<BUILD_INTERFACE:KFR_HAVE_DSP>)
438+
endif ()
439+
440+
if (KFR_ENABLE_IO)
441+
target_compile_definitions(kfr INTERFACE $<BUILD_INTERFACE:KFR_HAVE_IO>)
442+
endif ()
443+
444+
if (KFR_ENABLE_AUDIO)
445+
target_compile_definitions(kfr INTERFACE $<BUILD_INTERFACE:KFR_HAVE_AUDIO>)
446+
endif ()
447+
431448
if (KFR_EXTENDED_TESTS)
432449
target_compile_definitions(kfr
433450
INTERFACE $<BUILD_INTERFACE:KFR_EXTENDED_TESTS>)
@@ -442,13 +459,23 @@ set(KFR_DEBUG_INSTALL_SUFFIX
442459
"/debug"
443460
CACHE STRING "")
444461

445-
add_subdirectory(src/dsp)
446-
if(KFR_ENABLE_IO)
447-
add_subdirectory(src/io)
448-
if(KFR_ENABLE_AUDIO)
462+
if (KFR_ENABLE_AUDIO AND NOT KFR_ENABLE_IO)
463+
message(FATAL_ERROR "KFR_ENABLE_AUDIO requires KFR_ENABLE_IO to be enabled")
464+
endif ()
465+
if (KFR_ENABLE_AUDIO AND NOT KFR_ENABLE_DSP)
466+
message(
467+
FATAL_ERROR "KFR_ENABLE_AUDIO requires KFR_ENABLE_DSP to be enabled")
468+
endif ()
469+
470+
if (KFR_ENABLE_DSP)
471+
add_subdirectory(src/dsp)
472+
endif ()
473+
if (KFR_ENABLE_IO)
474+
add_subdirectory(src/io)
475+
endif ()
476+
if (KFR_ENABLE_AUDIO)
449477
add_subdirectory(src/audio)
450-
endif()
451-
endif()
478+
endif ()
452479
if (KFR_ENABLE_DFT)
453480
add_subdirectory(src/dft)
454481
endif ()
@@ -481,14 +508,15 @@ if (KFR_ENABLE_DFT)
481508
append_defines_from(kfr_dft)
482509
endif ()
483510

484-
append_defines_from(kfr_dsp)
485-
486-
if(KFR_ENABLE_IO)
487-
append_defines_from(kfr_io)
488-
if(KFR_ENABLE_AUDIO)
511+
if (KFR_ENABLE_DSP)
512+
append_defines_from(kfr_dsp)
513+
endif ()
514+
if (KFR_ENABLE_IO)
515+
append_defines_from(kfr_io)
516+
endif ()
517+
if (KFR_ENABLE_AUDIO)
489518
append_defines_from(kfr_audio)
490-
endif()
491-
endif()
519+
endif ()
492520

493521
string(REPLACE "$<BUILD_INTERFACE:" "" kfr_defines "${kfr_defines}")
494522
string(REPLACE ">" "" kfr_defines "${kfr_defines}")

tests/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,17 @@ target_link_libraries(all_tests kfr use_arch kfr_dsp)
133133
if (KFR_ENABLE_DFT)
134134
target_link_libraries(all_tests kfr_dft)
135135
endif ()
136+
137+
if (NOT TARGET kfr_dsp)
138+
message(FATAL_ERROR "KFR DSP module is not built, cannot build tests")
139+
endif ()
140+
if (NOT TARGET kfr_io)
141+
message(FATAL_ERROR "KFR IO module is not built, cannot build tests")
142+
endif ()
143+
if (NOT TARGET kfr_audio)
144+
message(FATAL_ERROR "KFR Audio module is not built, cannot build tests")
145+
endif ()
146+
136147
target_link_libraries(all_tests kfr_io)
137148
138149
option(KFR_NO_PERF_TESTS "Disable performance tests" OFF)

0 commit comments

Comments
 (0)