Skip to content

Commit f460def

Browse files
committed
Fix building umfd.dll on single-config generators
- add installation tests step to Windows generators nightly tests
1 parent 99d5347 commit f460def

File tree

3 files changed

+143
-27
lines changed

3 files changed

+143
-27
lines changed

.github/workflows/nightly.yml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ permissions:
1212

1313
env:
1414
BUILD_DIR : "${{github.workspace}}/build"
15+
INSTALL_DIR: "${{github.workspace}}/build/install"
1516

1617
jobs:
1718
fuzz-test:
@@ -96,11 +97,12 @@ jobs:
9697
strategy:
9798
matrix:
9899
os: ['windows-2019', 'windows-2022']
99-
build_type: [Release]
100+
build_type: [Debug, Release]
100101
compiler: [{c: cl, cxx: cl}]
101102
shared_library: ['ON', 'OFF']
102103
static_hwloc: ['ON', 'OFF']
103104
generator: ['Ninja', 'NMake Makefiles']
105+
umfd_lib: ['ON', 'OFF']
104106

105107
runs-on: ${{matrix.os}}
106108

@@ -112,11 +114,11 @@ jobs:
112114

113115
- name: Set VCPKG_PATH with hwloc
114116
if: matrix.static_hwloc == 'OFF'
115-
run: echo "VCPKG_PATH='${{github.workspace}}/build/vcpkg/packages/hwloc_x64-windows;${{github.workspace}}/build/vcpkg/packages/tbb_x64-windows;${{github.workspace}}/build/vcpkg/packages/jemalloc_x64-windows'" >> $env:GITHUB_ENV
117+
run: echo "VCPKG_PATH=${{github.workspace}}/build/vcpkg/packages/hwloc_x64-windows;${{github.workspace}}/build/vcpkg/packages/tbb_x64-windows;${{github.workspace}}/build/vcpkg/packages/jemalloc_x64-windows" >> $env:GITHUB_ENV
116118

117119
- name: Set VCPKG_PATH without hwloc
118120
if: matrix.static_hwloc == 'ON'
119-
run: echo "VCPKG_PATH='${{github.workspace}}/build/vcpkg/packages/tbb_x64-windows;${{github.workspace}}/build/vcpkg/packages/jemalloc_x64-windows'" >> $env:GITHUB_ENV
121+
run: echo "VCPKG_PATH=${{github.workspace}}/build/vcpkg/packages/tbb_x64-windows;${{github.workspace}}/build/vcpkg/packages/jemalloc_x64-windows" >> $env:GITHUB_ENV
120122

121123
- name: Initialize vcpkg
122124
uses: lukka/run-vcpkg@5e0cab206a5ea620130caf672fce3e4a6b5666a1 # v11.5
@@ -153,6 +155,7 @@ jobs:
153155
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
154156
-DUMF_BUILD_CUDA_PROVIDER=ON
155157
-DUMF_TESTS_FAIL_ON_SKIP=ON
158+
${{ matrix.umfd_lib == 'ON' && '-DUMF_USE_DEBUG_POSTFIX=ON' || '' }}
156159
157160
- name: Build UMF
158161
shell: cmd
@@ -163,6 +166,25 @@ jobs:
163166
working-directory: ${{env.BUILD_DIR}}
164167
run: ctest -C ${{matrix.build_type}} --output-on-failure --test-dir test
165168

