@@ -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 )
@@ -304,13 +306,18 @@ else()
304306 DIRECTORY )
305307 set (LIBHWLOC_LIBRARIES ${HWLOC_LIB_PATH} )
306308 set (LIBHWLOC_INCLUDE_DIRS ${hwloc_targ_BINARY_DIR} /include )
309+
310+ set_property (TARGET hwloc PROPERTY EXCLUDE_FROM_INSTALL TRUE )
307311 else () # not Windows
308312 FetchContent_Declare(
309313 hwloc_targ
310314 GIT_REPOSITORY ${UMF_HWLOC_REPO}
311315 GIT_TAG ${UMF_HWLOC_TAG} )
312316 FetchContent_MakeAvailable(hwloc_targ)
313317
318+ # Prevent hwloc from being installed
319+ set_property (TARGET hwloc_targ PROPERTY EXCLUDE_FROM_INSTALL TRUE )
320+
314321 add_custom_command (
315322 COMMAND ./autogen.sh
316323 WORKING_DIRECTORY ${hwloc_targ_SOURCE_DIR}
@@ -342,6 +349,7 @@ else()
342349 target_link_libraries (
343350 hwloc INTERFACE ${hwloc_targ_BINARY_DIR} /lib/libhwloc.a)
344351 add_dependencies (hwloc hwloc_prod)
352+ set_property (TARGET hwloc PROPERTY EXCLUDE_FROM_INSTALL TRUE )
345353
346354 set (LIBHWLOC_LIBRARY_DIRS ${hwloc_targ_BINARY_DIR} /lib)
347355 set (LIBHWLOC_INCLUDE_DIRS ${hwloc_targ_BINARY_DIR} /include )
@@ -429,24 +437,86 @@ elseif(UMF_BUILD_CUDA_PROVIDER)
429437endif ()
430438
431439if (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-
440+ # Build the umfd target in a separate directory with Debug configuration
441+ string (JOIN "\; " UMFD_CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} )
436442 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" )
443+ build_umfd ALL
444+ COMMAND
445+ ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR} " -S ${UMF_CMAKE_SOURCE_DIR}
446+ -B ${CMAKE_BINARY_DIR} /umfd_build -DCMAKE_BUILD_TYPE=Debug
447+ -DCMAKE_DEBUG_POSTFIX =d
448+ -DCMAKE_PREFIX_PATH="${UMFD_CMAKE_PREFIX_PATH} "
449+ -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
450+ -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
451+ -DUMF_USE_DEBUG_POSTFIX =OFF
452+ -DUMF_BUILD_SHARED_LIBRARY=${UMF_BUILD_SHARED_LIBRARY}
453+ -DUMF_BUILD_LEVEL_ZERO_PROVIDER=${UMF_BUILD_LEVEL_ZERO_PROVIDER}
454+ -DUMF_BUILD_CUDA_PROVIDER=${UMF_BUILD_CUDA_PROVIDER}
455+ -DUMF_BUILD_LIBUMF_POOL_JEMALLOC=${UMF_BUILD_LIBUMF_POOL_JEMALLOC}
456+ -DUMF_BUILD_TESTS=OFF -DUMF_BUILD_GPU_TESTS=OFF
457+ -DUMF_BUILD_BENCHMARKS=OFF -DUMF_BUILD_BENCHMARKS_MT=OFF
458+ -DUMF_BUILD_EXAMPLES=OFF -DUMF_BUILD_GPU_EXAMPLES=OFF
459+ -DUMF_BUILD_FUZZTESTS=OFF -DUMF_DISABLE_HWLOC=${UMF_DISABLE_HWLOC}
460+ -DUMF_LINK_HWLOC_STATICALLY=${UMF_LINK_HWLOC_STATICALLY}
461+ -DUMF_HWLOC_NAME=${UMF_HWLOC_NAME}
462+ -DUMF_INSTALL_RPATH=${UMF_INSTALL_RPATH} -DUMF_DEVELOPER_MODE=OFF
463+ -DUMF_FORMAT_CODE_STYLE=OFF -DUMF_TESTS_FAIL_ON_SKIP=OFF
464+ -DUMF_USE_ASAN=OFF -DUMF_USE_UBSAN=OFF -DUMF_USE_TSAN=OFF
465+ -DUMF_USE_MSAN=OFF -DUMF_USE_VALGRIND=OFF -DUMF_USE_COVERAGE=OFF
466+ -DUMF_PROXY_LIB_BASED_ON_POOL=${UMF_PROXY_LIB_BASED_ON_POOL}
467+ COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} /umfd_build --target
468+ umf --config Debug
469+ COMMENT
470+ "Configuring and building umfd.dll in a separate directory with Debug configuration"
471+ )
441472
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" )
473+ # Copy built UMF libraries to the main binary directory and remove
474+ # umfd_build
475+ if (CMAKE_CONFIGURATION_TYPES )
476+ # Multi-config generator (e.g., Visual Studio)
477+ if (UMF_BUILD_SHARED_LIBRARY)
478+ add_custom_command (
479+ TARGET build_umfd
480+ COMMAND
481+ ${CMAKE_COMMAND} -E copy_if_different
482+ ${CMAKE_BINARY_DIR} /umfd_build/bin/Debug/umfd.dll
483+ ${CMAKE_BINARY_DIR} /bin/$<CONFIG>/umfd.dll
484+ COMMENT "Copying umfd.dll to the main binary directory" )
485+ endif ()
486+ add_custom_command (
487+ TARGET build_umfd
488+ COMMAND
489+ ${CMAKE_COMMAND} -E copy_if_different
490+ ${CMAKE_BINARY_DIR} /umfd_build/lib/Debug/umfd.lib
491+ ${CMAKE_BINARY_DIR} /lib/$<CONFIG>/umfd.lib
492+ COMMAND
493+ ${CMAKE_COMMAND} -E remove_directory
494+ ${CMAKE_BINARY_DIR} /umfd_build DEPENDS
495+ ${CMAKE_BINARY_DIR} /bin/$<CONFIG>/umfd.dll
496+ COMMENT "Copying umfd.lib to the main library directory" )
497+ else ()
498+ # Single-config generator (e.g., Ninja)
499+ if (UMF_BUILD_SHARED_LIBRARY)
500+ add_custom_command (
501+ TARGET build_umfd
502+ COMMAND
503+ ${CMAKE_COMMAND} -E copy_if_different
504+ ${CMAKE_BINARY_DIR} /umfd_build/bin/umfd.dll
505+ ${CMAKE_BINARY_DIR} /bin/umfd.dll
506+ COMMENT "Copying umfd.dll file to the main binary directory" )
507+ endif ()
508+ add_custom_command (
509+ TARGET build_umfd
510+ COMMAND
511+ ${CMAKE_COMMAND} -E copy_if_different
512+ ${CMAKE_BINARY_DIR} /umfd_build/lib/umfd.lib
513+ ${CMAKE_BINARY_DIR} /lib/umfd.lib
514+ COMMAND
515+ ${CMAKE_COMMAND} -E remove_directory
516+ ${CMAKE_BINARY_DIR} /umfd_build DEPENDS
517+ ${CMAKE_BINARY_DIR} /bin/umfd.dll
518+ COMMENT "Copying umfd.lib file to the main library directory" )
519+ endif ()
450520endif ()
451521
452522# This build type check is not possible on Windows when CMAKE_BUILD_TYPE is not
@@ -841,12 +911,26 @@ endif()
841911# --------------------------------------------------------------------------- #
842912# Configure make install/uninstall and packages
843913# --------------------------------------------------------------------------- #
844- # Install umfd target
914+ # Install the umfd library files as part of the umfd component
845915if (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} )
916+ if (CMAKE_CONFIGURATION_TYPES )
917+ set (UMFD_DLL "${CMAKE_BINARY_DIR} /bin/$<CONFIG>/umfd.dll" )
918+ set (UMFD_LIB "${CMAKE_BINARY_DIR} /lib/$<CONFIG>/umfd.lib" )
919+ else ()
920+ set (UMFD_DLL "${CMAKE_BINARY_DIR} /bin/umfd.dll" )
921+ set (UMFD_LIB "${CMAKE_BINARY_DIR} /lib/umfd.lib" )
922+ endif ()
923+
924+ if (UMF_BUILD_SHARED_LIBRARY)
925+ install (
926+ FILES ${UMFD_DLL}
927+ DESTINATION ${CMAKE_INSTALL_BINDIR}
928+ COMPONENT umfd)
929+ endif ()
930+ install (
931+ FILES ${UMFD_LIB}
932+ DESTINATION ${CMAKE_INSTALL_LIBDIR}
933+ COMPONENT umfd)
850934endif ()
851935
852936install (FILES ${PROJECT_SOURCE_DIR} /LICENSE.TXT
0 commit comments