From a602e4fa400b1e61a68a8e52bec24055776d9944 Mon Sep 17 00:00:00 2001 From: Ray Molenkamp Date: Tue, 7 May 2024 12:19:20 -0600 Subject: [PATCH] CMake: Fix ASAN builds on windows When building with asan enabled on windows tools such as msgfmt will run before the install phase which normally copies the required asan dlls next to the binaries preventing msgfmt from stating and causing a build error. This change adds the MSVC path to the PLATFORM_ENV_BUILD_DIRS so when we run the various tools the asan shared libs can be found. --- build_files/cmake/platform/platform_win32.cmake | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/build_files/cmake/platform/platform_win32.cmake b/build_files/cmake/platform/platform_win32.cmake index ba58a2f27f7..fe251fcf08a 100644 --- a/build_files/cmake/platform/platform_win32.cmake +++ b/build_files/cmake/platform/platform_win32.cmake @@ -1319,12 +1319,15 @@ if(WITH_CYCLES AND (WITH_CYCLES_DEVICE_ONEAPI OR (WITH_CYCLES_EMBREE AND EMBREE_ ) endif() - +# Add the msvc directory to the path so when building with ASAN enabled tools such as +# msgfmt which run before the install phase can find the asan shared libraries. +get_filename_component(_msvc_path ${CMAKE_C_COMPILER} DIRECTORY) # Environment variables to run precompiled executables that needed libraries. list(JOIN PLATFORM_BUNDLED_LIBRARY_DIRS ";" _library_paths) -set(PLATFORM_ENV_BUILD_DIRS "${LIBDIR}/epoxy/bin\;${LIBDIR}/tbb/bin\;${LIBDIR}/OpenImageIO/bin\;${LIBDIR}/boost/lib\;${LIBDIR}/openexr/bin\;${LIBDIR}/imath/bin\;${LIBDIR}/shaderc/bin\;${PATH}") +set(PLATFORM_ENV_BUILD_DIRS "${_msvc_path}\;${LIBDIR}/epoxy/bin\;${LIBDIR}/tbb/bin\;${LIBDIR}/OpenImageIO/bin\;${LIBDIR}/boost/lib\;${LIBDIR}/openexr/bin\;${LIBDIR}/imath/bin\;${LIBDIR}/shaderc/bin\;${PATH}") set(PLATFORM_ENV_BUILD "PATH=${PLATFORM_ENV_BUILD_DIRS}") # Install needs the additional folders from PLATFORM_ENV_BUILD_DIRS as well, as tools like: # `idiff` and `abcls` use the release mode dlls. set(PLATFORM_ENV_INSTALL "PATH=${CMAKE_INSTALL_PREFIX_WITH_CONFIG}/blender.shared/\;${PLATFORM_ENV_BUILD_DIRS}\;$ENV{PATH}") unset(_library_paths) +unset(_msvc_path)