Fix: Unit tests on windows.
authorRay Molenkamp <github@lazydodo.com>
Thu, 3 Oct 2019 17:34:04 +0000 (11:34 -0600)
committerRay Molenkamp <github@lazydodo.com>
Thu, 3 Oct 2019 17:34:04 +0000 (11:34 -0600)
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

build_files/cmake/Modules/GTestTesting.cmake
tests/CMakeLists.txt

index 1c98a6456b84d45cedf27113546057248fba9dd6..a93e829e6b0676c01b844e073e68f3e85d97573e 100644 (file)
@@ -48,6 +48,14 @@ macro(BLENDER_SRC_GTEST_EX NAME SRC EXTRA_LIBS DO_ADD_TEST)
     if(WITH_OPENMP_STATIC)
       target_link_libraries(${TARGET_NAME} ${OpenMP_LIBRARIES})
     endif()
+
+    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()
+
     set_target_properties(${TARGET_NAME} PROPERTIES
                           RUNTIME_OUTPUT_DIRECTORY         "${TESTS_OUTPUT_DIR}"
                           RUNTIME_OUTPUT_DIRECTORY_RELEASE "${TESTS_OUTPUT_DIR}"
index 7d8a1390628da09822d0d13266fd959f09b00326..94b6e49181c1c0b7e79ad03a3c8959bcc657d8fd 100644 (file)
@@ -4,6 +4,7 @@
 #
 # 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()