pcsx2/tests/ctest/CMakeLists.txt

73 lines
1.9 KiB
CMake
Raw Normal View History

2021-04-24 04:46:12 +00:00
option(ENABLE_UNSUPPORTED_TESTS "Include tests that require instructions not supported by this computer" OFF)
set(avxdetect_code "
2021-08-13 05:39:40 +00:00
#ifdef __GNUC__
#include <cpuid.h>
void cpuid(int result[4], int leaf, int subleaf) {
__cpuid_count(leaf, subleaf, result[0], result[1], result[2], result[3]);
}
2021-04-24 04:46:12 +00:00
#else
2021-08-13 05:39:40 +00:00
#include <intrin.h>
#define cpuid __cpuidex
2021-04-24 04:46:12 +00:00
#endif
2021-08-13 05:39:40 +00:00
int test(int leaf, int subleaf, int reg, int bit) {
int res[4];
cpuid(res, 0, 0);
if (res[0] < leaf) { return 0; }
cpuid(res, leaf, subleaf);
return !!(res[reg] & (1 << bit));
}
int main() {
if (test(7, 0, 1, 5) /* AVX2 */) return 51;
if (test(1, 0, 2, 28) /* AVX */) return 50;
if (test(1, 0, 2, 19) /* SSE41 */) return 41;
return 0;
2021-04-24 04:46:12 +00:00
}
")
if(ENABLE_UNSUPPORTED_TESTS)
set(native_vector_isa 99)
else()
set(cc_backup ${CMAKE_CROSSCOMPILING})
set(CMAKE_CROSSCOMPILING 0)
file(WRITE "${CMAKE_BINARY_DIR}/avxdetect.c" "${avxdetect_code}")
try_run(
native_vector_isa
compile_result_unused
"${CMAKE_BINARY_DIR}"
"${CMAKE_BINARY_DIR}/avxdetect.c"
)
set(CMAKE_CROSSCOMPILING ${cc_backup})
endif()
2021-08-13 05:39:40 +00:00
if (MSVC)
set(compile_options_avx /arch:AVX)
set(compile_options_avx2 /arch:AVX2)
set(definitions_sse4 _M_SSE=0x401)
set(definitions_avx _M_SSE=0x500)
set(definitions_avx2 _M_SSE=0x501)
else()
set(compile_options_sse4 -msse4.1)
set(compile_options_avx -mavx)
set(compile_options_avx2 -mavx2 -mbmi -mbmi2)
endif()
set(isa_number_sse4 41)
set(isa_number_avx 50)
set(isa_number_avx2 51)
2021-04-24 04:46:12 +00:00
enable_testing()
add_custom_target(unittests)
add_custom_command(TARGET unittests POST_BUILD COMMAND ${CMAKE_CTEST_COMMAND})
macro(add_pcsx2_test target)
add_executable(${target} EXCLUDE_FROM_ALL ${ARGN})
2021-09-02 16:36:36 +00:00
target_link_libraries(${target} PRIVATE gtest_main common)
target_compile_definitions(${target} PRIVATE "PCSX2_CORE")
add_dependencies(unittests ${target})
add_test(NAME ${target} COMMAND ${target})
endmacro()
add_subdirectory(x86emitter)
2021-04-24 04:46:12 +00:00
add_subdirectory(GS)