@@ -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 )
@@ -285,13 +287,28 @@ else()
285287 set (HWLOC_ENABLE_TESTING OFF )
286288 set (HWLOC_SKIP_LSTOPO ON )
287289 set (HWLOC_SKIP_TOOLS ON )
290+ set (HWLOC_SKIP_INCLUDES ON )
288291
289292 FetchContent_Declare(
290293 hwloc_targ
291294 GIT_REPOSITORY ${UMF_HWLOC_REPO}
292295 GIT_TAG ${UMF_HWLOC_TAG}
293296 SOURCE_SUBDIR contrib/windows-cmake/)
297+
298+ if (CMAKE_GENERATOR MATCHES "Ninja" )
299+ # Disable installation of hwloc files
300+ set (CMAKE_SKIP_INSTALL_RULES_TMP
301+ "${CMAKE_SKIP_INSTALL_RULES} " )
302+ set (CMAKE_SKIP_INSTALL_RULES ON )
303+ endif ()
294304 FetchContent_MakeAvailable(hwloc_targ)
305+ if (CMAKE_GENERATOR MATCHES "Ninja" )
306+ # Restore CMake installation rules
307+ set (CMAKE_SKIP_INSTALL_RULES ${CMAKE_SKIP_INSTALL_RULES_TMP} )
308+ endif ()
309+
310+ set_target_properties (hwloc PROPERTIES EXCLUDE_FROM_ALL TRUE
311+ EXCLUDE_FROM_INSTALL TRUE )
295312
296313 set (HWLOC_LIB_PATH "" )
297314 if (CMAKE_GENERATOR STREQUAL "NMake Makefiles" )
@@ -429,24 +446,86 @@ elseif(UMF_BUILD_CUDA_PROVIDER)
429446endif ()
430447
431448if (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-
449+ # Build the umfd target in a separate directory with Debug configuration
450+ string (JOIN "\; " UMFD_CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} )
436451 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" )
452+ build_umfd ALL
453+ COMMAND
454+ ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR} " -S ${UMF_CMAKE_SOURCE_DIR}
455+ -B ${CMAKE_BINARY_DIR} /umfd_build -DCMAKE_BUILD_TYPE=Debug
456+ -DCMAKE_DEBUG_POSTFIX =d
457+ -DCMAKE_PREFIX_PATH="${UMFD_CMAKE_PREFIX_PATH} "
458+ -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
459+ -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
460+ -DUMF_USE_DEBUG_POSTFIX =OFF
461+ -DUMF_BUILD_SHARED_LIBRARY=${UMF_BUILD_SHARED_LIBRARY}
462+ -DUMF_BUILD_LEVEL_ZERO_PROVIDER=${UMF_BUILD_LEVEL_ZERO_PROVIDER}
463+ -DUMF_BUILD_CUDA_PROVIDER=${UMF_BUILD_CUDA_PROVIDER}
464+ -DUMF_BUILD_LIBUMF_POOL_JEMALLOC=${UMF_BUILD_LIBUMF_POOL_JEMALLOC}
465+ -DUMF_BUILD_TESTS=OFF -DUMF_BUILD_GPU_TESTS=OFF
466+ -DUMF_BUILD_BENCHMARKS=OFF -DUMF_BUILD_BENCHMARKS_MT=OFF
467+ -DUMF_BUILD_EXAMPLES=OFF -DUMF_BUILD_GPU_EXAMPLES=OFF
468+ -DUMF_BUILD_FUZZTESTS=OFF -DUMF_DISABLE_HWLOC=${UMF_DISABLE_HWLOC}
469+ -DUMF_LINK_HWLOC_STATICALLY=${UMF_LINK_HWLOC_STATICALLY}
470+ -DUMF_HWLOC_NAME=${UMF_HWLOC_NAME}
471+ -DUMF_INSTALL_RPATH=${UMF_INSTALL_RPATH} -DUMF_DEVELOPER_MODE=OFF
472+ -DUMF_FORMAT_CODE_STYLE=OFF -DUMF_TESTS_FAIL_ON_SKIP=OFF
473+ -DUMF_USE_ASAN=OFF -DUMF_USE_UBSAN=OFF -DUMF_USE_TSAN=OFF
474+ -DUMF_USE_MSAN=OFF -DUMF_USE_VALGRIND=OFF -DUMF_USE_COVERAGE=OFF
475+ -DUMF_PROXY_LIB_BASED_ON_POOL=${UMF_PROXY_LIB_BASED_ON_POOL}
476+ COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} /umfd_build --target
477+ umf --config Debug
478+ COMMENT
479+ "Configuring and building umfd.dll in a separate directory with Debug configuration"
480+ )
441481
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" )
482+ # Copy built UMF libraries to the main binary directory and remove
483+ # umfd_build
484+ if (CMAKE_CONFIGURATION_TYPES )
485+ # Multi-config generator (e.g., Visual Studio)
486+ if (UMF_BUILD_SHARED_LIBRARY)
487+ add_custom_command (
488+ TARGET build_umfd
489+ COMMAND
490+ ${CMAKE_COMMAND} -E copy_if_different
491+ ${CMAKE_BINARY_DIR} /umfd_build/bin/Debug/umfd.dll
492+ ${CMAKE_BINARY_DIR} /bin/$<CONFIG>/umfd.dll
493+ COMMENT "Copying umfd.dll to the main binary directory" )
494+ endif ()
495+ add_custom_command (
496+ TARGET build_umfd
497+ COMMAND
498+ ${CMAKE_COMMAND} -E copy_if_different
499+ ${CMAKE_BINARY_DIR} /umfd_build/lib/Debug/umfd.lib
500+ ${CMAKE_BINARY_DIR} /lib/$<CONFIG>/umfd.lib
501+ COMMAND
502+ ${CMAKE_COMMAND} -E remove_directory
503+ ${CMAKE_BINARY_DIR} /umfd_build DEPENDS
504+ ${CMAKE_BINARY_DIR} /bin/$<CONFIG>/umfd.dll
505+ COMMENT "Copying umfd.lib to the main library directory" )
506+ else ()
507+ # Single-config generator (e.g., Ninja)
508+ if (UMF_BUILD_SHARED_LIBRARY)
509+ add_custom_command (
510+ TARGET build_umfd
511+ COMMAND
512+ ${CMAKE_COMMAND} -E copy_if_different
513+ ${CMAKE_BINARY_DIR} /umfd_build/bin/umfd.dll
514+ ${CMAKE_BINARY_DIR} /bin/umfd.dll
515+ COMMENT "Copying umfd.dll file to the main binary directory" )
516+ endif ()
517+ add_custom_command (
518+ TARGET build_umfd
519+ COMMAND
520+ ${CMAKE_COMMAND} -E copy_if_different
521+ ${CMAKE_BINARY_DIR} /umfd_build/lib/umfd.lib
522+ ${CMAKE_BINARY_DIR} /lib/umfd.lib
523+ COMMAND
524+ ${CMAKE_COMMAND} -E remove_directory
525+ ${CMAKE_BINARY_DIR} /umfd_build DEPENDS
526+ ${CMAKE_BINARY_DIR} /bin/umfd.dll
527+ COMMENT "Copying umfd.lib file to the main library directory" )
528+ endif ()
450529endif ()
451530
452531# This build type check is not possible on Windows when CMAKE_BUILD_TYPE is not
@@ -841,12 +920,26 @@ endif()
841920# --------------------------------------------------------------------------- #
842921# Configure make install/uninstall and packages
843922# --------------------------------------------------------------------------- #
844- # Install umfd target
923+ # Install the umfd library files as part of the umfd component
845924if (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} )
925+ if (CMAKE_CONFIGURATION_TYPES )
926+ set (UMFD_DLL "${CMAKE_BINARY_DIR} /bin/$<CONFIG>/umfd.dll" )
927+ set (UMFD_LIB "${CMAKE_BINARY_DIR} /lib/$<CONFIG>/umfd.lib" )
928+ else ()
929+ set (UMFD_DLL "${CMAKE_BINARY_DIR} /bin/umfd.dll" )
930+ set (UMFD_LIB "${CMAKE_BINARY_DIR} /lib/umfd.lib" )
931+ endif ()
932+
933+ if (UMF_BUILD_SHARED_LIBRARY)
934+ install (
935+ FILES ${UMFD_DLL}
936+ DESTINATION ${CMAKE_INSTALL_BINDIR}
937+ COMPONENT umfd)
938+ endif ()
939+ install (
940+ FILES ${UMFD_LIB}
941+ DESTINATION ${CMAKE_INSTALL_LIBDIR}
942+ COMPONENT umfd)
850943endif ()
851944
852945install (FILES ${PROJECT_SOURCE_DIR} /LICENSE.TXT
0 commit comments