Skip to content

Commit 8d81df9

Browse files
committed
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/$<CONFIG>` 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 `$<CONFIG>` to the output directory.
1 parent 3d0fe19 commit 8d81df9

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

CMakeLists.txt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -332,17 +332,11 @@ endforeach()
332332
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
333333
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
334334
set(CMAKE_UMF_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
335-
if(MSVC)
335+
if(CMAKE_GENERATOR MATCHES "Visual Studio" OR CMAKE_GENERATOR MATCHES
336+
"Ninja Multi-Config")
336337
set(CMAKE_UMF_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/$<CONFIG>)
337338
endif()
338339

339-
# Define a path for custom commands to work around MSVC
340-
set(CUSTOM_COMMAND_BINARY_DIR ${CMAKE_UMF_OUTPUT_DIRECTORY})
341-
if(MSVC)
342-
# MSVC implicitly adds $<CONFIG> to the output path
343-
set(CUSTOM_COMMAND_BINARY_DIR ${CUSTOM_COMMAND_BINARY_DIR}/$<CONFIG>)
344-
endif()
345-
346340
# Sanitizer flags
347341
if(UMF_USE_ASAN)
348342
add_sanitizer_flag(address)

0 commit comments

Comments
 (0)