kfr

Fast, modern C++ DSP framework, FFT, Sample Rate Conversion, FIR/IIR/Biquad Filters (SSE, AVX, AVX-512, ARM NEON)
Log | Files | Refs | README

commit a91906faf48497ded49619e01f01e3e5baeb7d73
parent 5802b0c66198fc82002994d6c36bd5267f5960da
Author: [email protected] <[email protected]>
Date:   Sat, 23 Dec 2023 07:02:45 +0000

Cross compilation refactoring

Diffstat:
Mcmake/aarch64.cmake | 72+++++++++++++++++++++++++++++++++++++++++++-----------------------------
Mcmake/arm.cmake | 78+++++++++++++++++++++++++++++++++++++++++++++++++-----------------------------
Mtests/CMakeLists.txt | 19+++++++++++++------
3 files changed, 105 insertions(+), 64 deletions(-)

diff --git a/cmake/aarch64.cmake b/cmake/aarch64.cmake @@ -1,41 +1,55 @@ # For internal use only -set (CMAKE_SYSTEM_NAME Linux) -set (CMAKE_SYSTEM_VERSION 1) -set (UNIX True) -set (ARM True) -set (AARCH64 True) -set (CMAKE_SYSTEM_PROCESSOR aarch64) -set (EMULATOR qemu-aarch64) +set(TGT_TRIPLET aarch64-linux-gnu) + +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_VERSION 1) +set(UNIX True) +set(ARM True) +set(AARCH64 True) +set(CMAKE_SYSTEM_PROCESSOR aarch64) +set(EMULATOR qemu-aarch64) +set(QEMU_LD_PREFIX "/usr/${TGT_TRIPLET}/" CACHE INTERNAL "") +list(APPEND EMULATOR "-L") +list(APPEND EMULATOR ${QEMU_LD_PREFIX}) if (NOT CLANG_SUFFIX) - set (CLANG_SUFFIX "") + set(CLANG_SUFFIX "") endif () -include (CMakeForceCompiler) -CMAKE_FORCE_CXX_COMPILER (/usr/bin/clang++${CLANG_SUFFIX} Clang) -CMAKE_FORCE_C_COMPILER (/usr/bin/clang${CLANG_SUFFIX} Clang) -set (CMAKE_CXX_COMPILER_WORKS TRUE) -set (CMAKE_C_COMPILER_WORKS TRUE) - -set(TGT_TRIPLET aarch64-linux-gnu) - -set (ARM_ROOT "/usr/${TGT_TRIPLET}/include") +set(CMAKE_CXX_COMPILER + /usr/bin/clang++${CLANG_SUFFIX} + CACHE INTERNAL "Clang") +set(CMAKE_C_COMPILER + /usr/bin/clang${CLANG_SUFFIX} + CACHE INTERNAL "Clang") +set(CMAKE_CXX_COMPILER_TARGET + ${TGT_TRIPLET} + CACHE INTERNAL "Clang target") +set(CMAKE_C_COMPILER_TARGET + ${TGT_TRIPLET} + CACHE INTERNAL "Clang target") + +set(ARM_ROOT "/usr/${TGT_TRIPLET}/include") if (NOT GCC_VER) - set (GCC_VER 7.5.0) + set(GCC_VER 7.5.0) endif () -set (SYS_PATHS "-isystem ${ARM_ROOT}/c++/${GCC_VER} -isystem ${ARM_ROOT}/c++/${GCC_VER}/backward -isystem ${ARM_ROOT}/c++/${GCC_VER}/${TGT_TRIPLET} -isystem ${ARM_ROOT}") - -set (ARM_COMMON_FLAGS "-std=gnu++17 -target ${TGT_TRIPLET} -mcpu=cortex-a72 -static") +set(SYS_PATHS + "-isystem ${ARM_ROOT}/c++/${GCC_VER} -isystem ${ARM_ROOT}/c++/${GCC_VER}/backward -isystem ${ARM_ROOT}/c++/${GCC_VER}/${TGT_TRIPLET} -isystem ${ARM_ROOT}" +) -set (CMAKE_CXX_FLAGS "${SYS_PATHS} ${ARM_COMMON_FLAGS}" CACHE STRING "") -set (CMAKE_C_FLAGS " ${SYS_PATHS} ${ARM_COMMON_FLAGS}" CACHE STRING "") +set(ARM_COMMON_FLAGS "-mcpu=cortex-a72") -set (CMAKE_CXX_LINK_FLAGS " ${ARM_COMMON_FLAGS} ${CMAKE_CXX_LINK_FLAGS}") -set (CMAKE_C_LINK_FLAGS " ${ARM_COMMON_FLAGS} ${CMAKE_C_LINK_FLAGS}") +set(CMAKE_CXX_FLAGS + "${SYS_PATHS} ${ARM_COMMON_FLAGS}" + CACHE STRING "") +set(CMAKE_C_FLAGS + " ${SYS_PATHS} ${ARM_COMMON_FLAGS}" + CACHE STRING "") -message(STATUS "${ARM_COMMON_FLAGS}") +set(CMAKE_CXX_LINK_FLAGS " ${ARM_COMMON_FLAGS} ${CMAKE_CXX_LINK_FLAGS}") +set(CMAKE_C_LINK_FLAGS " ${ARM_COMMON_FLAGS} ${CMAKE_C_LINK_FLAGS}") -set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY) -set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/cmake/arm.cmake b/cmake/arm.cmake @@ -1,36 +1,56 @@ # For internal use only -set (CMAKE_SYSTEM_NAME Linux) -set (CMAKE_SYSTEM_VERSION 1) -set (UNIX True) -set (ARM True) -set (CMAKE_SYSTEM_PROCESSOR arm) -set (EMULATOR qemu-arm) - -include (CMakeForceCompiler) -CMAKE_FORCE_CXX_COMPILER (/usr/bin/clang++${CLANG_SUFFIX} Clang) -CMAKE_FORCE_C_COMPILER (/usr/bin/clang${CLANG_SUFFIX} Clang) -set (CMAKE_CXX_COMPILER_WORKS TRUE) -set (CMAKE_C_COMPILER_WORKS TRUE) - set(TGT_TRIPLET arm-linux-gnueabihf) -set (ARM_ROOT "/usr/${TGT_TRIPLET}/include") -if (NOT GCC_VER) - set (GCC_VER 7.5.0) -endif () -set (SYS_PATHS "-isystem ${ARM_ROOT}/c++/${GCC_VER} -isystem ${ARM_ROOT}/c++/${GCC_VER}/backward -isystem ${ARM_ROOT}/c++/${GCC_VER}/${TGT_TRIPLET} -isystem ${ARM_ROOT}") - -set (ARM_COMMON_FLAGS "-target ${TGT_TRIPLET} -mcpu=cortex-a15 -mfpu=neon-vfpv4 -mfloat-abi=hard -static") +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_VERSION 1) +set(UNIX True) +set(ARM True) -set (CMAKE_CXX_FLAGS "-std=gnu++17 ${SYS_PATHS} ${ARM_COMMON_FLAGS}" CACHE STRING "") -set (CMAKE_C_FLAGS " ${SYS_PATHS} ${ARM_COMMON_FLAGS}" CACHE STRING "") +set(CMAKE_SYSTEM_PROCESSOR arm) +set(EMULATOR qemu-arm) +set(QEMU_LD_PREFIX "/usr/${TGT_TRIPLET}/" CACHE INTERNAL "") +list(APPEND EMULATOR "-L") +list(APPEND EMULATOR ${QEMU_LD_PREFIX}) -set (CMAKE_CXX_LINK_FLAGS " ${ARM_COMMON_FLAGS} ${CMAKE_CXX_LINK_FLAGS}") -set (CMAKE_C_LINK_FLAGS " ${ARM_COMMON_FLAGS} ${CMAKE_C_LINK_FLAGS}") - -message(STATUS "${ARM_COMMON_FLAGS}") +if (NOT CLANG_SUFFIX) + set(CLANG_SUFFIX "") +endif () -set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY) -set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_CXX_COMPILER + /usr/bin/clang++${CLANG_SUFFIX} + CACHE INTERNAL "Clang") +set(CMAKE_C_COMPILER + /usr/bin/clang${CLANG_SUFFIX} + CACHE INTERNAL "Clang") +set(CMAKE_CXX_COMPILER_TARGET + ${TGT_TRIPLET} + CACHE INTERNAL "Clang target") +set(CMAKE_C_COMPILER_TARGET + ${TGT_TRIPLET} + CACHE INTERNAL "Clang target") + +set(ARM_ROOT "/usr/${TGT_TRIPLET}/include") +if (NOT GCC_VER) + set(GCC_VER 7.5.0) +endif () +set(SYS_PATHS + "-isystem ${ARM_ROOT}/c++/${GCC_VER} -isystem ${ARM_ROOT}/c++/${GCC_VER}/backward -isystem ${ARM_ROOT}/c++/${GCC_VER}/${TGT_TRIPLET} -isystem ${ARM_ROOT}" +) + +set(ARM_COMMON_FLAGS + "-target ${TGT_TRIPLET} -mcpu=cortex-a15 -mfpu=neon-vfpv4 -mfloat-abi=hard") + +set(CMAKE_CXX_FLAGS + "${SYS_PATHS} ${ARM_COMMON_FLAGS}" + CACHE STRING "") +set(CMAKE_C_FLAGS + " ${SYS_PATHS} ${ARM_COMMON_FLAGS}" + CACHE STRING "") + +set(CMAKE_CXX_LINK_FLAGS " ${ARM_COMMON_FLAGS} ${CMAKE_CXX_LINK_FLAGS}") +set(CMAKE_C_LINK_FLAGS " ${ARM_COMMON_FLAGS} ${CMAKE_C_LINK_FLAGS}") + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt @@ -56,7 +56,7 @@ if (KFR_ENABLE_CAPI_BUILD) add_executable(capi_test capi_test.cpp) target_include_directories(capi_test PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../include) - target_link_libraries(capi_test PUBLIC kfr_capi) + target_link_libraries(capi_test PRIVATE kfr_capi) endif () if (KFR_ENABLE_ASMTEST) @@ -191,10 +191,16 @@ set(SDE_ARCH_avx512 -skx) if (NOT KFR_SKIP_TESTS) enable_testing() - if (X86) - if (KFR_ENABLE_CAPI_BUILD) - add_test(NAME capi_test COMMAND ${EMULATOR} - ${PROJECT_BINARY_DIR}/bin/capi_test) + if (KFR_ENABLE_CAPI_BUILD) + add_test(NAME capi_test COMMAND ${EMULATOR} + ${PROJECT_BINARY_DIR}/bin/capi_test) + if (UNIX) + set_tests_properties( + capi_test + PROPERTIES + ENVIRONMENT + "LD_LIBRARY_PATH=${PROJECT_BINARY_DIR}/lib:$ENV{LD_LIBRARY_PATH}" + ) endif () endif () @@ -219,6 +225,7 @@ if (NOT KFR_SKIP_TESTS) COMMAND ${SDE} ${SDE_ARCH_avx512} -chip_check_exe_only -- ${PROJECT_BINARY_DIR}/bin/all_tests) else () - add_test(NAME all_tests COMMAND ${PROJECT_BINARY_DIR}/bin/all_tests) + add_test(NAME all_tests COMMAND ${EMULATOR} + ${PROJECT_BINARY_DIR}/bin/all_tests) endif () endif ()