@@ -148,6 +148,8 @@ if(UMF_DEVELOPER_MODE)
148148 UMF_DEVELOPER_MODE=1)
149149endif ()
150150
151+ message (STATUS "CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} " )
152+
151153if (NOT UMF_BUILD_LIBUMF_POOL_JEMALLOC)
152154 set (UMF_POOL_JEMALLOC_ENABLED FALSE )
153155 set (JEMALLOC_FOUND FALSE )
@@ -429,24 +431,85 @@ elseif(UMF_BUILD_CUDA_PROVIDER)
429431endif ()
430432
431433if (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-
434+ # Build the umfd target in a separate directory with Debug configuration
435+ string (JOIN "\; " CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} )
436436 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" )
437+ build_umfd ALL
438+ COMMAND
439+ ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR} " -S ${UMF_CMAKE_SOURCE_DIR}
440+ -B ${CMAKE_BINARY_DIR} /umfd_build -DCMAKE_BUILD_TYPE=Debug
441+ -DCMAKE_DEBUG_POSTFIX =d -DCMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH} "
442+ -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
443+ -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
444+ -DUMF_USE_DEBUG_POSTFIX =OFF
445+ -DUMF_BUILD_SHARED_LIBRARY=${UMF_BUILD_SHARED_LIBRARY}
446+ -DUMF_BUILD_LEVEL_ZERO_PROVIDER=${UMF_BUILD_LEVEL_ZERO_PROVIDER}
447+ -DUMF_BUILD_CUDA_PROVIDER=${UMF_BUILD_CUDA_PROVIDER}
448+ -DUMF_BUILD_LIBUMF_POOL_JEMALLOC=${UMF_BUILD_LIBUMF_POOL_JEMALLOC}
449+ -DUMF_BUILD_TESTS=OFF -DUMF_BUILD_GPU_TESTS=OFF
450+ -DUMF_BUILD_BENCHMARKS=OFF -DUMF_BUILD_BENCHMARKS_MT=OFF
451+ -DUMF_BUILD_EXAMPLES=OFF -DUMF_BUILD_GPU_EXAMPLES=OFF
452+ -DUMF_BUILD_FUZZTESTS=OFF -DUMF_DISABLE_HWLOC=${UMF_DISABLE_HWLOC}
453+ -DUMF_LINK_HWLOC_STATICALLY=${UMF_LINK_HWLOC_STATICALLY}
454+ -DUMF_HWLOC_NAME=${UMF_HWLOC_NAME}
455+ -DUMF_INSTALL_RPATH=${UMF_INSTALL_RPATH} -DUMF_DEVELOPER_MODE=OFF
456+ -DUMF_FORMAT_CODE_STYLE=OFF -DUMF_TESTS_FAIL_ON_SKIP=OFF
457+ -DUMF_USE_ASAN=OFF -DUMF_USE_UBSAN=OFF -DUMF_USE_TSAN=OFF
458+ -DUMF_USE_MSAN=OFF -DUMF_USE_VALGRIND=OFF -DUMF_USE_COVERAGE=OFF
459+ -DUMF_PROXY_LIB_BASED_ON_POOL=${UMF_PROXY_LIB_BASED_ON_POOL}
460+ COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} /umfd_build --target
461+ umf --config Debug
462+ COMMENT
463+ "Configuring and building umfd.dll in a separate directory with Debug configuration"
464+ )
441465
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" )
466+ # Copy built UMF libraries to the main binary directory and remove
467+ # umfd_build
468+ if (CMAKE_CONFIGURATION_TYPES )
469+ # Multi-config generator (e.g., Visual Studio)
470+ if (UMF_BUILD_SHARED_LIBRARY)
471+ add_custom_command (
472+ TARGET build_umfd
473+ COMMAND
474+ ${CMAKE_COMMAND} -E copy_if_different
475+ ${CMAKE_BINARY_DIR} /umfd_build/bin/Debug/umfd.dll
476+ ${CMAKE_BINARY_DIR} /bin/$<CONFIG>/umfd.dll
477+ COMMENT "Copying umfd.dll to the main binary directory" )
478+ endif ()
479+ add_custom_command (
480+ TARGET build_umfd
481+ COMMAND
482+ ${CMAKE_COMMAND} -E copy_if_different
483+ ${CMAKE_BINARY_DIR} /umfd_build/lib/Debug/umfd.lib
484+ ${CMAKE_BINARY_DIR} /lib/$<CONFIG>/umfd.lib
485+ COMMAND
486+ ${CMAKE_COMMAND} -E remove_directory
487+ ${CMAKE_BINARY_DIR} /umfd_build DEPENDS
488+ ${CMAKE_BINARY_DIR} /bin/$<CONFIG>/umfd.dll
489+ COMMENT "Copying umfd.lib to the main library directory" )
490+ else ()
491+ # Single-config generator (e.g., Ninja)
492+ if (UMF_BUILD_SHARED_LIBRARY)
493+ add_custom_command (
494+ TARGET build_umfd
495+ COMMAND
496+ ${CMAKE_COMMAND} -E copy_if_different
497+ ${CMAKE_BINARY_DIR} /umfd_build/bin/umfd.dll
498+ ${CMAKE_BINARY_DIR} /bin/umfd.dll
499+ COMMENT "Copying umfd.dll file to the main binary directory" )
500+ endif ()
501+ add_custom_command (
502+ TARGET build_umfd
503+ COMMAND
504+ ${CMAKE_COMMAND} -E copy_if_different
505+ ${CMAKE_BINARY_DIR} /umfd_build/lib/umfd.lib
506+ ${CMAKE_BINARY_DIR} /lib/umfd.lib
507+ COMMAND
508+ ${CMAKE_COMMAND} -E remove_directory
509+ ${CMAKE_BINARY_DIR} /umfd_build DEPENDS
510+ ${CMAKE_BINARY_DIR} /bin/umfd.dll
511+ COMMENT "Copying umfd.lib file to the main library directory" )
512+ endif ()
450513endif ()
451514
452515# This build type check is not possible on Windows when CMAKE_BUILD_TYPE is not
@@ -841,12 +904,24 @@ endif()
841904# --------------------------------------------------------------------------- #
842905# Configure make install/uninstall and packages
843906# --------------------------------------------------------------------------- #
844- # Install umfd target
907+ # Install the umfd library files as part of the umfd component
845908if (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} )
909+ if (CMAKE_CONFIGURATION_TYPES )
910+ set (UMFD_DLL "${CMAKE_BINARY_DIR} /bin/$<CONFIG>/umfd.dll" )
911+ set (UMFD_LIB "${CMAKE_BINARY_DIR} /lib/$<CONFIG>/umfd.lib" )
912+ else ()
913+ set (UMFD_DLL "${CMAKE_BINARY_DIR} /bin/umfd.dll" )
914+ set (UMFD_LIB "${CMAKE_BINARY_DIR} /lib/umfd.lib" )
915+ endif ()
916+
917+ install (
918+ FILES ${UMFD_DLL}
919+ DESTINATION ${CMAKE_INSTALL_BINDIR}
920+ COMPONENT umfd)
921+ install (
922+ FILES ${UMFD_LIB}
923+ DESTINATION ${CMAKE_INSTALL_LIBDIR}
924+ COMPONENT umfd)
850925endif ()
851926
852927install (FILES ${PROJECT_SOURCE_DIR} /LICENSE.TXT
0 commit comments