1# 2# libraries for tests 3# 4 5include_directories(../include) 6add_definitions(-DCPU_FEATURES_TEST) 7 8##------------------------------------------------------------------------------ 9add_library(string_view ../src/string_view.c) 10##------------------------------------------------------------------------------ 11add_library(filesystem_for_testing filesystem_for_testing.cc) 12target_compile_definitions(filesystem_for_testing PUBLIC CPU_FEATURES_MOCK_FILESYSTEM) 13##------------------------------------------------------------------------------ 14add_library(hwcaps_for_testing hwcaps_for_testing.cc) 15target_link_libraries(hwcaps_for_testing filesystem_for_testing) 16##------------------------------------------------------------------------------ 17add_library(stack_line_reader ../src/stack_line_reader.c) 18target_compile_definitions(stack_line_reader PUBLIC STACK_LINE_READER_BUFFER_SIZE=1024) 19target_link_libraries(stack_line_reader string_view) 20##------------------------------------------------------------------------------ 21add_library(stack_line_reader_for_test ../src/stack_line_reader.c) 22target_compile_definitions(stack_line_reader_for_test PUBLIC STACK_LINE_READER_BUFFER_SIZE=16) 23target_link_libraries(stack_line_reader_for_test string_view filesystem_for_testing) 24##------------------------------------------------------------------------------ 25add_library(all_libraries ../src/hwcaps.c ../src/stack_line_reader.c) 26target_link_libraries(all_libraries hwcaps_for_testing stack_line_reader string_view) 27 28# 29# tests 30# 31link_libraries(gtest gmock_main) 32 33## bit_utils_test 34add_executable(bit_utils_test bit_utils_test.cc) 35target_link_libraries(bit_utils_test) 36add_test(NAME bit_utils_test COMMAND bit_utils_test) 37##------------------------------------------------------------------------------ 38## string_view_test 39add_executable(string_view_test string_view_test.cc ../src/string_view.c) 40target_link_libraries(string_view_test string_view) 41add_test(NAME string_view_test COMMAND string_view_test) 42##------------------------------------------------------------------------------ 43## stack_line_reader_test 44add_executable(stack_line_reader_test stack_line_reader_test.cc) 45target_link_libraries(stack_line_reader_test stack_line_reader_for_test) 46add_test(NAME stack_line_reader_test COMMAND stack_line_reader_test) 47##------------------------------------------------------------------------------ 48## cpuinfo_x86_test 49if(PROCESSOR_IS_X86) 50 add_executable(cpuinfo_x86_test cpuinfo_x86_test.cc ../src/cpuinfo_x86.c) 51 target_compile_definitions(cpuinfo_x86_test PUBLIC CPU_FEATURES_MOCK_CPUID_X86) 52 if(APPLE) 53 target_compile_definitions(cpuinfo_x86_test PRIVATE HAVE_SYSCTLBYNAME) 54 endif() 55 target_link_libraries(cpuinfo_x86_test all_libraries) 56 add_test(NAME cpuinfo_x86_test COMMAND cpuinfo_x86_test) 57endif() 58##------------------------------------------------------------------------------ 59## cpuinfo_arm_test 60if(PROCESSOR_IS_ARM) 61 add_executable(cpuinfo_arm_test cpuinfo_arm_test.cc ../src/cpuinfo_arm.c) 62 target_link_libraries(cpuinfo_arm_test all_libraries) 63 add_test(NAME cpuinfo_arm_test COMMAND cpuinfo_arm_test) 64endif() 65##------------------------------------------------------------------------------ 66## cpuinfo_aarch64_test 67if(PROCESSOR_IS_AARCH64) 68 add_executable(cpuinfo_aarch64_test cpuinfo_aarch64_test.cc ../src/cpuinfo_aarch64.c) 69 target_link_libraries(cpuinfo_aarch64_test all_libraries) 70 add_test(NAME cpuinfo_aarch64_test COMMAND cpuinfo_aarch64_test) 71endif() 72##------------------------------------------------------------------------------ 73## cpuinfo_mips_test 74if(PROCESSOR_IS_MIPS) 75 add_executable(cpuinfo_mips_test cpuinfo_mips_test.cc ../src/cpuinfo_mips.c) 76 target_link_libraries(cpuinfo_mips_test all_libraries) 77 add_test(NAME cpuinfo_mips_test COMMAND cpuinfo_mips_test) 78endif() 79##------------------------------------------------------------------------------ 80## cpuinfo_ppc_test 81if(PROCESSOR_IS_POWER) 82 add_executable(cpuinfo_ppc_test cpuinfo_ppc_test.cc ../src/cpuinfo_ppc.c) 83 target_link_libraries(cpuinfo_ppc_test all_libraries) 84 add_test(NAME cpuinfo_ppc_test COMMAND cpuinfo_ppc_test) 85endif() 86