169+
- name: Get UMF version
170+
run: |
171+
$version = (git describe --tags --abbrev=0 | Select-String -Pattern '\d+\.\d+\.\d+').Matches.Value
172+
echo "UMF_VERSION=$version" >> $env:GITHUB_ENV
173+
shell: pwsh
174+
175+
- name: Test UMF installation and uninstallation
176+
# The '--shared-library' parameter is added to the installation test when the UMF is built as a shared library
177+
# The '--umfd-lib' parameter is added when the UMF is built with the umfd library
178+
run: >
179+
python3 ${{github.workspace}}/test/test_installation.py
180+
--build-dir ${{env.BUILD_DIR}}
181+
--install-dir ${{env.INSTALL_DIR}}
182+
--build-type ${{matrix.build_type}}
183+
--umf-version ${{env.UMF_VERSION}}
184+
--cmake-generator "${{matrix.generator}}"
185+
${{ matrix.shared_library == 'ON' && '--proxy --shared-library' || '' }}
186+
${{ matrix.umfd_lib == 'ON' && '--umfd-lib' || ''}}
187+
166188
icx:
167189
name: ICX
168190
env:

CMakeLists.txt

Lines changed: 99 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ if(UMF_DEVELOPER_MODE)
148148
UMF_DEVELOPER_MODE=1)
149149
endif()
150150

151+
message(STATUS "CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}")
152+
151153
if(NOT UMF_BUILD_LIBUMF_POOL_JEMALLOC)
152154
set(UMF_POOL_JEMALLOC_ENABLED FALSE)
153155
set(JEMALLOC_FOUND FALSE)
@@ -429,24 +431,86 @@ elseif(UMF_BUILD_CUDA_PROVIDER)
429431
endif()
430432

431433
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-
434+
# Build the umfd target in a separate directory with Debug configuration
435+
string(JOIN "\;" UMFD_CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH})
436436
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")
437+
build_umfd ALL
438+
COMMAND
439+
${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" -S ${UMF_CMAKE_SOURCE_DIR}
440+
-B ${CMAKE_BINARY_DIR}/umfd_build -DCMAKE_BUILD_TYPE=Debug
441+
-DCMAKE_DEBUG_POSTFIX=d
442+
-DCMAKE_PREFIX_PATH="${UMFD_CMAKE_PREFIX_PATH}"
443+
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
444+
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
445+
-DUMF_USE_DEBUG_POSTFIX=OFF
446+
-DUMF_BUILD_SHARED_LIBRARY=${UMF_BUILD_SHARED_LIBRARY}
447+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=${UMF_BUILD_LEVEL_ZERO_PROVIDER}
448+
-DUMF_BUILD_CUDA_PROVIDER=${UMF_BUILD_CUDA_PROVIDER}
449+
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=${UMF_BUILD_LIBUMF_POOL_JEMALLOC}
450+
-DUMF_BUILD_TESTS=OFF -DUMF_BUILD_GPU_TESTS=OFF
451+
-DUMF_BUILD_BENCHMARKS=OFF -DUMF_BUILD_BENCHMARKS_MT=OFF
452+
-DUMF_BUILD_EXAMPLES=OFF -DUMF_BUILD_GPU_EXAMPLES=OFF
453+
-DUMF_BUILD_FUZZTESTS=OFF -DUMF_DISABLE_HWLOC=${UMF_DISABLE_HWLOC}
454+
-DUMF_LINK_HWLOC_STATICALLY=${UMF_LINK_HWLOC_STATICALLY}
455+
-DUMF_HWLOC_NAME=${UMF_HWLOC_NAME}
456+
-DUMF_INSTALL_RPATH=${UMF_INSTALL_RPATH} -DUMF_DEVELOPER_MODE=OFF
457+
-DUMF_FORMAT_CODE_STYLE=OFF -DUMF_TESTS_FAIL_ON_SKIP=OFF
458+
-DUMF_USE_ASAN=OFF -DUMF_USE_UBSAN=OFF -DUMF_USE_TSAN=OFF
459+
-DUMF_USE_MSAN=OFF -DUMF_USE_VALGRIND=OFF -DUMF_USE_COVERAGE=OFF
460+
-DUMF_PROXY_LIB_BASED_ON_POOL=${UMF_PROXY_LIB_BASED_ON_POOL}
461+
COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR}/umfd_build --target
462+
umf --config Debug
463+
COMMENT
464+
"Configuring and building umfd.dll in a separate directory with Debug configuration"
465+
)
441466

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")
467+
# Copy built UMF libraries to the main binary directory and remove
468+
# umfd_build
469+
if(CMAKE_CONFIGURATION_TYPES)
470+
# Multi-config generator (e.g., Visual Studio)
471+
if(UMF_BUILD_SHARED_LIBRARY)
472+
add_custom_command(
473+
TARGET build_umfd
474+
COMMAND
475+
${CMAKE_COMMAND} -E copy_if_different
476+
${CMAKE_BINARY_DIR}/umfd_build/bin/Debug/umfd.dll
477+
${CMAKE_BINARY_DIR}/bin/$<CONFIG>/umfd.dll
478+
COMMENT "Copying umfd.dll to the main binary directory")
479+
endif()
480+
add_custom_command(
481+
TARGET build_umfd
482+
COMMAND
483+
${CMAKE_COMMAND} -E copy_if_different
484+
${CMAKE_BINARY_DIR}/umfd_build/lib/Debug/umfd.lib
485+
${CMAKE_BINARY_DIR}/lib/$<CONFIG>/umfd.lib
486+
COMMAND
487+
${CMAKE_COMMAND} -E remove_directory
488+
${CMAKE_BINARY_DIR}/umfd_build DEPENDS
489+
${CMAKE_BINARY_DIR}/bin/$<CONFIG>/umfd.dll
490+
COMMENT "Copying umfd.lib to the main library directory")
491+
else()
492+
# Single-config generator (e.g., Ninja)
493+
if(UMF_BUILD_SHARED_LIBRARY)
494+
add_custom_command(
495+
TARGET build_umfd
496+
COMMAND
497+
${CMAKE_COMMAND} -E copy_if_different
498+
${CMAKE_BINARY_DIR}/umfd_build/bin/umfd.dll
499+
${CMAKE_BINARY_DIR}/bin/umfd.dll
500+
COMMENT "Copying umfd.dll file to the main binary directory")
501+
endif()
502+
add_custom_command(
503+
TARGET build_umfd
504+
COMMAND
505+
${CMAKE_COMMAND} -E copy_if_different
506+
${CMAKE_BINARY_DIR}/umfd_build/lib/umfd.lib
507+
${CMAKE_BINARY_DIR}/lib/umfd.lib
508+
COMMAND
509+
${CMAKE_COMMAND} -E remove_directory
510+
${CMAKE_BINARY_DIR}/umfd_build DEPENDS
511+
${CMAKE_BINARY_DIR}/bin/umfd.dll
512+
COMMENT "Copying umfd.lib file to the main library directory")
513+
endif()
450514
endif()
451515

