Skip to content

Commit 30443a0

Browse files
kbenzielukaszstolarczuk
authored andcommitted
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 4598a5b commit 30443a0

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
@@ -268,17 +268,11 @@ endforeach()
268268
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
269269
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
270270
set(CMAKE_UMF_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
271-
if(MSVC)
271+
if(CMAKE_GENERATOR MATCHES "Visual Studio" OR CMAKE_GENERATOR MATCHES
272+
"Ninja Multi-Config")
272273
set(CMAKE_UMF_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/$<CONFIG>)
273274
endif()
274275

275-
# Define a path for custom commands to work around MSVC
276-
set(CUSTOM_COMMAND_BINARY_DIR ${CMAKE_UMF_OUTPUT_DIRECTORY})
277-
if(MSVC)
278-
# MSVC implicitly adds $<CONFIG> to the output path
279-
set(CUSTOM_COMMAND_BINARY_DIR ${CUSTOM_COMMAND_BINARY_DIR}/$<CONFIG>)
280-
endif()
281-
282276
# Sanitizer flags
283277
if(UMF_USE_ASAN)
284278
add_sanitizer_flag(address)

0 commit comments

Comments
 (0)