mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-22 15:40:02 +00:00
CMake: Put all unit tests in one binary
We currently have 32 different binaries containing unit tests. At least when I build for Android, each one takes up over 200 MiB, and linking them all increases my incremental build times by over a minute. I'd like to change this for the sake of my productivity and disk space. For reference, MSBuild is already putting all tests in a single binary.
This commit is contained in:
parent
ca22d0af57
commit
f404edb4dc
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user