From 942cbd3c8d579796e2eb47c47483ae20191fc421 Mon Sep 17 00:00:00 2001 From: Michael Maltese Date: Sat, 20 May 2017 16:00:55 -0700 Subject: [PATCH 01/10] CMake: don't prefix test targets with Test_ The current prefixing makes it harder to build test executables directly from the command line, since the target name breaks CMake convention and doesn't match the name passed to `add_dolphin_test`. They all have "Test" somewhere in the name anyways. --- Source/UnitTests/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/UnitTests/CMakeLists.txt b/Source/UnitTests/CMakeLists.txt index a884724444..b06d4a1ce1 100644 --- a/Source/UnitTests/CMakeLists.txt +++ b/Source/UnitTests/CMakeLists.txt @@ -12,13 +12,13 @@ macro(add_dolphin_test target srcs) # core, but before other core dependencies like videocommon which also use # Host_ functions. set(srcs2 ${srcs} ${CMAKE_SOURCE_DIR}/Source/UnitTests/TestUtils/StubHost.cpp ${ARGN}) - add_executable(Test_${target} EXCLUDE_FROM_ALL ${srcs2}) - set_target_properties(Test_${target} PROPERTIES + add_executable(${target} EXCLUDE_FROM_ALL ${srcs2}) + set_target_properties(${target} PROPERTIES OUTPUT_NAME Tests/${target} FOLDER Tests ) - target_link_libraries(Test_${target} ${LIBS}) - add_dependencies(unittests Test_${target}) + target_link_libraries(${target} ${LIBS}) + add_dependencies(unittests ${target}) add_test(NAME ${target} COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Tests/${target}) endmacro() From a78ca46d9ea584ba817aaffbd35525775a7f7c82 Mon Sep 17 00:00:00 2001 From: Michael Maltese Date: Sat, 20 May 2017 16:01:59 -0700 Subject: [PATCH 02/10] CMake: use implicit target location in add_test --- Source/UnitTests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/UnitTests/CMakeLists.txt b/Source/UnitTests/CMakeLists.txt index b06d4a1ce1..7c7df89129 100644 --- a/Source/UnitTests/CMakeLists.txt +++ b/Source/UnitTests/CMakeLists.txt @@ -19,7 +19,7 @@ macro(add_dolphin_test target srcs) ) target_link_libraries(${target} ${LIBS}) add_dependencies(unittests ${target}) - add_test(NAME ${target} COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Tests/${target}) + add_test(NAME ${target} COMMAND ${target}) endmacro() add_subdirectory(TestUtils) From 9d130b52f70a3691524a36fb1e5ba9cd9b91f084 Mon Sep 17 00:00:00 2001 From: Michael Maltese Date: Sun, 21 May 2017 23:56:35 -0700 Subject: [PATCH 03/10] CMake: use unittests_stubhost object library --- Source/UnitTests/CMakeLists.txt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Source/UnitTests/CMakeLists.txt b/Source/UnitTests/CMakeLists.txt index 7c7df89129..629b121b1f 100644 --- a/Source/UnitTests/CMakeLists.txt +++ b/Source/UnitTests/CMakeLists.txt @@ -6,12 +6,16 @@ if(ANDROID) set(LIBS ${LIBS} android log) endif() file(MAKE_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Tests) + +# 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 TestUtils/StubHost.cpp) + macro(add_dolphin_test target srcs) - # Since this is a Core dependency, it can't be linked as a library and has - # to be linked as an object file. Otherwise CMake inserts the library after - # core, but before other core dependencies like videocommon which also use - # Host_ functions. - set(srcs2 ${srcs} ${CMAKE_SOURCE_DIR}/Source/UnitTests/TestUtils/StubHost.cpp ${ARGN}) + + set(srcs2 ${srcs} $ ${ARGN}) add_executable(${target} EXCLUDE_FROM_ALL ${srcs2}) set_target_properties(${target} PROPERTIES OUTPUT_NAME Tests/${target} From 87d64afe1961684851758bdc089349c061e7b4a3 Mon Sep 17 00:00:00 2001 From: Michael Maltese Date: Sat, 20 May 2017 16:06:19 -0700 Subject: [PATCH 04/10] CMake: pass all srcs to add_test in ARGN --- Source/UnitTests/CMakeLists.txt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Source/UnitTests/CMakeLists.txt b/Source/UnitTests/CMakeLists.txt index 629b121b1f..a60fa05996 100644 --- a/Source/UnitTests/CMakeLists.txt +++ b/Source/UnitTests/CMakeLists.txt @@ -13,10 +13,11 @@ file(MAKE_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Tests) # GNU linker complain. add_library(unittests_stubhost OBJECT TestUtils/StubHost.cpp) -macro(add_dolphin_test target srcs) - - set(srcs2 ${srcs} $ ${ARGN}) - add_executable(${target} EXCLUDE_FROM_ALL ${srcs2}) +macro(add_dolphin_test target) + add_executable(${target} EXCLUDE_FROM_ALL + ${ARGN} + $ + ) set_target_properties(${target} PROPERTIES OUTPUT_NAME Tests/${target} FOLDER Tests From 41fb6db6e35b2e78397dc17d4e1fa834ada46f26 Mon Sep 17 00:00:00 2001 From: Michael Maltese Date: Sat, 20 May 2017 16:08:50 -0700 Subject: [PATCH 05/10] CMake: remove extraneous TestUtils directory --- Source/UnitTests/CMakeLists.txt | 4 +--- Source/UnitTests/{TestUtils => }/StubHost.cpp | 0 Source/UnitTests/TestUtils/CMakeLists.txt | 9 --------- Source/UnitTests/UnitTests.vcxproj | 3 ++- 4 files changed, 3 insertions(+), 13 deletions(-) rename Source/UnitTests/{TestUtils => }/StubHost.cpp (100%) delete mode 100644 Source/UnitTests/TestUtils/CMakeLists.txt diff --git a/Source/UnitTests/CMakeLists.txt b/Source/UnitTests/CMakeLists.txt index a60fa05996..4f97ce5793 100644 --- a/Source/UnitTests/CMakeLists.txt +++ b/Source/UnitTests/CMakeLists.txt @@ -11,7 +11,7 @@ file(MAKE_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Tests) # 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 TestUtils/StubHost.cpp) +add_library(unittests_stubhost OBJECT StubHost.cpp) macro(add_dolphin_test target) add_executable(${target} EXCLUDE_FROM_ALL @@ -27,8 +27,6 @@ macro(add_dolphin_test target) add_test(NAME ${target} COMMAND ${target}) endmacro() -add_subdirectory(TestUtils) - add_subdirectory(Common) add_subdirectory(Core) add_subdirectory(VideoCommon) diff --git a/Source/UnitTests/TestUtils/StubHost.cpp b/Source/UnitTests/StubHost.cpp similarity index 100% rename from Source/UnitTests/TestUtils/StubHost.cpp rename to Source/UnitTests/StubHost.cpp diff --git a/Source/UnitTests/TestUtils/CMakeLists.txt b/Source/UnitTests/TestUtils/CMakeLists.txt deleted file mode 100644 index 79424a42a6..0000000000 --- a/Source/UnitTests/TestUtils/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -set(SRCS - # Do not add StubHost.cpp here - it is added manually via add_dolphin_test. - ) - -set(LIBS - ) - -# TODO: uncomment when there is actually something here. -#add_dolphin_library(testutils "${SRCS}" "${LIBS}") diff --git a/Source/UnitTests/UnitTests.vcxproj b/Source/UnitTests/UnitTests.vcxproj index 9c91baf8c0..27cc4992d0 100644 --- a/Source/UnitTests/UnitTests.vcxproj +++ b/Source/UnitTests/UnitTests.vcxproj @@ -60,6 +60,7 @@ + @@ -111,4 +112,4 @@ - \ No newline at end of file + From ea35549e0046e794bfa591aafc344fc3fdf0e83c Mon Sep 17 00:00:00 2001 From: Michael Maltese Date: Sat, 20 May 2017 16:09:47 -0700 Subject: [PATCH 06/10] CMake: don't explictly create Tests/ directory --- Source/UnitTests/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/Source/UnitTests/CMakeLists.txt b/Source/UnitTests/CMakeLists.txt index 4f97ce5793..b5f9ad6f43 100644 --- a/Source/UnitTests/CMakeLists.txt +++ b/Source/UnitTests/CMakeLists.txt @@ -5,7 +5,6 @@ endif() if(ANDROID) set(LIBS ${LIBS} android log) endif() -file(MAKE_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Tests) # 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 From be2f4466e3c8215338d9f18c3ec8637d733901d9 Mon Sep 17 00:00:00 2001 From: Michael Maltese Date: Sat, 20 May 2017 16:21:59 -0700 Subject: [PATCH 07/10] CMake: move unittests target to UnitTests --- CMakeLists.txt | 8 +++----- Source/UnitTests/CMakeLists.txt | 4 ++++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 58aaaa9c43..67424f11b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -806,13 +806,11 @@ include_directories("${PROJECT_BINARY_DIR}/Source/Core") message(STATUS "Using static gtest from Externals") add_subdirectory(Externals/gtest EXCLUDE_FROM_ALL) -enable_testing() -add_custom_target(unittests) -add_custom_command(TARGET unittests POST_BUILD COMMAND ${CMAKE_CTEST_COMMAND}) - +######################################## +# Process Dolphin source now that all setup is complete +# add_subdirectory(Source) - ######################################## # Install shared data files # diff --git a/Source/UnitTests/CMakeLists.txt b/Source/UnitTests/CMakeLists.txt index b5f9ad6f43..ebfcd3f046 100644 --- a/Source/UnitTests/CMakeLists.txt +++ b/Source/UnitTests/CMakeLists.txt @@ -1,3 +1,7 @@ +enable_testing() +add_custom_target(unittests) +add_custom_command(TARGET unittests POST_BUILD COMMAND ${CMAKE_CTEST_COMMAND}) + set(LIBS core gtest_main) if(APPLE) list(APPEND LIBS ${FOUNDATION_LIBRARY} ${CORESERV_LIBRARY}) From 8e57a0ff1400ee599d91067050bdcd02bb4a8205 Mon Sep 17 00:00:00 2001 From: Michael Maltese Date: Mon, 22 May 2017 00:07:08 -0700 Subject: [PATCH 08/10] CMake: remove explicit platform libraries from UnitTests They're not used directly, and any libraries that need them will pull them in transitively. --- Source/UnitTests/CMakeLists.txt | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Source/UnitTests/CMakeLists.txt b/Source/UnitTests/CMakeLists.txt index ebfcd3f046..27903f8c20 100644 --- a/Source/UnitTests/CMakeLists.txt +++ b/Source/UnitTests/CMakeLists.txt @@ -3,12 +3,6 @@ add_custom_target(unittests) add_custom_command(TARGET unittests POST_BUILD COMMAND ${CMAKE_CTEST_COMMAND}) set(LIBS core gtest_main) -if(APPLE) - list(APPEND LIBS ${FOUNDATION_LIBRARY} ${CORESERV_LIBRARY}) -endif() -if(ANDROID) - set(LIBS ${LIBS} android log) -endif() # 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 From 6d403d9ad4fd7103552b9db58783f401fbed54c4 Mon Sep 17 00:00:00 2001 From: Michael Maltese Date: Mon, 22 May 2017 00:07:46 -0700 Subject: [PATCH 09/10] CMake: specify unittests libs directly in target_link_libraries --- Source/UnitTests/CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Source/UnitTests/CMakeLists.txt b/Source/UnitTests/CMakeLists.txt index 27903f8c20..93e9deb4a8 100644 --- a/Source/UnitTests/CMakeLists.txt +++ b/Source/UnitTests/CMakeLists.txt @@ -2,8 +2,6 @@ enable_testing() add_custom_target(unittests) add_custom_command(TARGET unittests POST_BUILD COMMAND ${CMAKE_CTEST_COMMAND}) -set(LIBS core gtest_main) - # 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 @@ -19,7 +17,7 @@ macro(add_dolphin_test target) OUTPUT_NAME Tests/${target} FOLDER Tests ) - target_link_libraries(${target} ${LIBS}) + target_link_libraries(${target} core gtest_main) add_dependencies(unittests ${target}) add_test(NAME ${target} COMMAND ${target}) endmacro() From 974ada25e4c611be91eacdc0a2c177ca3ee1fc3f Mon Sep 17 00:00:00 2001 From: Michael Maltese Date: Mon, 22 May 2017 00:05:13 -0700 Subject: [PATCH 10/10] CMake: use RUNTIME_OUTPUT_DIRECTORY rather than setting OUTPUT_NAME each time --- Source/UnitTests/CMakeLists.txt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Source/UnitTests/CMakeLists.txt b/Source/UnitTests/CMakeLists.txt index 93e9deb4a8..18bae340a7 100644 --- a/Source/UnitTests/CMakeLists.txt +++ b/Source/UnitTests/CMakeLists.txt @@ -2,6 +2,8 @@ enable_testing() add_custom_target(unittests) add_custom_command(TARGET unittests POST_BUILD COMMAND ${CMAKE_CTEST_COMMAND}) +string(APPEND CMAKE_RUNTIME_OUTPUT_DIRECTORY "/Tests") + # 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 @@ -13,10 +15,7 @@ macro(add_dolphin_test target) ${ARGN} $ ) - set_target_properties(${target} PROPERTIES - OUTPUT_NAME Tests/${target} - FOLDER Tests - ) + set_target_properties(${target} PROPERTIES FOLDER Tests) target_link_libraries(${target} core gtest_main) add_dependencies(unittests ${target}) add_test(NAME ${target} COMMAND ${target})