diff --git a/unittests/Support/DynamicLibrary/CMakeLists.txt b/unittests/Support/DynamicLibrary/CMakeLists.txt index 00d20510ffd..c241837e521 100644 --- a/unittests/Support/DynamicLibrary/CMakeLists.txt +++ b/unittests/Support/DynamicLibrary/CMakeLists.txt @@ -39,13 +39,15 @@ function(dynlib_add_module NAME) add_dependencies(DynamicLibraryTests ${NAME}) - # We need to link in the Support lib for the Memory allocator override, - # otherwise the DynamicLibrary.Shutdown test will fail, because it would - # allocate memory with the CRT allocator, and release it with our custom - # allocator (see llvm/lib/Support/Windows/Memory.inc). - # /INCLUDE:malloc is there to force searching into LLVMSupport before libucrt - llvm_map_components_to_libnames(llvm_libs Support) - target_link_libraries(${NAME} ${llvm_libs} "-INCLUDE:malloc") + if(LLVM_INTEGRATED_CRT_ALLOC) + # We need to link in the Support lib for the Memory allocator override, + # otherwise the DynamicLibrary.Shutdown test will fail, because it would + # allocate memory with the CRT allocator, and release it with our custom + # allocator (see llvm/lib/Support/Windows/Memory.inc). + # /INCLUDE:malloc is there to force searching into LLVMSupport before libucrt + llvm_map_components_to_libnames(llvm_libs Support) + target_link_libraries(${NAME} ${llvm_libs} "-INCLUDE:malloc") + endif() endfunction(dynlib_add_module)