452516
# This build type check is not possible on Windows when CMAKE_BUILD_TYPE is not
@@ -841,12 +905,26 @@ endif()
841905
# --------------------------------------------------------------------------- #
842906
# Configure make install/uninstall and packages
843907
# --------------------------------------------------------------------------- #
844-
# Install umfd target
908+
# Install the umfd library files as part of the umfd component
845909
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})
910+
if(CMAKE_CONFIGURATION_TYPES)
911+
set(UMFD_DLL "${CMAKE_BINARY_DIR}/bin/$<CONFIG>/umfd.dll")
912+
set(UMFD_LIB "${CMAKE_BINARY_DIR}/lib/$<CONFIG>/umfd.lib")
913+
else()
914+
set(UMFD_DLL "${CMAKE_BINARY_DIR}/bin/umfd.dll")
915+
set(UMFD_LIB "${CMAKE_BINARY_DIR}/lib/umfd.lib")
916+
endif()
917+
918+
if(UMF_BUILD_SHARED_LIBRARY)
919+
install(
920+
FILES ${UMFD_DLL}
921+
DESTINATION ${CMAKE_INSTALL_BINDIR}
922+
COMPONENT umfd)
923+
endif()
924+
install(
925+
FILES ${UMFD_LIB}
926+
DESTINATION ${CMAKE_INSTALL_LIBDIR}
927+
COMPONENT umfd)
850928
endif()
851929

