blender/tests/CMakeLists.txt
Ray Molenkamp 6ac2a2061f Fix: Unit tests on windows.
Problem was twofold

1) `GENERATOR_IS_MULTI_CONFIG` is a property not a variable so
the test for it would always be false, unless you set a custom
CMAKE_INSTALL_PREFIX (like the buildbot does) the unit tests
would have a wrong working directory and complain about missing
dlls or blender executable

2) Tests added outside of `/test` (like libmv) would have no working
folder set since the variable would not be visible for them.

consulted @sergey who voiced the opinion that duplicating the code
to the test macro was slightly less evil than moving it to the main
CMakeLists.txt
2019-10-03 11:34:04 -06:00

39 lines
1.4 KiB
CMake

# Always run tests from install path, so all required scripts and libraries
# are available and we are testing the actual installation layout.
#
# Getting the install path of the executable is somewhat involved, as there are
# no direct CMake generator expressions to get the install paths of executables.
get_property(GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(GENERATOR_IS_MULTI_CONFIG)
string(REPLACE "\${BUILD_TYPE}" "$<CONFIG>" TEST_INSTALL_DIR ${CMAKE_INSTALL_PREFIX})
else()
string(REPLACE "\${BUILD_TYPE}" "" TEST_INSTALL_DIR ${CMAKE_INSTALL_PREFIX})
endif()
# Path to Blender and Python executables for all platforms.
if(MSVC)
set(TEST_BLENDER_EXE ${TEST_INSTALL_DIR}/blender.exe)
set(TEST_PYTHON_EXE "${TEST_INSTALL_DIR}/${BLENDER_VERSION_MAJOR}.${BLENDER_VERSION_MINOR}/python/bin/python$<$<CONFIG:Debug>:_d>")
elseif(APPLE)
set(TEST_BLENDER_EXE ${TEST_INSTALL_DIR}/Blender.app/Contents/MacOS/Blender)
set(TEST_PYTHON_EXE)
else()
set(TEST_BLENDER_EXE ${TEST_INSTALL_DIR}/blender)
set(TEST_PYTHON_EXE)
endif()
# For testing with Valgrind
# set(TEST_BLENDER_EXE valgrind --track-origins=yes --error-limit=no ${TEST_BLENDER_EXE})
# Standard Blender arguments for running tests.
set(TEST_BLENDER_EXE_PARAMS --background -noaudio --factory-startup)
# Python CTests
if(WITH_BLENDER AND WITH_PYTHON)
add_subdirectory(python)
endif()
# GTest
add_subdirectory(gtests)