@@ -89,7 +89,8 @@ set(UMF_INSTALL_RPATH
89
89
"Set the runtime search path to the directory with dependencies (e.g. hwloc)"
90
90
)
91
91
92
- umf_option(UMF_USE_DEBUG_POSTFIX "Add a 'd' postfix to Windows debug libraries" OFF )
92
+ umf_option(UMF_USE_DEBUG_POSTFIX "Add a 'd' postfix to Windows debug libraries"
93
+ OFF )
93
94
umf_option(UMF_DEVELOPER_MODE "Enable additional developer checks" OFF )
94
95
umf_option(
95
96
UMF_FORMAT_CODE_STYLE
@@ -112,6 +113,7 @@ set(UMF_PROXY_LIB_BASED_ON_POOL
112
113
set_property (CACHE UMF_PROXY_LIB_BASED_ON_POOL
113
114
PROPERTY STRINGS ${KNOWN_PROXY_LIB_POOLS} )
114
115
list (APPEND UMF_OPTIONS_LIST UMF_PROXY_LIB_BASED_ON_POOL)
116
+ set (UMF_DEBUG_POSTFIX OFF CACHE BOOL "Add a 'd' postfix to Windows debug libraries" )
115
117
116
118
# --------------------------------------------------------------------------- #
117
119
# Setup required variables, definitions; fetch dependencies; include
@@ -427,6 +429,60 @@ elseif(UMF_BUILD_CUDA_PROVIDER)
427
429
message (STATUS "CUDA_INCLUDE_DIRS = ${CUDA_INCLUDE_DIRS} " )
428
430
endif ()
429
431
432
+ if (WINDOWS AND UMF_USE_DEBUG_POSTFIX )
433
+ # Build debug libraries with the d suffix that are compiled with /MDd so
434
+ # users can link against these in debug builds.
435
+ include (ExternalProject)
436
+ set (UMFD_BINARY_DIR ${CMAKE_BINARY_DIR} /umfd)
437
+ set (UMFD_INSTALL_DIR ${UMFD_BINARY_DIR} /install )
438
+ set (UMF_DEBUG_POSTFIX ON )
439
+
440
+ ExternalProject_Add(
441
+ umfd
442
+ SOURCE_DIR ${PROJECT_SOURCE_DIR}
443
+ BINARY_DIR ${UMFD_BINARY_DIR}
444
+ INSTALL_DIR ${UMFD_INSTALL_DIR}
445
+ INSTALL_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --target
446
+ install -umf-libraries --config Debug
447
+ CMAKE_CACHE_ARGS
448
+ -DCMAKE_INSTALL_PREFIX:STRING =<INSTALL_DIR>
449
+ -DCMAKE_PREFIX_PATH:STRING =${CMAKE_PREFIX_PATH}
450
+ # Enable d suffix on libraries
451
+ -DUMF_USE_DEBUG_POSTFIX :BOOL =OFF
452
+ # Don't build unnecessary targets in subbuild.
453
+ -DUMF_BUILD_EXAMPLES:BOOL =OFF
454
+ -DUMF_BUILD_TESTS:BOOL =OFF
455
+ # Inherit settings from parent build.
456
+ -DUMF_BUILD_SHARED_LIBRARY:BOOL =${UMF_BUILD_SHARED_LIBRARY}
457
+ -DUMF_BUILD_LEVEL_ZERO_PROVIDER:BOOL =${UMF_BUILD_LEVEL_ZERO_PROVIDER}
458
+ -DUMF_BUILD_CUDA_PROVIDER:BOOL =${UMF_BUILD_CUDA_PROVIDER}
459
+ -DUMF_BUILD_LIBUMF_POOL_JEMALLOC:BOOL =${UMF_BUILD_LIBUMF_POOL_JEMALLOC}
460
+ -DUMF_DISABLE_HWLOC:BOOL =${UMF_DISABLE_HWLOC}
461
+ -DUMF_LINK_HWLOC_STATICALLY:BOOL =${UMF_LINK_HWLOC_STATICALLY}
462
+ -DUMF_HWLOC_NAME:STRING =${UMF_HWLOC_NAME}
463
+ -DUMF_INSTALL_RPATH:STRING =${UMF_INSTALL_RPATH} )
464
+
465
+ # Copy debug runtime libraries to the parent build directory
466
+ set (UMFD_FILES_TO_COPY)
467
+ list (APPEND UMFD_COPY_FILES ${PROJECT_BINARY_DIR} /bin/umfd.dll
468
+ ${PROJECT_BINARY_DIR} /lib/umfd.lib)
469
+ add_custom_command (
470
+ OUTPUT ${PROJECT_BINARY_DIR} /bin/umfd.dll
471
+ ${PROJECT_BINARY_DIR} /lib/umfd.lib
472
+ COMMAND ${CMAKE_COMMAND} -E copy ${UMFD_INSTALL_DIR} /bin/umfd.dll
473
+ ${PROJECT_BINARY_DIR} /bin/umfd.dll
474
+ COMMAND ${CMAKE_COMMAND} -E copy ${UMFD_INSTALL_DIR} /lib/umfd.lib
475
+ ${PROJECT_BINARY_DIR} /lib/umfd.lib)
476
+
477
+ add_custom_target (copy-umfd-files DEPENDS ${UMFD_COPY_FILES} )
478
+ add_dependencies (copy-umfd-files umfd)
479
+ endif ()
480
+
481
+ # Target with all UMF libraries added with add_umf_library()
482
+ if (NOT TARGET umf-libraries)
483
+ add_custom_target (umf-libraries)
484
+ endif ()
485
+
430
486
# This build type check is not possible on Windows when CMAKE_BUILD_TYPE is not
431
487
# set, because in this case the build type is determined after a CMake
432
488
# configuration is done (at the build time)
@@ -859,6 +915,14 @@ install(FILES ${PROJECT_BINARY_DIR}/cmake/${PROJECT_NAME}-config.cmake
859
915
${PROJECT_BINARY_DIR} /cmake/${PROJECT_NAME} -config-version .cmake
860
916
DESTINATION ${CMAKE_INSTALL_LIBDIR} /cmake/${PROJECT_NAME} )
861
917
918
+ # Install Windows debug libraries
919
+ if (NOT TARGET install -umf-libraries)
920
+ add_custom_target (
921
+ install -umf-libraries
922
+ COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target install
923
+ DEPENDS umf-libraries)
924
+ endif ()
925
+
862
926
# Configure uninstall commands
863
927
configure_file ("${PROJECT_SOURCE_DIR} /cmake/cmake_uninstall.cmake.in"
864
928
"${PROJECT_BINARY_DIR} /cmake_uninstall.cmake" IMMEDIATE @ONLY)
0 commit comments