@@ -429,24 +429,70 @@ elseif(UMF_BUILD_CUDA_PROVIDER)
429429endif ()
430430
431431if (WINDOWS AND UMF_USE_DEBUG_POSTFIX )
432- # Build debug umf library with the d suffix that is compiled with /MDd so
433- # users can link against it in debug builds.
434- set (CMAKE_DEBUG_POSTFIX d)
435-
432+ # Build the umfd target in a separate directory with Debug configuration
436433 add_custom_target (
437- umfd ALL
438- COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target umf
439- --config Debug
440- COMMENT "Building debug umf library with the d suffix" )
434+ build_umfd ALL
435+ COMMAND
436+ ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR} " -S ${UMF_CMAKE_SOURCE_DIR}
437+ -B ${CMAKE_BINARY_DIR} /umfd_build -DCMAKE_BUILD_TYPE=Debug
438+ -DCMAKE_DEBUG_POSTFIX =d -DCMAKE_PREFIX_PATH="'${CMAKE_PREFIX_PATH} '"
439+ -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
440+ -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
441+ -DUMF_USE_DEBUG_POSTFIX =OFF
442+ -DUMF_BUILD_SHARED_LIBRARY=${UMF_BUILD_SHARED_LIBRARY}
443+ -DUMF_BUILD_LEVEL_ZERO_PROVIDER=${UMF_BUILD_LEVEL_ZERO_PROVIDER}
444+ -DUMF_BUILD_CUDA_PROVIDER=${UMF_BUILD_CUDA_PROVIDER}
445+ -DUMF_BUILD_LIBUMF_POOL_JEMALLOC=${UMF_BUILD_LIBUMF_POOL_JEMALLOC}
446+ -DUMF_BUILD_TESTS=OFF -DUMF_BUILD_GPU_TESTS=OFF
447+ -DUMF_BUILD_BENCHMARKS=OFF -DUMF_BUILD_BENCHMARKS_MT=OFF
448+ -DUMF_BUILD_EXAMPLES=OFF -DUMF_BUILD_GPU_EXAMPLES=OFF
449+ -DUMF_BUILD_FUZZTESTS=OFF -DUMF_DISABLE_HWLOC=${UMF_DISABLE_HWLOC}
450+ -DUMF_LINK_HWLOC_STATICALLY=${UMF_LINK_HWLOC_STATICALLY}
451+ -DUMF_HWLOC_NAME=${UMF_HWLOC_NAME}
452+ -DUMF_INSTALL_RPATH=${UMF_INSTALL_RPATH} -DUMF_DEVELOPER_MODE=OFF
453+ -DUMF_FORMAT_CODE_STYLE=OFF -DUMF_TESTS_FAIL_ON_SKIP=OFF
454+ -DUMF_USE_ASAN=OFF -DUMF_USE_UBSAN=OFF -DUMF_USE_TSAN=OFF
455+ -DUMF_USE_MSAN=OFF -DUMF_USE_VALGRIND=OFF -DUMF_USE_COVERAGE=OFF
456+ -DUMF_PROXY_LIB_BASED_ON_POOL=${UMF_PROXY_LIB_BASED_ON_POOL}
457+ COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} /umfd_build --target
458+ umf --config Debug
459+ COMMENT
460+ "Configuring and building umfd.dll in a separate directory with Debug configuration"
461+ )
441462
442- # Copy built UMF libraries to the Release build subdirectory
443- add_custom_command (
444- TARGET umfd
445- COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR} /bin/Debug/umfd.dll
446- ${CMAKE_BINARY_DIR} /bin/Release/umfd.dll
447- COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR} /lib/Debug/umfd.lib
448- ${CMAKE_BINARY_DIR} /lib/Release/umfd.lib
449- COMMENT "Copying debug libraries to the Release build directory" )
463+ # Copy built UMF libraries to the main binary directory and remove
464+ # umfd_build
465+ if (CMAKE_CONFIGURATION_TYPES )
466+ # Multi-config generator (e.g., Visual Studio)
467+ add_custom_command (
468+ TARGET build_umfd
469+ COMMAND
470+ ${CMAKE_COMMAND} -E copy_if_different
471+ ${CMAKE_BINARY_DIR} /umfd_build/bin/Debug/umfd.dll
472+ ${CMAKE_BINARY_DIR} /bin/$<CONFIG>/umfd.dll
473+ COMMAND
474+ ${CMAKE_COMMAND} -E copy_if_different
475+ ${CMAKE_BINARY_DIR} /umfd_build/lib/Debug/umfd.lib
476+ ${CMAKE_BINARY_DIR} /lib/$<CONFIG>/umfd.lib
477+ COMMAND ${CMAKE_COMMAND} -E remove_directory
478+ ${CMAKE_BINARY_DIR} /umfd_build
479+ COMMENT "Copying debug libraries to the main binary directory" )
480+ else ()
481+ # Single-config generator (e.g., Ninja)
482+ add_custom_command (
483+ TARGET build_umfd
484+ COMMAND
485+ ${CMAKE_COMMAND} -E copy_if_different
486+ ${CMAKE_BINARY_DIR} /umfd_build/bin/umfd.dll
487+ ${CMAKE_BINARY_DIR} /bin/umfd.dll
488+ COMMAND
489+ ${CMAKE_COMMAND} -E copy_if_different
490+ ${CMAKE_BINARY_DIR} /umfd_build/lib/umfd.lib
491+ ${CMAKE_BINARY_DIR} /lib/umfd.lib
492+ COMMAND ${CMAKE_COMMAND} -E remove_directory
493+ ${CMAKE_BINARY_DIR} /umfd_build
494+ COMMENT "Copying debug libraries to the main binary directory" )
495+ endif ()
450496endif ()
451497
452498# This build type check is not possible on Windows when CMAKE_BUILD_TYPE is not
@@ -841,12 +887,24 @@ endif()
841887# --------------------------------------------------------------------------- #
842888# Configure make install/uninstall and packages
843889# --------------------------------------------------------------------------- #
844- # Install umfd target
890+ # Install the umfd library files as part of the umfd component
845891if (WINDOWS AND UMF_USE_DEBUG_POSTFIX )
846- install (FILES ${CMAKE_BINARY_DIR} /bin/Debug/umfd.dll
847- DESTINATION ${CMAKE_INSTALL_BINDIR} )
848- install (FILES ${CMAKE_BINARY_DIR} /lib/Debug/umfd.lib
849- DESTINATION ${CMAKE_INSTALL_LIBDIR} )
892+ if (CMAKE_CONFIGURATION_TYPES )
893+ set (UMFD_DLL "${CMAKE_BINARY_DIR} /bin/$<CONFIG>/umfd.dll" )
894+ set (UMFD_LIB "${CMAKE_BINARY_DIR} /lib/$<CONFIG>/umfd.lib" )
895+ else ()
896+ set (UMFD_DLL "${CMAKE_BINARY_DIR} /bin/umfd.dll" )
897+ set (UMFD_LIB "${CMAKE_BINARY_DIR} /lib/umfd.lib" )
898+ endif ()
899+
900+ install (
901+ FILES ${UMFD_DLL}
902+ DESTINATION ${CMAKE_INSTALL_BINDIR}
903+ COMPONENT umfd)
904+ install (
905+ FILES ${UMFD_LIB}
906+ DESTINATION ${CMAKE_INSTALL_LIBDIR}
907+ COMPONENT umfd)
850908endif ()
851909
852910install (FILES ${PROJECT_SOURCE_DIR} /LICENSE.TXT
0 commit comments