From 4ce14a639f024a461bb53a4c5372501eab24fadf Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 2 Jan 2024 19:06:39 +0100 Subject: [PATCH] Revert "Cleanup: move CMake test utility functions into testing.cmake" This breaks execution of some Windows tests. This reverts commit 4190a61020eb1ddde5097ac21aaf0bb77118f140. --- CMakeLists.txt | 1 - build_files/cmake/Modules/GTestTesting.cmake | 116 ++++++++ build_files/cmake/macros.cmake | 155 ++++++++++ build_files/cmake/testing.cmake | 268 ------------------ intern/atomic/CMakeLists.txt | 1 + intern/cycles/test/CMakeLists.txt | 2 + intern/ffmpeg/CMakeLists.txt | 1 + intern/guardedalloc/CMakeLists.txt | 1 + intern/libmv/CMakeLists.txt | 2 + intern/libmv/bundle.sh | 2 + intern/opensubdiv/CMakeLists.txt | 2 + source/blender/animrig/CMakeLists.txt | 1 + source/blender/asset_system/CMakeLists.txt | 1 + source/blender/blenkernel/CMakeLists.txt | 1 + source/blender/blenlib/CMakeLists.txt | 1 + source/blender/blenloader/CMakeLists.txt | 1 + source/blender/bmesh/CMakeLists.txt | 1 + source/blender/compositor/CMakeLists.txt | 1 + source/blender/depsgraph/CMakeLists.txt | 1 + source/blender/draw/CMakeLists.txt | 1 + .../blender/editors/animation/CMakeLists.txt | 1 + source/blender/functions/CMakeLists.txt | 1 + source/blender/gpu/CMakeLists.txt | 1 + source/blender/io/alembic/CMakeLists.txt | 1 + source/blender/io/common/CMakeLists.txt | 1 + source/blender/io/ply/CMakeLists.txt | 1 + source/blender/io/stl/CMakeLists.txt | 1 + source/blender/io/usd/CMakeLists.txt | 1 + .../blender/io/wavefront_obj/CMakeLists.txt | 1 + source/blender/windowmanager/CMakeLists.txt | 1 + 30 files changed, 301 insertions(+), 269 deletions(-) create mode 100644 build_files/cmake/Modules/GTestTesting.cmake delete mode 100644 build_files/cmake/testing.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 7276bbc540a..a36ab662bb9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,7 +94,6 @@ endif() # Load Blender's Local Macros include(build_files/cmake/macros.cmake) -include(build_files/cmake/testing.cmake) # ----------------------------------------------------------------------------- # Initialize Project diff --git a/build_files/cmake/Modules/GTestTesting.cmake b/build_files/cmake/Modules/GTestTesting.cmake new file mode 100644 index 00000000000..e533fe47a3f --- /dev/null +++ b/build_files/cmake/Modules/GTestTesting.cmake @@ -0,0 +1,116 @@ +# SPDX-FileCopyrightText: 2014 Blender Authors +# +# SPDX-License-Identifier: BSD-3-Clause + +# Inspired on the Testing.cmake from Libmv + +function(GET_BLENDER_TEST_INSTALL_DIR VARIABLE_NAME) + get_property(GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + if(GENERATOR_IS_MULTI_CONFIG) + string(REPLACE "\${BUILD_TYPE}" "$" TEST_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}) + else() + string(REPLACE "\${BUILD_TYPE}" "" TEST_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}) + endif() + set(${VARIABLE_NAME} "${TEST_INSTALL_DIR}" PARENT_SCOPE) +endfunction() + + +macro(BLENDER_SRC_GTEST_EX) + if(WITH_GTESTS) + set(options SKIP_ADD_TEST) + set(oneValueArgs NAME) + set(multiValueArgs SRC EXTRA_LIBS COMMAND_ARGS) + cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) + + set(TARGET_NAME ${ARG_NAME}_test) + get_property(_current_include_directories + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + PROPERTY INCLUDE_DIRECTORIES) + set(TEST_INC + ${_current_include_directories} + ${CMAKE_SOURCE_DIR}/tests/gtests + ) + set(TEST_INC_SYS + ${GLOG_INCLUDE_DIRS} + ${GFLAGS_INCLUDE_DIRS} + ${CMAKE_SOURCE_DIR}/extern/gtest/include + ${CMAKE_SOURCE_DIR}/extern/gmock/include + ) + unset(_current_include_directories) + if(WIN32) + set(MANIFEST "${CMAKE_BINARY_DIR}/tests.exe.manifest") + else() + set(MANIFEST "") + endif() + + add_executable(${TARGET_NAME} ${ARG_SRC} ${MANIFEST}) + setup_platform_linker_flags(${TARGET_NAME}) + target_compile_definitions(${TARGET_NAME} PRIVATE ${GFLAGS_DEFINES}) + target_compile_definitions(${TARGET_NAME} PRIVATE ${GLOG_DEFINES}) + target_include_directories(${TARGET_NAME} PUBLIC "${TEST_INC}") + target_include_directories(${TARGET_NAME} SYSTEM PUBLIC "${TEST_INC_SYS}") + blender_link_libraries(${TARGET_NAME} "${ARG_EXTRA_LIBS};${PLATFORM_LINKLIBS}") + if(WITH_TBB) + # Force TBB libraries to be in front of MKL (part of OpenImageDenoise), so + # that it is initialized before MKL and static library initialization order + # issues are avoided. + target_link_libraries(${TARGET_NAME} PRIVATE ${TBB_LIBRARIES}) + if(WITH_OPENIMAGEDENOISE) + target_link_libraries(${TARGET_NAME} PRIVATE ${OPENIMAGEDENOISE_LIBRARIES}) + endif() + endif() + target_link_libraries(${TARGET_NAME} PRIVATE + bf_testing_main + bf_intern_eigen + bf_intern_guardedalloc + extern_gtest + extern_gmock + # Needed for GLOG. + ${GLOG_LIBRARIES} + ${GFLAGS_LIBRARIES}) + + if(DEFINED PTHREADS_LIBRARIES) # Needed for GLOG. + target_link_libraries(${TARGET_NAME} PRIVATE ${PTHREADS_LIBRARIES}) + endif() + if(WITH_OPENMP AND WITH_OPENMP_STATIC) + target_link_libraries(${TARGET_NAME} PRIVATE ${OpenMP_LIBRARIES}) + endif() + if(UNIX AND NOT APPLE) + target_link_libraries(${TARGET_NAME} PRIVATE bf_intern_libc_compat) + endif() + if(WITH_TBB) + target_link_libraries(${TARGET_NAME} PRIVATE ${TBB_LIBRARIES}) + endif() + if(WITH_GMP) + target_link_libraries(${TARGET_NAME} PRIVATE ${GMP_LIBRARIES}) + endif() + + get_blender_test_install_dir(TEST_INSTALL_DIR) + set_target_properties(${TARGET_NAME} PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${TESTS_OUTPUT_DIR}" + RUNTIME_OUTPUT_DIRECTORY_RELEASE "${TESTS_OUTPUT_DIR}" + RUNTIME_OUTPUT_DIRECTORY_DEBUG "${TESTS_OUTPUT_DIR}") + if(NOT ARG_SKIP_ADD_TEST) + add_test( + NAME ${TARGET_NAME} + COMMAND ${TESTS_OUTPUT_DIR}/${TARGET_NAME} ${ARG_COMMAND_ARGS} + WORKING_DIRECTORY ${TEST_INSTALL_DIR}) + + # Don't fail tests on leaks since these often happen in external libraries + # that we can't fix. + set_tests_properties(${TARGET_NAME} PROPERTIES + ENVIRONMENT LSAN_OPTIONS=exitcode=0:$ENV{LSAN_OPTIONS} + ) + if(WIN32) + set_tests_properties(${TARGET_NAME} PROPERTIES ENVIRONMENT "PATH=${CMAKE_INSTALL_PREFIX_WITH_CONFIG}/blender.shared/;$ENV{PATH}") + endif() + endif() + if(WIN32) + set_target_properties(${TARGET_NAME} PROPERTIES VS_GLOBAL_VcpkgEnabled "false") + endif() + unset(MANIFEST) + unset(TEST_INC) + unset(TEST_INC_SYS) + unset(TARGET_NAME) + endif() +endmacro() diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index 56168258d79..0ed6d0d348c 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -456,6 +456,161 @@ function(blender_add_lib set_property(GLOBAL APPEND PROPERTY BLENDER_LINK_LIBS ${name}) endfunction() +function(blender_add_test_suite) + if(ARGC LESS 1) + message(FATAL_ERROR "No arguments supplied to blender_add_test_suite()") + endif() + + # Parse the arguments + set(oneValueArgs TARGET SUITE_NAME) + set(multiValueArgs SOURCES) + cmake_parse_arguments(ARGS "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + # Figure out the release dir, as some tests need files from there. + get_blender_test_install_dir(TEST_INSTALL_DIR) + if(APPLE) + set(_test_release_dir ${TEST_INSTALL_DIR}/Blender.app/Contents/Resources/${BLENDER_VERSION}) + else() + if(WIN32 OR WITH_INSTALL_PORTABLE) + set(_test_release_dir ${TEST_INSTALL_DIR}/${BLENDER_VERSION}) + else() + set(_test_release_dir ${TEST_INSTALL_DIR}/share/blender/${BLENDER_VERSION}) + endif() + endif() + + # Define a test case with our custom gtest_add_tests() command. + include(GTest) + gtest_add_tests( + TARGET ${ARGS_TARGET} + SOURCES "${ARGS_SOURCES}" + TEST_PREFIX ${ARGS_SUITE_NAME} + WORKING_DIRECTORY "${TEST_INSTALL_DIR}" + EXTRA_ARGS + --test-assets-dir "${CMAKE_SOURCE_DIR}/../lib/tests" + --test-release-dir "${_test_release_dir}" + ) + if(WIN32) + set_tests_properties( + ${ARGS_SUITE_NAME} PROPERTIES + ENVIRONMENT "PATH=${CMAKE_INSTALL_PREFIX_WITH_CONFIG}/blender.shared/;$ENV{PATH}" + ) + endif() + unset(_test_release_dir) +endfunction() + +# Add tests for a Blender library, to be called in tandem with blender_add_lib(). +# The tests will be part of the blender_test executable (see tests/gtests/runner). +function(blender_add_test_lib + name + sources + includes + includes_sys + library_deps + ) + + add_cc_flags_custom_test(${name} PARENT_SCOPE) + + # Otherwise external projects will produce warnings that we cannot fix. + remove_strict_flags() + + # This duplicates logic that's also in GTestTesting.cmake, macro BLENDER_SRC_GTEST_EX. + # TODO(Sybren): deduplicate after the general approach in D7649 has been approved. + list(APPEND includes + ${CMAKE_SOURCE_DIR}/tests/gtests + ) + list(APPEND includes_sys + ${GLOG_INCLUDE_DIRS} + ${GFLAGS_INCLUDE_DIRS} + ${CMAKE_SOURCE_DIR}/extern/gtest/include + ${CMAKE_SOURCE_DIR}/extern/gmock/include + ) + + blender_add_lib__impl(${name} "${sources}" "${includes}" "${includes_sys}" "${library_deps}") + + target_compile_definitions(${name} PRIVATE ${GFLAGS_DEFINES}) + target_compile_definitions(${name} PRIVATE ${GLOG_DEFINES}) + + set_property(GLOBAL APPEND PROPERTY BLENDER_TEST_LIBS ${name}) + + blender_add_test_suite( + TARGET blender_test + SUITE_NAME ${name} + SOURCES "${sources}" + ) +endfunction() + + +# Add tests for a Blender library, to be called in tandem with blender_add_lib(). +# Test will be compiled into a ${name}_test executable. +# +# To be used for smaller isolated libraries, that do not have many dependencies. +# For libraries that do drag in many other Blender libraries and would create a +# very large executable, blender_add_test_lib() should be used instead. +function(blender_add_test_executable_impl + name + add_test_suite + sources + includes + includes_sys + library_deps + ) + + add_cc_flags_custom_test(${name} PARENT_SCOPE) + + ## Otherwise external projects will produce warnings that we cannot fix. + remove_strict_flags() + + blender_src_gtest_ex( + NAME ${name} + SRC "${sources}" + EXTRA_LIBS "${library_deps}" + SKIP_ADD_TEST + ) + if(add_test_suite) + blender_add_test_suite( + TARGET ${name}_test + SUITE_NAME ${name} + SOURCES "${sources}" + ) + endif() + blender_target_include_dirs(${name}_test ${includes}) + blender_target_include_dirs_sys(${name}_test ${includes_sys}) +endfunction() + +function(blender_add_test_executable + name + sources + includes + includes_sys + library_deps + ) + blender_add_test_executable_impl( + "${name}" + TRUE + "${sources}" + "${includes}" + "${includes_sys}" + "${library_deps}" + ) +endfunction() + +function(blender_add_performancetest_executable + name + sources + includes + includes_sys + library_deps + ) + blender_add_test_executable_impl( + "${name}" + FALSE + "${sources}" + "${includes}" + "${includes_sys}" + "${library_deps}" + ) +endfunction() + # Ninja only: assign 'heavy pool' to some targets that are especially RAM-consuming to build. function(setup_heavy_lib_pool) if(WITH_NINJA_POOL_JOBS AND NINJA_MAX_NUM_PARALLEL_COMPILE_HEAVY_JOBS) diff --git a/build_files/cmake/testing.cmake b/build_files/cmake/testing.cmake deleted file mode 100644 index acd70ca9c35..00000000000 --- a/build_files/cmake/testing.cmake +++ /dev/null @@ -1,268 +0,0 @@ -# SPDX-FileCopyrightText: 2006-2023 Blender Authors -# -# SPDX-License-Identifier: GPL-2.0-or-later - -function(get_blender_test_install_dir variable_name) - get_property(GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) - if(GENERATOR_IS_MULTI_CONFIG) - string(REPLACE "\${BUILD_TYPE}" "$" TEST_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}) - else() - string(REPLACE "\${BUILD_TYPE}" "" TEST_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}) - endif() - set(${VARIABLE_NAME} "${TEST_INSTALL_DIR}" PARENT_SCOPE) -endfunction() - -macro(blender_src_gtest_ex) - if(WITH_GTESTS) - set(options SKIP_ADD_TEST) - set(oneValueArgs NAME) - set(multiValueArgs SRC EXTRA_LIBS COMMAND_ARGS) - cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) - - set(TARGET_NAME ${ARG_NAME}_test) - get_property(_current_include_directories - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - PROPERTY INCLUDE_DIRECTORIES) - set(TEST_INC - ${_current_include_directories} - ${CMAKE_SOURCE_DIR}/tests/gtests - ) - set(TEST_INC_SYS - ${GLOG_INCLUDE_DIRS} - ${GFLAGS_INCLUDE_DIRS} - ${CMAKE_SOURCE_DIR}/extern/gtest/include - ${CMAKE_SOURCE_DIR}/extern/gmock/include - ) - unset(_current_include_directories) - if(WIN32) - set(MANIFEST "${CMAKE_BINARY_DIR}/tests.exe.manifest") - else() - set(MANIFEST "") - endif() - - add_executable(${TARGET_NAME} ${ARG_SRC} ${MANIFEST}) - setup_platform_linker_flags(${TARGET_NAME}) - target_compile_definitions(${TARGET_NAME} PRIVATE ${GFLAGS_DEFINES}) - target_compile_definitions(${TARGET_NAME} PRIVATE ${GLOG_DEFINES}) - target_include_directories(${TARGET_NAME} PUBLIC "${TEST_INC}") - target_include_directories(${TARGET_NAME} SYSTEM PUBLIC "${TEST_INC_SYS}") - blender_link_libraries(${TARGET_NAME} "${ARG_EXTRA_LIBS};${PLATFORM_LINKLIBS}") - if(WITH_TBB) - # Force TBB libraries to be in front of MKL (part of OpenImageDenoise), so - # that it is initialized before MKL and static library initialization order - # issues are avoided. - target_link_libraries(${TARGET_NAME} PRIVATE ${TBB_LIBRARIES}) - if(WITH_OPENIMAGEDENOISE) - target_link_libraries(${TARGET_NAME} PRIVATE ${OPENIMAGEDENOISE_LIBRARIES}) - endif() - endif() - target_link_libraries(${TARGET_NAME} PRIVATE - bf_testing_main - bf_intern_eigen - bf_intern_guardedalloc - extern_gtest - extern_gmock - # Needed for GLOG. - ${GLOG_LIBRARIES} - ${GFLAGS_LIBRARIES}) - - if(DEFINED PTHREADS_LIBRARIES) # Needed for GLOG. - target_link_libraries(${TARGET_NAME} PRIVATE ${PTHREADS_LIBRARIES}) - endif() - if(WITH_OPENMP AND WITH_OPENMP_STATIC) - target_link_libraries(${TARGET_NAME} PRIVATE ${OpenMP_LIBRARIES}) - endif() - if(UNIX AND NOT APPLE) - target_link_libraries(${TARGET_NAME} PRIVATE bf_intern_libc_compat) - endif() - if(WITH_TBB) - target_link_libraries(${TARGET_NAME} PRIVATE ${TBB_LIBRARIES}) - endif() - if(WITH_GMP) - target_link_libraries(${TARGET_NAME} PRIVATE ${GMP_LIBRARIES}) - endif() - - get_blender_test_install_dir(TEST_INSTALL_DIR) - set_target_properties(${TARGET_NAME} PROPERTIES - RUNTIME_OUTPUT_DIRECTORY "${TESTS_OUTPUT_DIR}" - RUNTIME_OUTPUT_DIRECTORY_RELEASE "${TESTS_OUTPUT_DIR}" - RUNTIME_OUTPUT_DIRECTORY_DEBUG "${TESTS_OUTPUT_DIR}") - if(NOT ARG_SKIP_ADD_TEST) - add_test( - NAME ${TARGET_NAME} - COMMAND ${TESTS_OUTPUT_DIR}/${TARGET_NAME} ${ARG_COMMAND_ARGS} - WORKING_DIRECTORY ${TEST_INSTALL_DIR}) - - # Don't fail tests on leaks since these often happen in external libraries - # that we can't fix. - set_tests_properties(${TARGET_NAME} PROPERTIES - ENVIRONMENT LSAN_OPTIONS=exitcode=0:$ENV{LSAN_OPTIONS} - ) - if(WIN32) - set_tests_properties(${TARGET_NAME} PROPERTIES ENVIRONMENT "PATH=${CMAKE_INSTALL_PREFIX_WITH_CONFIG}/blender.shared/;$ENV{PATH}") - endif() - endif() - if(WIN32) - set_target_properties(${TARGET_NAME} PROPERTIES VS_GLOBAL_VcpkgEnabled "false") - endif() - unset(MANIFEST) - unset(TEST_INC) - unset(TEST_INC_SYS) - unset(TARGET_NAME) - endif() -endmacro() - -function(blender_add_test_suite) - if(ARGC LESS 1) - message(FATAL_ERROR "No arguments supplied to blender_add_test_suite()") - endif() - - # Parse the arguments - set(oneValueArgs TARGET SUITE_NAME) - set(multiValueArgs SOURCES) - cmake_parse_arguments(ARGS "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - # Figure out the release dir, as some tests need files from there. - get_blender_test_install_dir(TEST_INSTALL_DIR) - if(APPLE) - set(_test_release_dir ${TEST_INSTALL_DIR}/Blender.app/Contents/Resources/${BLENDER_VERSION}) - else() - if(WIN32 OR WITH_INSTALL_PORTABLE) - set(_test_release_dir ${TEST_INSTALL_DIR}/${BLENDER_VERSION}) - else() - set(_test_release_dir ${TEST_INSTALL_DIR}/share/blender/${BLENDER_VERSION}) - endif() - endif() - - # Define a test case with our custom gtest_add_tests() command. - include(GTest) - gtest_add_tests( - TARGET ${ARGS_TARGET} - SOURCES "${ARGS_SOURCES}" - TEST_PREFIX ${ARGS_SUITE_NAME} - WORKING_DIRECTORY "${TEST_INSTALL_DIR}" - EXTRA_ARGS - --test-assets-dir "${CMAKE_SOURCE_DIR}/../lib/tests" - --test-release-dir "${_test_release_dir}" - ) - if(WIN32) - set_tests_properties( - ${ARGS_SUITE_NAME} PROPERTIES - ENVIRONMENT "PATH=${CMAKE_INSTALL_PREFIX_WITH_CONFIG}/blender.shared/;$ENV{PATH}" - ) - endif() - unset(_test_release_dir) -endfunction() - -# Add tests for a Blender library, to be called in tandem with blender_add_lib(). -# The tests will be part of the blender_test executable (see tests/gtests/runner). -function(blender_add_test_lib - name - sources - includes - includes_sys - library_deps - ) - - add_cc_flags_custom_test(${name} PARENT_SCOPE) - - # Otherwise external projects will produce warnings that we cannot fix. - remove_strict_flags() - - # This duplicates logic that's also in blender_src_gtest_ex. - # TODO(Sybren): deduplicate after the general approach in D7649 has been approved. - list(APPEND includes - ${CMAKE_SOURCE_DIR}/tests/gtests - ) - list(APPEND includes_sys - ${GLOG_INCLUDE_DIRS} - ${GFLAGS_INCLUDE_DIRS} - ${CMAKE_SOURCE_DIR}/extern/gtest/include - ${CMAKE_SOURCE_DIR}/extern/gmock/include - ) - - blender_add_lib__impl(${name} "${sources}" "${includes}" "${includes_sys}" "${library_deps}") - - target_compile_definitions(${name} PRIVATE ${GFLAGS_DEFINES}) - target_compile_definitions(${name} PRIVATE ${GLOG_DEFINES}) - - set_property(GLOBAL APPEND PROPERTY BLENDER_TEST_LIBS ${name}) - - blender_add_test_suite( - TARGET blender_test - SUITE_NAME ${name} - SOURCES "${sources}" - ) -endfunction() - - -# Add tests for a Blender library, to be called in tandem with blender_add_lib(). -# Test will be compiled into a ${name}_test executable. -# -# To be used for smaller isolated libraries, that do not have many dependencies. -# For libraries that do drag in many other Blender libraries and would create a -# very large executable, blender_add_test_lib() should be used instead. -function(blender_add_test_executable_impl - name - add_test_suite - sources - includes - includes_sys - library_deps - ) - - add_cc_flags_custom_test(${name} PARENT_SCOPE) - - ## Otherwise external projects will produce warnings that we cannot fix. - remove_strict_flags() - - blender_src_gtest_ex( - NAME ${name} - SRC "${sources}" - EXTRA_LIBS "${library_deps}" - SKIP_ADD_TEST - ) - if(add_test_suite) - blender_add_test_suite( - TARGET ${name}_test - SUITE_NAME ${name} - SOURCES "${sources}" - ) - endif() - blender_target_include_dirs(${name}_test ${includes}) - blender_target_include_dirs_sys(${name}_test ${includes_sys}) -endfunction() - -function(blender_add_test_executable - name - sources - includes - includes_sys - library_deps - ) - blender_add_test_executable_impl( - "${name}" - TRUE - "${sources}" - "${includes}" - "${includes_sys}" - "${library_deps}" - ) -endfunction() - -function(blender_add_performancetest_executable - name - sources - includes - includes_sys - library_deps - ) - blender_add_test_executable_impl( - "${name}" - FALSE - "${sources}" - "${includes}" - "${includes_sys}" - "${library_deps}" - ) -endfunction() diff --git a/intern/atomic/CMakeLists.txt b/intern/atomic/CMakeLists.txt index b3013a4a650..d69ade46bfd 100644 --- a/intern/atomic/CMakeLists.txt +++ b/intern/atomic/CMakeLists.txt @@ -41,5 +41,6 @@ if(WITH_GTESTS) set(TEST_LIB PRIVATE bf_intern_atomic ) + include(GTestTesting) blender_add_test_executable(atomic "${TEST_SRC}" "${INC};${TEST_INC}" "${INC_SYS}" "${LIB};${TEST_LIB}") endif() diff --git a/intern/cycles/test/CMakeLists.txt b/intern/cycles/test/CMakeLists.txt index 184e4b6af55..1e74b160e40 100644 --- a/intern/cycles/test/CMakeLists.txt +++ b/intern/cycles/test/CMakeLists.txt @@ -3,6 +3,8 @@ # SPDX-License-Identifier: Apache-2.0 if(WITH_GTESTS AND WITH_CYCLES_LOGGING) + Include(GTestTesting) + # Otherwise we get warnings here that we can't fix in external projects remove_strict_flags() endif() diff --git a/intern/ffmpeg/CMakeLists.txt b/intern/ffmpeg/CMakeLists.txt index 3e41030da8d..b8bf5a2c940 100644 --- a/intern/ffmpeg/CMakeLists.txt +++ b/intern/ffmpeg/CMakeLists.txt @@ -22,5 +22,6 @@ if(WITH_GTESTS) if(WITH_IMAGE_OPENJPEG) set(TEST_LIB ${TEST_LIB} ${OPENJPEG_LIBRARIES}) endif() + include(GTestTesting) blender_add_test_lib(ffmpeg_codecs "${TEST_SRC}" "${TEST_INC}" "${TEST_INC_SYS}" "${TEST_LIB}") endif() diff --git a/intern/guardedalloc/CMakeLists.txt b/intern/guardedalloc/CMakeLists.txt index be4db5725a5..81abc5a1092 100644 --- a/intern/guardedalloc/CMakeLists.txt +++ b/intern/guardedalloc/CMakeLists.txt @@ -83,5 +83,6 @@ if(WITH_GTESTS) bf_intern_guardedalloc bf_blenlib ) + include(GTestTesting) blender_add_test_executable(guardedalloc "${TEST_SRC}" "${INC};${TEST_INC}" "${INC_SYS}" "${LIB};${TEST_LIB}") endif() diff --git a/intern/libmv/CMakeLists.txt b/intern/libmv/CMakeLists.txt index 965d0028020..7cb06c4725b 100644 --- a/intern/libmv/CMakeLists.txt +++ b/intern/libmv/CMakeLists.txt @@ -198,6 +198,8 @@ if(WITH_LIBMV) if(WITH_GTESTS) + include(GTestTesting) + blender_add_lib(libmv_test_dataset "./libmv/multiview/test_data_sets.cc" "${INC}" "${INC_SYS}" "") blender_add_test_executable("libmv_predict_tracks" "./libmv/autotrack/predict_tracks_test.cc" "${INC}" "${INC_SYS}" "libmv_test_dataset;bf_intern_libmv;extern_ceres") diff --git a/intern/libmv/bundle.sh b/intern/libmv/bundle.sh index b35b16b5058..29e4dce60a8 100755 --- a/intern/libmv/bundle.sh +++ b/intern/libmv/bundle.sh @@ -190,6 +190,8 @@ ${third_headers} if(WITH_GTESTS) + include(GTestTesting) + blender_add_lib(libmv_test_dataset "./libmv/multiview/test_data_sets.cc" "\${INC}" "\${INC_SYS}" "") ${tests} diff --git a/intern/opensubdiv/CMakeLists.txt b/intern/opensubdiv/CMakeLists.txt index f3c07a0c4c8..00cd6de23d3 100644 --- a/intern/opensubdiv/CMakeLists.txt +++ b/intern/opensubdiv/CMakeLists.txt @@ -105,6 +105,8 @@ blender_add_lib(bf_intern_opensubdiv "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") # Tests. if(WITH_GTESTS AND WITH_OPENSUBDIV) + include(GTestTesting) + add_definitions(${GFLAGS_DEFINES}) add_definitions(${GLOG_DEFINES}) diff --git a/source/blender/animrig/CMakeLists.txt b/source/blender/animrig/CMakeLists.txt index 1e24abf68c6..dff06f030b8 100644 --- a/source/blender/animrig/CMakeLists.txt +++ b/source/blender/animrig/CMakeLists.txt @@ -63,5 +63,6 @@ if(WITH_GTESTS) set(TEST_LIB PRIVATE bf::animrig ) + include(GTestTesting) blender_add_test_lib(bf_animrig_tests "${TEST_SRC}" "${INC};${TEST_INC}" "${INC_SYS}" "${LIB};${TEST_LIB}") endif() diff --git a/source/blender/asset_system/CMakeLists.txt b/source/blender/asset_system/CMakeLists.txt index 6085432e77c..9200d1da9c0 100644 --- a/source/blender/asset_system/CMakeLists.txt +++ b/source/blender/asset_system/CMakeLists.txt @@ -64,5 +64,6 @@ if(WITH_GTESTS) set(TEST_LIB bf_asset_system ) + include(GTestTesting) blender_add_test_lib(bf_asset_system_tests "${TEST_SRC}" "${INC};${TEST_INC}" "${INC_SYS}" "${LIB};${TEST_LIB}") endif() diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index f5c1e476ae8..eb07fcdce40 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -863,6 +863,7 @@ if(WITH_GTESTS) set(TEST_INC ../editors/include ) + include(GTestTesting) blender_add_test_lib(bf_blenkernel_tests "${TEST_SRC}" "${INC};${TEST_INC}" "${INC_SYS}" "${LIB}") # RNA_prototypes.h diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt index 361dbfac763..3de5abb69e9 100644 --- a/source/blender/blenlib/CMakeLists.txt +++ b/source/blender/blenlib/CMakeLists.txt @@ -571,6 +571,7 @@ if(WITH_GTESTS) set(TEST_LIB bf_blenlib ) + include(GTestTesting) blender_add_test_executable(blenlib "${TEST_SRC}" "${INC};${TEST_INC}" "${INC_SYS}" "${LIB};${TEST_LIB}") add_subdirectory(tests/performance) diff --git a/source/blender/blenloader/CMakeLists.txt b/source/blender/blenloader/CMakeLists.txt index b994dab2d5d..383bd6ef3eb 100644 --- a/source/blender/blenloader/CMakeLists.txt +++ b/source/blender/blenloader/CMakeLists.txt @@ -111,5 +111,6 @@ if(WITH_GTESTS) set(TEST_LIB bf_blenloader ) + include(GTestTesting) blender_add_test_lib(bf_blenloader_tests "${TEST_SRC}" "${INC};${TEST_INC}" "${INC_SYS}" "${LIB};${TEST_LIB}") endif() diff --git a/source/blender/bmesh/CMakeLists.txt b/source/blender/bmesh/CMakeLists.txt index be6001b743d..0e62b06ff00 100644 --- a/source/blender/bmesh/CMakeLists.txt +++ b/source/blender/bmesh/CMakeLists.txt @@ -232,5 +232,6 @@ if(WITH_GTESTS) set(TEST_LIB bf_bmesh ) + include(GTestTesting) blender_add_test_lib(bf_bmesh_tests "${TEST_SRC}" "${INC};${TEST_INC}" "${INC_SYS}" "${LIB};${TEST_LIB}") endif() diff --git a/source/blender/compositor/CMakeLists.txt b/source/blender/compositor/CMakeLists.txt index 46e8d1116be..0a726e650a1 100644 --- a/source/blender/compositor/CMakeLists.txt +++ b/source/blender/compositor/CMakeLists.txt @@ -674,6 +674,7 @@ if(WITH_COMPOSITOR_CPU) set(TEST_LIB bf_compositor ) + include(GTestTesting) blender_add_test_lib(bf_compositor_tests "${TEST_SRC}" "${INC};${TEST_INC}" "${INC_SYS}" "${LIB};${TEST_LIB}") endif() diff --git a/source/blender/depsgraph/CMakeLists.txt b/source/blender/depsgraph/CMakeLists.txt index e84f5aa0049..ae5d5d55d8b 100644 --- a/source/blender/depsgraph/CMakeLists.txt +++ b/source/blender/depsgraph/CMakeLists.txt @@ -178,5 +178,6 @@ if(WITH_GTESTS) set(TEST_LIB bf_depsgraph ) + include(GTestTesting) blender_add_test_lib(bf_depsgraph_tests "${TEST_SRC}" "${INC};${TEST_INC}" "${INC_SYS}" "${LIB}") endif() diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index 091d8e865dd..0f4dd5fe19e 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -995,6 +995,7 @@ if(WITH_GTESTS) ) set(TEST_LIB ) + include(GTestTesting) blender_add_test_lib(bf_draw_tests "${TEST_SRC}" "${INC};${TEST_INC}" "${INC_SYS}" "${LIB};${TEST_LIB}") endif() endif() diff --git a/source/blender/editors/animation/CMakeLists.txt b/source/blender/editors/animation/CMakeLists.txt index b4aa4a7537a..f5ed75c72cd 100644 --- a/source/blender/editors/animation/CMakeLists.txt +++ b/source/blender/editors/animation/CMakeLists.txt @@ -71,5 +71,6 @@ if(WITH_GTESTS) ) set(TEST_LIB ) + include(GTestTesting) blender_add_test_lib(bf_editor_animation_tests "${TEST_SRC}" "${INC};${TEST_INC}" "${INC_SYS}" "${LIB};${TEST_LIB}") endif() diff --git a/source/blender/functions/CMakeLists.txt b/source/blender/functions/CMakeLists.txt index b297d754275..7d184b3f9b6 100644 --- a/source/blender/functions/CMakeLists.txt +++ b/source/blender/functions/CMakeLists.txt @@ -79,5 +79,6 @@ if(WITH_GTESTS) set(TEST_LIB bf_functions ) + include(GTestTesting) blender_add_test_lib(bf_functions_tests "${TEST_SRC}" "${INC};${TEST_INC}" "${INC_SYS}" "${LIB};${TEST_LIB}") endif() diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt index 9f8e68d79d3..b295562a477 100644 --- a/source/blender/gpu/CMakeLists.txt +++ b/source/blender/gpu/CMakeLists.txt @@ -923,6 +923,7 @@ if(WITH_GTESTS) tests/gpu_testing.hh ) + include(GTestTesting) blender_add_test_lib(bf_gpu_tests "${TEST_SRC}" "${INC};${TEST_INC}" "${INC_SYS}" "${LIB};${TEST_LIB}") endif() endif() diff --git a/source/blender/io/alembic/CMakeLists.txt b/source/blender/io/alembic/CMakeLists.txt index d2018e2ccfe..3f7822dcb77 100644 --- a/source/blender/io/alembic/CMakeLists.txt +++ b/source/blender/io/alembic/CMakeLists.txt @@ -114,5 +114,6 @@ if(WITH_GTESTS) set(TEST_LIB bf_io_alembic ) + include(GTestTesting) blender_add_test_lib(bf_io_alembic_tests "${TEST_SRC}" "${INC};${TEST_INC}" "${INC_SYS}" "${LIB};${TEST_LIB}") endif() diff --git a/source/blender/io/common/CMakeLists.txt b/source/blender/io/common/CMakeLists.txt index 77695dbe27e..10269e17d2e 100644 --- a/source/blender/io/common/CMakeLists.txt +++ b/source/blender/io/common/CMakeLists.txt @@ -55,5 +55,6 @@ if(WITH_GTESTS) bf_blenloader_tests bf_io_common ) + include(GTestTesting) blender_add_test_lib(bf_io_common_tests "${TEST_SRC}" "${INC};${TEST_INC}" "${INC_SYS}" "${LIB};${TEST_LIB}") endif() diff --git a/source/blender/io/ply/CMakeLists.txt b/source/blender/io/ply/CMakeLists.txt index eb1f88d80b2..04232accb2d 100644 --- a/source/blender/io/ply/CMakeLists.txt +++ b/source/blender/io/ply/CMakeLists.txt @@ -74,5 +74,6 @@ if(WITH_GTESTS) set(TEST_LIB bf_io_ply ) + include(GTestTesting) blender_add_test_lib(bf_io_ply_tests "${TEST_SRC}" "${INC};${TEST_INC}" "${INC_SYS}" "${LIB};${TEST_LIB}") endif() diff --git a/source/blender/io/stl/CMakeLists.txt b/source/blender/io/stl/CMakeLists.txt index 13a1fc02270..a3289f7a618 100644 --- a/source/blender/io/stl/CMakeLists.txt +++ b/source/blender/io/stl/CMakeLists.txt @@ -71,6 +71,7 @@ if(WITH_GTESTS) bf_io_stl ) + include(GTestTesting) blender_add_test_lib(bf_io_stl_tests "${TEST_SRC}" "${TEST_INC}" "${INC_SYS}" "${TEST_LIB}") add_dependencies(bf_io_stl_tests bf_io_stl) endif() diff --git a/source/blender/io/usd/CMakeLists.txt b/source/blender/io/usd/CMakeLists.txt index 5a60906bce5..a77f7a02f99 100644 --- a/source/blender/io/usd/CMakeLists.txt +++ b/source/blender/io/usd/CMakeLists.txt @@ -253,6 +253,7 @@ if(WITH_GTESTS) ) set(TEST_LIB ) + include(GTestTesting) blender_add_test_lib(bf_io_usd_tests "${TEST_SRC}" "${INC};${TEST_INC}" "${INC_SYS}" "${LIB};${TEST_LIB}") endif() diff --git a/source/blender/io/wavefront_obj/CMakeLists.txt b/source/blender/io/wavefront_obj/CMakeLists.txt index 0076e293583..70e421be6fb 100644 --- a/source/blender/io/wavefront_obj/CMakeLists.txt +++ b/source/blender/io/wavefront_obj/CMakeLists.txt @@ -95,6 +95,7 @@ if(WITH_GTESTS) bf_io_wavefront_obj ) + include(GTestTesting) blender_add_test_lib(bf_io_wavefront_obj_tests "${TEST_SRC}" "${TEST_INC}" "${INC_SYS}" "${TEST_LIB}") add_dependencies(bf_io_wavefront_obj_tests bf_io_wavefront_obj) endif() diff --git a/source/blender/windowmanager/CMakeLists.txt b/source/blender/windowmanager/CMakeLists.txt index f9b8b90e482..80eae0a0ae8 100644 --- a/source/blender/windowmanager/CMakeLists.txt +++ b/source/blender/windowmanager/CMakeLists.txt @@ -217,5 +217,6 @@ if(WITH_GTESTS) set(TEST_SRC intern/wm_dragdrop_test.cc ) + include(GTestTesting) blender_add_test_lib(bf_wm_tests "${TEST_SRC}" "${INC};${TEST_INC}" "${INC_SYS}" "${LIB}") endif()