Skip to content

Commit

Permalink
Merge pull request #12837 from JosJuice/cmake-one-tests-binary
Browse files Browse the repository at this point in the history
CMake: Put all unit tests in one binary
  • Loading branch information
AdmiralCurtiss committed Jun 10, 2024
2 parents 6b2dc1c + f404edb commit 04c246d
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions Source/UnitTests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,16 @@ add_custom_command(TARGET unittests POST_BUILD COMMAND ${CMAKE_CTEST_COMMAND} "-

string(APPEND CMAKE_RUNTIME_OUTPUT_DIRECTORY "/Tests")

add_library(unittests_main OBJECT UnitTestsMain.cpp)

target_link_libraries(unittests_main PUBLIC fmt::fmt gtest::gtest)
# Since this is a Core dependency, it can't be linked as a normal library.
# Otherwise CMake inserts the library after core, but before other core
# dependencies like videocommon which also use Host_ functions, which makes the
# GNU linker complain.
add_library(unittests_stubhost OBJECT StubHost.cpp)
add_executable(tests EXCLUDE_FROM_ALL UnitTestsMain.cpp StubHost.cpp)
set_target_properties(tests PROPERTIES FOLDER Tests)
target_link_libraries(tests PRIVATE fmt::fmt gtest::gtest core uicommon)
add_test(NAME tests COMMAND tests)
add_dependencies(unittests tests)

macro(add_dolphin_test target)
add_executable(${target} EXCLUDE_FROM_ALL
${ARGN}
$<TARGET_OBJECTS:unittests_stubhost>
)
set_target_properties(${target} PROPERTIES FOLDER Tests)
target_link_libraries(${target} PRIVATE core uicommon unittests_main)
add_dependencies(unittests ${target})
add_test(NAME ${target} COMMAND ${target})
add_library(${target} OBJECT ${ARGN})
target_link_libraries(${target} PUBLIC fmt::fmt gtest::gtest PRIVATE core uicommon)
target_link_libraries(tests PRIVATE ${target})
endmacro()

add_subdirectory(Common)
Expand Down

0 comments on commit 04c246d

Please sign in to comment.