Skip to content

Commit 7fd639c

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 673b844 commit 7fd639c

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
@@ -275,17 +275,10 @@ endforeach()
275275
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
276276
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
277277
set(CMAKE_UMF_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
278-
if(MSVC)
278+
if(CMAKE_GENERATOR MATCHES "Visual Studio")
279279
set(CMAKE_UMF_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/$<CONFIG>)
280280
endif()
281281

282-
# Define a path for custom commands to work around MSVC
283-
set(CUSTOM_COMMAND_BINARY_DIR ${CMAKE_UMF_OUTPUT_DIRECTORY})
284-
if(MSVC)
285-
# MSVC implicitly adds $<CONFIG> to the output path
286-
set(CUSTOM_COMMAND_BINARY_DIR ${CUSTOM_COMMAND_BINARY_DIR}/$<CONFIG>)
287-
endif()
288-
289282
# Sanitizer flags
290283
if(UMF_USE_ASAN)
291284
add_sanitizer_flag(address)

0 commit comments

Comments
 (0)