diff --git a/cmake/winml.cmake b/cmake/winml.cmake index f5171158f230e..f9c02ddf0e9e5 100644 --- a/cmake/winml.cmake +++ b/cmake/winml.cmake @@ -442,15 +442,15 @@ endif(onnxruntime_USE_DML) # The default libraries to link with in Windows are kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib # Remove them and use the onecore umbrella library instead -set(CMAKE_C_STANDARD_LIBRARIES "onecoreuap_apiset.lib") -set(CMAKE_CXX_STANDARD_LIBRARIES "onecoreuap_apiset.lib") foreach(default_lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdgl32.lib advapi32.lib) set(removed_libs "${removed_libs} /NODEFAULTLIB:${default_lib}") endforeach() +set(CMAKE_C_STANDARD_LIBRARIES "${removed_libs} onecoreuap.lib") +set(CMAKE_CXX_STANDARD_LIBRARIES "${removed_libs} onecoreuap.lib") set_target_properties(winml_dll PROPERTIES LINK_FLAGS - "/DEF:${WINML_DIR}/windows.ai.machinelearning.def ${os_component_link_flags} /DELAYLOAD:d3d12.dll /DELAYLOAD:d3d11.dll /DELAYLOAD:dxgi.dll ${delayload_dml} ${removed_libs}") + "/DEF:${WINML_DIR}/windows.ai.machinelearning.def ${os_component_link_flags} /DELAYLOAD:d3d12.dll /DELAYLOAD:d3d11.dll /DELAYLOAD:dxgi.dll ${delayload_dml}") set_target_properties(winml_dll diff --git a/cmake/winml_unittests.cmake b/cmake/winml_unittests.cmake index bd91611a6d17c..0596c711dca1a 100644 --- a/cmake/winml_unittests.cmake +++ b/cmake/winml_unittests.cmake @@ -44,7 +44,7 @@ function(add_winml_test) if (_UT_DEPENDS) add_dependencies(${_UT_TARGET} ${_UT_DEPENDS}) endif() - target_link_libraries(${_UT_TARGET} PRIVATE ${_UT_LIBS} gtest windowsapp winml_lib_image ${onnxruntime_EXTERNAL_LIBRARIES} winml_lib_telemetry winml_lib_api onnxruntime) + target_link_libraries(${_UT_TARGET} PRIVATE ${_UT_LIBS} gtest winml_lib_image ${onnxruntime_EXTERNAL_LIBRARIES} winml_lib_telemetry winml_lib_api onnxruntime) add_test(NAME ${_UT_TARGET} COMMAND ${_UT_TARGET} @@ -81,7 +81,7 @@ endif() add_winml_test( TARGET winml_test_scenario SOURCES ${winml_test_scenario_src} - LIBS winml_test_common ${winml_test_scenario_libs} + LIBS winml_test_common delayimp.lib ${winml_test_scenario_libs} ) target_precompiled_header(winml_test_scenario testPch.h) target_compile_definitions(winml_test_scenario PRIVATE BUILD_GOOGLE_TEST) diff --git a/winml/test/api/LearningModelSessionAPITest.cpp b/winml/test/api/LearningModelSessionAPITest.cpp index 6ee0b3d57f751..908d13532e44d 100644 --- a/winml/test/api/LearningModelSessionAPITest.cpp +++ b/winml/test/api/LearningModelSessionAPITest.cpp @@ -417,4 +417,4 @@ const LearningModelSesssionAPITestApi& getapi() { CloseSession, }; return api; -} \ No newline at end of file +} diff --git a/winml/test/common/googleTestMacros.h b/winml/test/common/googleTestMacros.h index dc38c6402f005..b7ee591404b2a 100644 --- a/winml/test/common/googleTestMacros.h +++ b/winml/test/common/googleTestMacros.h @@ -64,7 +64,7 @@ #ifndef USE_DML #define GPUTEST \ - WINML_SKIP_TEST("GPU tests disabled because this is a WinML only build (no DML)") + WINML_SUPRESS_UNREACHABLE_BELOW(WINML_SKIP_TEST("GPU tests disabled because this is a WinML only build (no DML)")) #else #define GPUTEST \ if (auto noGpuTests = RuntimeParameters::Parameters.find("noGPUtests"); \ diff --git a/winml/test/common/taefTestMacros.h b/winml/test/common/taefTestMacros.h index 06d9048d7c6ff..083baa531a99e 100644 --- a/winml/test/common/taefTestMacros.h +++ b/winml/test/common/taefTestMacros.h @@ -23,10 +23,12 @@ using namespace WEX::TestExecution; getapi().test_name(); \ } -#define WINML_SKIP_TEST(message) \ - Log::Result(TestResults::Skipped, \ - std::wstring_convert>().from_bytes(message).c_str()); \ - return; +#define WINML_SKIP_TEST(message) \ + do { \ + Log::Result(TestResults::Skipped, \ + std::wstring_convert>().from_bytes(message).c_str()); \ + return; \ + } while (0) #define WINML_EXPECT_NO_THROW(statement) VERIFY_NO_THROW(statement) #define WINML_EXPECT_TRUE(statement) VERIFY_IS_TRUE(statement) @@ -43,7 +45,7 @@ using namespace WEX::TestExecution; #ifndef USE_DML #define GPUTEST \ - WINML_SKIP_TEST("GPU tests disabled because this is a WinML only build (no DML)") + WINML_SUPRESS_UNREACHABLE_BELOW(WINML_SKIP_TEST("GPU tests disabled because this is a WinML only build (no DML)")) #else #define GPUTEST \ bool noGPUTests; \ @@ -58,4 +60,4 @@ using namespace WEX::TestExecution; if (SUCCEEDED(RuntimeParameters::TryGetValue(L"EdgeCore", edgeCoreRun)) && edgeCoreRun) { \ WINML_SKIP_TEST("This test is disabled by the EdgeCore runtime parameter."); \ return; \ - } \ No newline at end of file + } diff --git a/winml/test/common/test.h b/winml/test/common/test.h index 31739f672503f..037f59e932484 100644 --- a/winml/test/common/test.h +++ b/winml/test/common/test.h @@ -1,10 +1,18 @@ +#pragma once + using VoidTest = void (*)(); using SetupTest = VoidTest; +constexpr bool alwaysTrue() { + return true; +} +#define WINML_SUPRESS_UNREACHABLE_BELOW(statement) \ + if (alwaysTrue()) { statement; } + #ifdef BUILD_GOOGLE_TEST #include "googleTestMacros.h" #else #ifdef BUILD_TAEF_TEST #include "taefTestMacros.h" #endif -#endif \ No newline at end of file +#endif