852930
install(FILES ${PROJECT_SOURCE_DIR}/LICENSE.TXT

test/test_installation.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import platform
1313
import subprocess # nosec B404
1414
import sys
15+
import os
1516
from typing import List
1617

1718

@@ -28,7 +29,8 @@ class UmfInstaller:
2829
proxy (bool): Determines whether the proxy library should be built together with the UMF library
2930
pools (List[str]): A list of enabled pools during the UMF compilation
3031
umf_version (Version): UMF version currently being built and installed
31-
match_list (List[str]): A list of relative paths of files that should be installed
32+
umfd_lib (bool): Determines if the UMF was built with the umfd library
33+
cmake_generator (str): The CMake generator used for the build
3234
"""
3335

3436
def __init__(
@@ -42,6 +44,7 @@ def __init__(
4244
pools: List[str],
4345
umf_version: Version,
4446
umfd_lib: bool,
47+
cmake_generator: str,
4548
):
4649
self.workspace_dir = workspace_dir
4750
self.build_dir = build_dir
@@ -52,6 +55,7 @@ def __init__(
5255
self.pools = pools
5356
self.umf_version = umf_version
5457
self.umfd_lib = umfd_lib
58+
self.cmake_generator = cmake_generator
5559
self.match_list = self._create_match_list()
5660

5761
def _create_match_list(self) -> List[str]:
@@ -100,9 +104,14 @@ def _create_match_list(self) -> List[str]:
100104
"lib/cmake/umf",
101105
"lib/cmake/umf/umf-config-version.cmake",
102106
"lib/cmake/umf/umf-config.cmake",
103-
f"lib/cmake/umf/umf-targets-{self.build_type}.cmake",
107+
*(
108+
f"lib/cmake/umf/umf-targets-{self.build_type}.cmake"
109+
for _ in [1]
110+
if self.cmake_generator.lower() != "ninja"
111+
),
104112
"lib/cmake/umf/umf-targets.cmake",
105113
]
114+
106115
for pool in self.pools:
107116
lib.append(f"lib/{lib_prefix}{pool}.{lib_ext_static}")
108117
if self.shared_library:
@@ -122,6 +131,8 @@ def _create_match_list(self) -> List[str]:
122131
lib.append(f"lib/{lib_prefix}umf.{self.umf_version}.{lib_ext_shared}")
123132
else:
124133
lib.append(f"lib/{lib_prefix}umf.{lib_ext_static}")
134+
if self.umfd_lib and platform.system() == "Windows":
135+
lib.append(f"lib/{lib_prefix}umfd.{lib_ext_static}")
125136

126137
if self.proxy:
127138
lib.append(f"lib/{lib_prefix}umf_proxy.{lib_ext_shared}")
@@ -135,7 +146,6 @@ def _create_match_list(self) -> List[str]:
135146
f"lib/{lib_prefix}umf_proxy.{self.umf_version.major}.{lib_ext_shared}"
136147
)
137148

138-
share = []
139149
share = [
140150
"share",
141151
"share/doc",
@@ -296,6 +306,11 @@ def parse_arguments(self) -> argparse.Namespace:
296306
action="store_true",
297307
help="Add this argument if the UMF was built with the umfd library",
298308
)
309+
self.parser.add_argument(
310+
"--cmake-generator",
311+
default="Visual Studio 17 2022" if platform.system() == "Windows" else "Unix Makefiles",
312+
help="The CMake generator used for the build, default: platform-specific",
313+
)
299314
return self.parser.parse_args()
300315

301316
def run(self) -> None:
@@ -320,6 +335,7 @@ def run(self) -> None:
320335
pools,
321336
umf_version,
322337
self.args.umfd_lib,
338+
self.args.cmake_generator,
323339
)
324340

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

0 commit comments

Comments
 (0)