Skip to content

Commit 1f11268

Browse files
committed
Fix gtest build to work for windows static or dynamic
Signed-off-by: Neil R. Spruit <neil.r.spruit@intel.com>
1 parent 41e5e32 commit 1f11268

2 files changed

Lines changed: 2 additions & 13 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ endif()
5252

5353
include(FetchContent)
5454

55-
if(BUILD_L0_LOADER_TESTS AND (NOT MSVC OR (MSVC AND NOT BUILD_STATIC)))
55+
if(BUILD_L0_LOADER_TESTS)
5656
FetchContent_Declare(
5757
googletest
5858
GIT_REPOSITORY https://github.com/google/googletest.git
@@ -61,11 +61,6 @@ if(BUILD_L0_LOADER_TESTS AND (NOT MSVC OR (MSVC AND NOT BUILD_STATIC)))
6161
add_library(GTest::GTest INTERFACE IMPORTED)
6262
target_link_libraries(GTest::GTest INTERFACE gtest_main)
6363

64-
# For Windows: Prevent overriding the parent project's compiler/linker settings
65-
if(MSVC)
66-
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
67-
endif()
68-
6964
FetchContent_MakeAvailable(googletest)
7065

7166
enable_testing()
@@ -229,7 +224,7 @@ set(TARGET_LOADER_NAME ze_loader)
229224
add_subdirectory(source)
230225
add_subdirectory(samples)
231226

232-
if(BUILD_L0_LOADER_TESTS AND (NOT MSVC OR (MSVC AND NOT BUILD_STATIC)))
227+
if(BUILD_L0_LOADER_TESTS)
233228
include(CTest)
234229
add_subdirectory(test)
235230
endif()

test/CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ target_link_libraries(
1313
${TARGET_LOADER_NAME}
1414
)
1515

16-
# For some reason the MSVC runtime libraries used by googletest and test
17-
# binaries don't match, so force the test binary to use the dynamic runtime.
18-
if(MSVC)
19-
target_compile_options(tests PRIVATE "/MD$<$<CONFIG:Debug>:d>")
20-
endif()
21-
2216
add_test(NAME tests_api COMMAND tests --gtest_filter=*GivenLevelZeroLoaderPresentWhenCallingzeGetLoaderVersionsAPIThenValidVersionIsReturned*)
2317
set_property(TEST tests_api PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_NULL_DRIVER=1")
2418
add_test(NAME tests_init_gpu_all COMMAND tests --gtest_filter=*GivenLevelZeroLoaderPresentWhenCallingZeInitDriversWithGPUTypeThenExpectPassWithGPUorAllOnly*)

0 commit comments

Comments
 (0)