diff --git a/CMakeLists.txt b/CMakeLists.txt index ea1a194aec..ed5dd10251 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,7 @@ option(USE_SYSTEM_CURL "Prefer system Curl instead of the prebuild one" ON) option(USE_SYSTEM_OPENCV "Prefer system OpenCV instead of the builtin one" ON) option(HAS_MEMORY_BREAKPOINTS "Add support for memory breakpoints to the interpreter" OFF) option(USE_LTO "Use LTO for building" ON) +option(BUILD_RPCS3_TESTS "Build RPCS3 unit tests." OFF) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/buildfiles/cmake") diff --git a/rpcs3/CMakeLists.txt b/rpcs3/CMakeLists.txt index cec0cb6b9b..11c7770385 100644 --- a/rpcs3/CMakeLists.txt +++ b/rpcs3/CMakeLists.txt @@ -1,4 +1,4 @@ -# Define GNU standard installation directories +# Define GNU standard installation directories include(GNUInstallDirs) # Generate git-version.h at build time. @@ -214,3 +214,29 @@ if (NOT ANDROID) DESTINATION ${CMAKE_INSTALL_DATADIR}/rpcs3) endif() endif() + +# Unit tests +if(BUILD_RPCS3_TESTS) + enable_testing() + find_package(GTest REQUIRED) + + message(STATUS "Building unit tests...") + + add_executable(rpcs3_test + tests/test_fmt.cpp + ) + + target_link_libraries(rpcs3_test + rpcs3_lib + GTest::gtest_main + ) + + target_include_directories(rpcs3_test + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/.. + ) + + include(GoogleTest) + gtest_discover_tests(rpcs3_test) +endif()