Changeset View
Changeset View
Standalone View
Standalone View
build_files/cmake/macros.cmake
| Show First 20 Lines • Show All 382 Lines • ▼ Show 20 Lines | function(blender_add_lib | ||||
| add_cc_flags_custom_test(${name} PARENT_SCOPE) | add_cc_flags_custom_test(${name} PARENT_SCOPE) | ||||
| blender_add_lib__impl(${name} "${sources}" "${includes}" "${includes_sys}" "${library_deps}") | blender_add_lib__impl(${name} "${sources}" "${includes}" "${includes_sys}" "${library_deps}") | ||||
| set_property(GLOBAL APPEND PROPERTY BLENDER_LINK_LIBS ${name}) | set_property(GLOBAL APPEND PROPERTY BLENDER_LINK_LIBS ${name}) | ||||
| endfunction() | 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. | |||||
| 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} | |||||
| EXTRA_ARGS | |||||
| --test-assets-dir "${CMAKE_SOURCE_DIR}/../lib/tests" | |||||
| --test-release-dir "${_test_release_dir}" | |||||
| ) | |||||
| unset(_test_release_dir) | |||||
| endfunction() | |||||
| # Add tests for a Blender library, to be called in tandem with blender_add_lib(). | # 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). | # The tests will be part of the blender_test executable (see tests/gtests/runner). | ||||
| function(blender_add_test_lib | function(blender_add_test_lib | ||||
| name | name | ||||
| sources | sources | ||||
| includes | includes | ||||
| includes_sys | includes_sys | ||||
| library_deps | library_deps | ||||
| Show All 17 Lines | function(blender_add_test_lib | ||||
| ) | ) | ||||
| add_definitions(-DBLENDER_GFLAGS_NAMESPACE=${GFLAGS_NAMESPACE}) | add_definitions(-DBLENDER_GFLAGS_NAMESPACE=${GFLAGS_NAMESPACE}) | ||||
| add_definitions(${GFLAGS_DEFINES}) | add_definitions(${GFLAGS_DEFINES}) | ||||
| add_definitions(${GLOG_DEFINES}) | add_definitions(${GLOG_DEFINES}) | ||||
| blender_add_lib__impl(${name} "${sources}" "${includes}" "${includes_sys}" "${library_deps}") | blender_add_lib__impl(${name} "${sources}" "${includes}" "${includes_sys}" "${library_deps}") | ||||
| set_property(GLOBAL APPEND PROPERTY BLENDER_TEST_LIBS ${name}) | set_property(GLOBAL APPEND PROPERTY BLENDER_TEST_LIBS ${name}) | ||||
| blender_add_test_suite( | |||||
| TARGET blender_test | |||||
| SUITE_NAME ${name} | |||||
| SOURCES "${sources}" | |||||
| ) | |||||
| endfunction() | endfunction() | ||||
| # Add tests for a Blender library, to be called in tandem with blender_add_lib(). | # Add tests for a Blender library, to be called in tandem with blender_add_lib(). | ||||
| # Test will be compiled into a ${name}_test executable. | # Test will be compiled into a ${name}_test executable. | ||||
| # | # | ||||
| # To be used for smaller isolated libraries, that do not have many dependencies. | # 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 | # For libraries that do drag in many other Blender libraries and would create a | ||||
| Show All 17 Lines | function(blender_add_test_executable | ||||
| BLENDER_SRC_GTEST_EX( | BLENDER_SRC_GTEST_EX( | ||||
| NAME ${name} | NAME ${name} | ||||
| SRC "${sources}" | SRC "${sources}" | ||||
| EXTRA_LIBS "${library_deps}" | EXTRA_LIBS "${library_deps}" | ||||
| SKIP_ADD_TEST | SKIP_ADD_TEST | ||||
| ) | ) | ||||
| include(GTest) | blender_add_test_suite( | ||||
| set(_GOOGLETEST_DISCOVER_TESTS_SCRIPT | TARGET ${name}_test | ||||
| ${CMAKE_SOURCE_DIR}/build_files/cmake/Modules/GTestAddTests.cmake | SUITE_NAME ${name} | ||||
| ) | SOURCES "${sources}" | ||||
| gtest_discover_tests(${name}_test | |||||
| DISCOVERY_MODE PRE_TEST | |||||
| WORKING_DIRECTORY "${TEST_INSTALL_DIR}" | |||||
| ) | ) | ||||
| endfunction() | endfunction() | ||||
| # Ninja only: assign 'heavy pool' to some targets that are especially RAM-consuming to build. | # Ninja only: assign 'heavy pool' to some targets that are especially RAM-consuming to build. | ||||
| function(setup_heavy_lib_pool) | function(setup_heavy_lib_pool) | ||||
| if(WITH_NINJA_POOL_JOBS AND NINJA_MAX_NUM_PARALLEL_COMPILE_HEAVY_JOBS) | if(WITH_NINJA_POOL_JOBS AND NINJA_MAX_NUM_PARALLEL_COMPILE_HEAVY_JOBS) | ||||
| if(WITH_CYCLES) | if(WITH_CYCLES) | ||||
| list(APPEND _HEAVY_LIBS "cycles_device" "cycles_kernel") | list(APPEND _HEAVY_LIBS "cycles_device" "cycles_kernel") | ||||
| ▲ Show 20 Lines • Show All 797 Lines • Show Last 20 Lines | |||||