Skip to content

Commit e3d2929

Browse files
authored
Merge pull request #1219 from PatKamin/debug-dll
Install debug libraries on Windows
2 parents 0c49a4e + 1dd392c commit e3d2929

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

.github/workflows/reusable_basic.yml

+3
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ jobs:
241241
shared_library: 'ON'
242242
level_zero_provider: 'ON'
243243
cuda_provider: 'ON'
244+
umfd_lib: 'ON'
244245
- os: 'windows-2022'
245246
build_type: Release
246247
compiler: {c: cl, cxx: cl}
@@ -289,6 +290,7 @@ jobs:
289290
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=${{matrix.level_zero_provider}}
290291
-DUMF_BUILD_CUDA_PROVIDER=${{matrix.cuda_provider}}
291292
-DUMF_TESTS_FAIL_ON_SKIP=ON
293+
-DUMF_USE_DEBUG_POSTFIX=${{matrix.umfd_lib}}
292294
293295
- name: Build UMF
294296
run: cmake --build ${{env.BUILD_DIR}} --config ${{matrix.build_type}} -j $Env:NUMBER_OF_PROCESSORS
@@ -307,6 +309,7 @@ jobs:
307309
${{matrix.shared_library == 'ON' && '--proxy' || '' }}
308310
--umf-version ${{env.UMF_VERSION}}
309311
${{ matrix.shared_library == 'ON' && '--shared-library' || ''}}
312+
${{ matrix.umfd_lib == 'ON' && '--umfd-lib' || ''}}
310313
311314
- name: check /DEPENDENTLOADFLAG in umf.dll
312315
if: ${{matrix.shared_library == 'ON' && matrix.compiler.cxx == 'cl'}}

CMakeLists.txt

+31
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ set(UMF_INSTALL_RPATH
8989
"Set the runtime search path to the directory with dependencies (e.g. hwloc)"
9090
)
9191

92+
umf_option(UMF_USE_DEBUG_POSTFIX "Add a 'd' postfix to Windows debug libraries"
93+
OFF)
9294
umf_option(UMF_DEVELOPER_MODE "Enable additional developer checks" OFF)
9395
umf_option(
9496
UMF_FORMAT_CODE_STYLE
@@ -426,6 +428,27 @@ elseif(UMF_BUILD_CUDA_PROVIDER)
426428
message(STATUS "CUDA_INCLUDE_DIRS = ${CUDA_INCLUDE_DIRS}")
427429
endif()
428430

431+
if(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+
436+
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")
441+
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")
450+
endif()
451+
429452
# This build type check is not possible on Windows when CMAKE_BUILD_TYPE is not
430453
# set, because in this case the build type is determined after a CMake
431454
# configuration is done (at the build time)
@@ -818,6 +841,14 @@ endif()
818841
# --------------------------------------------------------------------------- #
819842
# Configure make install/uninstall and packages
820843
# --------------------------------------------------------------------------- #
844+
# Install umfd target
845+
if(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})
850+
endif()
851+
821852
install(FILES ${PROJECT_SOURCE_DIR}/LICENSE.TXT
822853
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/doc/${PROJECT_NAME}/")
823854
install(

test/test_installation.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def __init__(
4141
proxy: bool,
4242
pools: List[str],
4343
umf_version: Version,
44+
umfd_lib: bool,
4445
):
4546
self.workspace_dir = workspace_dir
4647
self.build_dir = build_dir
@@ -50,6 +51,7 @@ def __init__(
5051
self.proxy = proxy
5152
self.pools = pools
5253
self.umf_version = umf_version
54+
self.umfd_lib = umfd_lib
5355
self.match_list = self._create_match_list()
5456

5557
def _create_match_list(self) -> List[str]:
@@ -74,10 +76,14 @@ def _create_match_list(self) -> List[str]:
7476
lib_prefix = "lib"
7577

7678
bin = []
77-
if platform.system() == "Windows" and (self.shared_library or self.proxy):
79+
if platform.system() == "Windows" and (
80+
self.shared_library or self.proxy or self.umfd_lib
81+
):
7882
bin.append("bin")
7983
if self.shared_library:
8084
bin.append("bin/umf.dll")
85+
if self.umfd_lib:
86+
bin.append("bin/umfd.dll")
8187
if self.proxy:
8288
bin.append("bin/umf_proxy.dll")
8389

@@ -101,6 +107,8 @@ def _create_match_list(self) -> List[str]:
101107
lib.append(f"lib/{lib_prefix}{pool}.{lib_ext_static}")
102108
if self.shared_library:
103109
lib.append(f"lib/{lib_prefix}umf.{lib_ext_shared}")
110+
if platform.system() == "Windows" and self.umfd_lib:
111+
lib.append(f"lib/{lib_prefix}umfd.{lib_ext_shared}")
104112

105113
if platform.system() == "Linux":
106114
lib.append(
@@ -283,6 +291,11 @@ def parse_arguments(self) -> argparse.Namespace:
283291
action="store",
284292
help="Current version of the UMF, e.g. 1.0.0",
285293
)
294+
self.parser.add_argument(
295+
"--umfd-lib",
296+
action="store_true",
297+
help="Add this argument if the UMF was built with the umfd library",
298+
)
286299
return self.parser.parse_args()
287300

288301
def run(self) -> None:
@@ -306,6 +319,7 @@ def run(self) -> None:
306319
self.args.proxy,
307320
pools,
308321
umf_version,
322+
self.args.umfd_lib,
309323
)
310324

311325
print("Installation test - BEGIN", flush=True)

0 commit comments

Comments
 (0)