Fix MSVC builds and test runs

Change-Id: I79f839b22985a6510965559af54209d89c8703a0
diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml
index b2ad9ea..1c76c85 100644
--- a/.github/workflows/android.yml
+++ b/.github/workflows/android.yml
@@ -36,8 +36,8 @@
         run: |
           sudo apt-get update
           sudo apt-get install -y \
-            git \
             ccache \
+            git \
             ninja-build
 
       - uses: actions/checkout@v4
diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml
index 86b9a70..c7e2cfa 100644
--- a/.github/workflows/linux.yml
+++ b/.github/workflows/linux.yml
@@ -34,10 +34,10 @@
         run: |
           apt-get update
           apt-get install -y \
-            git \
             build-essential \
             ccache \
             cmake \
+            git \
             libbenchmark-dev \
             libblas-dev \
             libeigen3-dev \
diff --git a/internal/ceres/CMakeLists.txt b/internal/ceres/CMakeLists.txt
index dcbdd36..f4e40fb 100644
--- a/internal/ceres/CMakeLists.txt
+++ b/internal/ceres/CMakeLists.txt
@@ -401,6 +401,10 @@
   target_link_libraries (test_util PUBLIC GTest::gmock ceres_static)
   target_compile_definitions(test_util PRIVATE CERES_TEST_SRCDIR_SUFFIX="../../data")
 
+  if (BUILD_SHARED_LIBS)
+    target_compile_definitions(test_util PUBLIC GTEST_LINKED_AS_SHARED_LIBRARY=1)
+  endif (BUILD_SHARED_LIBS)
+
   macro (CERES_TEST NAME)
     add_executable(${NAME}_test ${NAME}_test.cc)
 
@@ -425,8 +429,10 @@
       target_link_libraries (${NAME}_test PRIVATE SuiteSparse::SPQR)
     endif (TARGET SuiteSparse::SPQR)
 
-    add_test(NAME ${NAME}_test
-             COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${NAME}_test)
+    add_test(NAME ${NAME}_test COMMAND ${NAME}_test)
+    # Override testing::SrcDir to support multi-configuration builds, such as MSVC
+    # that write binaries into addtional configuration specific subdirectories.
+    set_tests_properties(${NAME}_test PROPERTIES ENVIRONMENT TEST_SRCDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
   endmacro (CERES_TEST)
 
   ceres_test(array_utils)