From 8d81df93ce4a77cc656cf7730d21698ff9646473 Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Thu, 21 Nov 2024 14:27:17 +0000 Subject: [PATCH] Fix output directory on Windows with non-VS generators On Windows when configuring CMake with the Ninja generator and `-DUMF_BUILD_SHARED_LIBRARY=ON` the `umf.dll` is output to the `${CMAKE_BINARY_DIR}/bin/$` directory, this is problematic as it breaks tools like `urinfo.exe` and `sycl-ls.exe` in development builds as they rely on `umf.dll` residing in the same directory in order to be loaded. This behavior is desirable when using Visual Studio generators, however. Therefore, this patch changes the logic to check if `CMAKE_GENERATOR` matches the `"Visual Studio"` string before appending `$` to the output directory. --- CMakeLists.txt | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f55a4198c7..d1409c0c5f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -332,17 +332,11 @@ endforeach() set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_UMF_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) -if(MSVC) +if(CMAKE_GENERATOR MATCHES "Visual Studio" OR CMAKE_GENERATOR MATCHES + "Ninja Multi-Config") set(CMAKE_UMF_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/$) endif() -# Define a path for custom commands to work around MSVC -set(CUSTOM_COMMAND_BINARY_DIR ${CMAKE_UMF_OUTPUT_DIRECTORY}) -if(MSVC) - # MSVC implicitly adds $ to the output path - set(CUSTOM_COMMAND_BINARY_DIR ${CUSTOM_COMMAND_BINARY_DIR}/$) -endif() - # Sanitizer flags if(UMF_USE_ASAN) add_sanitizer_flag(address)