@@ -58,6 +58,8 @@ macro(umf_option)
5858 option (${ARGV} )
5959endmacro ()
6060
61+ # All CMake options have to be explicitly set in the build_umfd target's
62+ # configuration command
6163umf_option(UMF_BUILD_SHARED_LIBRARY "Build UMF as shared library" OFF )
6264umf_option(UMF_BUILD_LEVEL_ZERO_PROVIDER "Build Level Zero memory provider" ON )
6365umf_option(UMF_BUILD_CUDA_PROVIDER "Build CUDA memory provider" ON )
@@ -89,6 +91,8 @@ set(UMF_INSTALL_RPATH
8991 "Set the runtime search path to the directory with dependencies (e.g. hwloc)"
9092)
9193
94+ umf_option(UMF_USE_DEBUG_POSTFIX "Add a 'd' postfix to Windows debug libraries"
95+ OFF )
9296umf_option(UMF_DEVELOPER_MODE "Enable additional developer checks" OFF )
9397umf_option(
9498 UMF_FORMAT_CODE_STYLE
@@ -146,6 +150,8 @@ if(UMF_DEVELOPER_MODE)
146150 UMF_DEVELOPER_MODE=1)
147151endif ()
148152
153+ message (STATUS "CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} " )
154+
149155if (NOT UMF_BUILD_LIBUMF_POOL_JEMALLOC)
150156 set (UMF_POOL_JEMALLOC_ENABLED FALSE )
151157 set (JEMALLOC_FOUND FALSE )
@@ -291,6 +297,7 @@ else()
291297 set (HWLOC_ENABLE_TESTING OFF )
292298 set (HWLOC_SKIP_LSTOPO ON )
293299 set (HWLOC_SKIP_TOOLS ON )
300+ set (HWLOC_SKIP_INCLUDES ON )
294301
295302 FetchContent_Declare(
296303 hwloc_targ
@@ -434,6 +441,74 @@ elseif(UMF_BUILD_CUDA_PROVIDER)
434441 message (STATUS "CUDA_INCLUDE_DIRS = ${CUDA_INCLUDE_DIRS} " )
435442endif ()
436443
444+ # Build the umfd target in a separate directory with Debug configuration
445+ if (WINDOWS AND UMF_USE_DEBUG_POSTFIX )
446+ # The build_umfd target's configuration command requires to have
447+ # CMAKE_PREFIX_PATH with semicolons escaped
448+ string (JOIN "\; " UMFD_CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} )
449+ add_custom_target (
450+ build_umfd ALL
451+ COMMAND
452+ ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR} " -S ${UMF_CMAKE_SOURCE_DIR}
453+ -B ${CMAKE_BINARY_DIR} /umfd_build -DCMAKE_BUILD_TYPE=Debug
454+ -DCMAKE_DEBUG_POSTFIX =d
455+ -DCMAKE_PREFIX_PATH="${UMFD_CMAKE_PREFIX_PATH} "
456+ -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
457+ -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
458+ -DUMF_USE_DEBUG_POSTFIX =OFF
459+ -DUMF_BUILD_SHARED_LIBRARY=${UMF_BUILD_SHARED_LIBRARY}
460+ -DUMF_BUILD_LEVEL_ZERO_PROVIDER=${UMF_BUILD_LEVEL_ZERO_PROVIDER}
461+ -DUMF_BUILD_CUDA_PROVIDER=${UMF_BUILD_CUDA_PROVIDER}
462+ -DUMF_BUILD_LIBUMF_POOL_JEMALLOC=${UMF_BUILD_LIBUMF_POOL_JEMALLOC}
463+ -DUMF_BUILD_TESTS=OFF -DUMF_BUILD_GPU_TESTS=OFF
464+ -DUMF_BUILD_BENCHMARKS=OFF -DUMF_BUILD_BENCHMARKS_MT=OFF
465+ -DUMF_BUILD_EXAMPLES=OFF -DUMF_BUILD_GPU_EXAMPLES=OFF
466+ -DUMF_BUILD_FUZZTESTS=OFF -DUMF_DISABLE_HWLOC=${UMF_DISABLE_HWLOC}
467+ -DUMF_LINK_HWLOC_STATICALLY=${UMF_LINK_HWLOC_STATICALLY}
468+ -DUMF_HWLOC_NAME=${UMF_HWLOC_NAME}
469+ -DUMF_INSTALL_RPATH=${UMF_INSTALL_RPATH} -DUMF_DEVELOPER_MODE=OFF
470+ -DUMF_FORMAT_CODE_STYLE=OFF -DUMF_TESTS_FAIL_ON_SKIP=OFF
471+ -DUMF_USE_ASAN=OFF -DUMF_USE_UBSAN=OFF -DUMF_USE_TSAN=OFF
472+ -DUMF_USE_MSAN=OFF -DUMF_USE_VALGRIND=OFF -DUMF_USE_COVERAGE=OFF
473+ -DUMF_PROXY_LIB_BASED_ON_POOL=${UMF_PROXY_LIB_BASED_ON_POOL}
474+ COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} /umfd_build --target
475+ umf --config Debug
476+ COMMENT
477+ "Configuring and building umfd.dll in a separate directory with Debug configuration"
478+ )
479+
480+ # Copy built UMF libraries to the main binary directory and remove
481+ # umfd_build
482+ if (CMAKE_CONFIGURATION_TYPES )
483+ # Multi-config generator (e.g., Visual Studio)
484+ set (UMFD_DLL_SRC "${CMAKE_BINARY_DIR} /umfd_build/bin/Debug/umfd.dll" )
485+ set (UMFD_LIB_SRC "${CMAKE_BINARY_DIR} /umfd_build/lib/Debug/umfd.lib" )
486+ set (UMFD_DLL "${CMAKE_BINARY_DIR} /bin/$<CONFIG>/umfd.dll" )
487+ set (UMFD_LIB "${CMAKE_BINARY_DIR} /lib/$<CONFIG>/umfd.lib" )
488+ else ()
489+ # Single-config generator (e.g., Ninja)
490+ set (UMFD_DLL_SRC "${CMAKE_BINARY_DIR} /umfd_build/bin/umfd.dll" )
491+ set (UMFD_LIB_SRC "${CMAKE_BINARY_DIR} /umfd_build/lib/umfd.lib" )
492+ set (UMFD_DLL "${CMAKE_BINARY_DIR} /bin/umfd.dll" )
493+ set (UMFD_LIB "${CMAKE_BINARY_DIR} /lib/umfd.lib" )
494+ endif ()
495+
496+ if (UMF_BUILD_SHARED_LIBRARY)
497+ add_custom_command (
498+ TARGET build_umfd
499+ COMMAND ${CMAKE_COMMAND} -E copy_if_different ${UMFD_DLL_SRC}
500+ ${UMFD_DLL}
501+ COMMENT "Copying umfd.dll to the main binary directory" )
502+ endif ()
503+ add_custom_command (
504+ TARGET build_umfd
505+ COMMAND ${CMAKE_COMMAND} -E copy_if_different ${UMFD_LIB_SRC}
506+ ${UMFD_LIB}
507+ COMMAND ${CMAKE_COMMAND} -E remove_directory
508+ ${CMAKE_BINARY_DIR} /umfd_build DEPENDS ${UMFD_DLL}
509+ COMMENT "Copying umfd.lib to the main library directory" )
510+ endif ()
511+
437512# This build type check is not possible on Windows when CMAKE_BUILD_TYPE is not
438513# set, because in this case the build type is determined after a CMake
439514# configuration is done (at the build time)
@@ -826,6 +901,20 @@ endif()
826901# --------------------------------------------------------------------------- #
827902# Configure make install/uninstall and packages
828903# --------------------------------------------------------------------------- #
904+ # Install the umfd library files as part of the umfd component
905+ if (WINDOWS AND UMF_USE_DEBUG_POSTFIX )
906+ if (UMF_BUILD_SHARED_LIBRARY)
907+ install (
908+ FILES ${UMFD_DLL}
909+ DESTINATION ${CMAKE_INSTALL_BINDIR}
910+ COMPONENT umfd)
911+ endif ()
912+ install (
913+ FILES ${UMFD_LIB}
914+ DESTINATION ${CMAKE_INSTALL_LIBDIR}
915+ COMPONENT umfd)
916+ endif ()
917+
829918install (FILES ${PROJECT_SOURCE_DIR} /LICENSE.TXT
830919 DESTINATION "${CMAKE_INSTALL_DATAROOTDIR} /doc/${PROJECT_NAME} /" )
831920install (
0 commit comments