@@ -58,6 +58,8 @@ macro(umf_option)
58
58
option (${ARGV} )
59
59
endmacro ()
60
60
61
+ # All CMake options have to be explicitly set in the build_umfd target's
62
+ # configuration command
61
63
umf_option(UMF_BUILD_SHARED_LIBRARY "Build UMF as shared library" OFF )
62
64
umf_option(UMF_BUILD_LEVEL_ZERO_PROVIDER "Build Level Zero memory provider" ON )
63
65
umf_option(UMF_BUILD_CUDA_PROVIDER "Build CUDA memory provider" ON )
@@ -89,6 +91,8 @@ set(UMF_INSTALL_RPATH
89
91
"Set the runtime search path to the directory with dependencies (e.g. hwloc)"
90
92
)
91
93
94
+ umf_option(UMF_USE_DEBUG_POSTFIX "Add a 'd' postfix to Windows debug libraries"
95
+ OFF )
92
96
umf_option(UMF_DEVELOPER_MODE "Enable additional developer checks" OFF )
93
97
umf_option(
94
98
UMF_FORMAT_CODE_STYLE
@@ -146,6 +150,8 @@ if(UMF_DEVELOPER_MODE)
146
150
UMF_DEVELOPER_MODE=1)
147
151
endif ()
148
152
153
+ message (STATUS "CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} " )
154
+
149
155
if (NOT UMF_BUILD_LIBUMF_POOL_JEMALLOC)
150
156
set (UMF_POOL_JEMALLOC_ENABLED FALSE )
151
157
set (JEMALLOC_FOUND FALSE )
@@ -291,6 +297,7 @@ else()
291
297
set (HWLOC_ENABLE_TESTING OFF )
292
298
set (HWLOC_SKIP_LSTOPO ON )
293
299
set (HWLOC_SKIP_TOOLS ON )
300
+ set (HWLOC_SKIP_INCLUDES ON )
294
301
295
302
FetchContent_Declare(
296
303
hwloc_targ
@@ -434,6 +441,74 @@ elseif(UMF_BUILD_CUDA_PROVIDER)
434
441
message (STATUS "CUDA_INCLUDE_DIRS = ${CUDA_INCLUDE_DIRS} " )
435
442
endif ()
436
443
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
+
437
512
# This build type check is not possible on Windows when CMAKE_BUILD_TYPE is not
438
513
# set, because in this case the build type is determined after a CMake
439
514
# configuration is done (at the build time)
@@ -826,6 +901,20 @@ endif()
826
901
# --------------------------------------------------------------------------- #
827
902
# Configure make install/uninstall and packages
828
903
# --------------------------------------------------------------------------- #
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
+
829
918
install (FILES ${PROJECT_SOURCE_DIR} /LICENSE.TXT
830
919
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR} /doc/${PROJECT_NAME} /" )
831
920
install (
0 commit comments