Skip to content

Commit ced8f13

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 ced8f13

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

CMakeLists.txt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -332,17 +332,10 @@ 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 "Ninja Multi-Config")
336336
set(CMAKE_UMF_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/$<CONFIG>)
337337
endif()
338338

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-
346339
# Sanitizer flags
347340
if(UMF_USE_ASAN)
348341
add_sanitizer_flag(address)

0 commit comments

Comments
 (0)