Skip to content

Install debug libraries on Windows #1219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/reusable_basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ jobs:
shared_library: 'ON'
level_zero_provider: 'ON'
cuda_provider: 'ON'
umfd_lib: 'ON'
- os: 'windows-2022'
build_type: Release
compiler: {c: cl, cxx: cl}
Expand Down Expand Up @@ -289,6 +290,7 @@ jobs:
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=${{matrix.level_zero_provider}}
-DUMF_BUILD_CUDA_PROVIDER=${{matrix.cuda_provider}}
-DUMF_TESTS_FAIL_ON_SKIP=ON
-DUMF_USE_DEBUG_POSTFIX=${{matrix.umfd_lib}}

- name: Build UMF
run: cmake --build ${{env.BUILD_DIR}} --config ${{matrix.build_type}} -j $Env:NUMBER_OF_PROCESSORS
Expand All @@ -307,6 +309,7 @@ jobs:
${{matrix.shared_library == 'ON' && '--proxy' || '' }}
--umf-version ${{env.UMF_VERSION}}
${{ matrix.shared_library == 'ON' && '--shared-library' || ''}}
${{ matrix.umfd_lib == 'ON' && '--umfd-lib' || ''}}

- name: check /DEPENDENTLOADFLAG in umf.dll
if: ${{matrix.shared_library == 'ON' && matrix.compiler.cxx == 'cl'}}
Expand Down
31 changes: 31 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ set(UMF_INSTALL_RPATH
"Set the runtime search path to the directory with dependencies (e.g. hwloc)"
)

umf_option(UMF_USE_DEBUG_POSTFIX "Add a 'd' postfix to Windows debug libraries"
OFF)
umf_option(UMF_DEVELOPER_MODE "Enable additional developer checks" OFF)
umf_option(
UMF_FORMAT_CODE_STYLE
Expand Down Expand Up @@ -426,6 +428,27 @@ elseif(UMF_BUILD_CUDA_PROVIDER)
message(STATUS "CUDA_INCLUDE_DIRS = ${CUDA_INCLUDE_DIRS}")
endif()

if(WINDOWS AND UMF_USE_DEBUG_POSTFIX)
# Build debug umf library with the d suffix that is compiled with /MDd so
# users can link against it in debug builds.
set(CMAKE_DEBUG_POSTFIX d)

add_custom_target(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you also add comment here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

umfd ALL
COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target umf
--config Debug
COMMENT "Building debug umf library with the d suffix")

# Copy built UMF libraries to the Release build subdirectory
add_custom_command(
TARGET umfd
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/bin/Debug/umfd.dll
${CMAKE_BINARY_DIR}/bin/Release/umfd.dll
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/lib/Debug/umfd.lib
${CMAKE_BINARY_DIR}/lib/Release/umfd.lib
COMMENT "Copying debug libraries to the Release build directory")
Comment on lines +443 to +449
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks when using Ninja generator (I assume also Unix Makefiles which is what internal builds use).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes made in #1238

endif()

# This build type check is not possible on Windows when CMAKE_BUILD_TYPE is not
# set, because in this case the build type is determined after a CMake
# configuration is done (at the build time)
Expand Down Expand Up @@ -818,6 +841,14 @@ endif()
# --------------------------------------------------------------------------- #
# Configure make install/uninstall and packages
# --------------------------------------------------------------------------- #
# Install umfd target
if(WINDOWS AND UMF_USE_DEBUG_POSTFIX)
install(FILES ${CMAKE_BINARY_DIR}/bin/Debug/umfd.dll
DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES ${CMAKE_BINARY_DIR}/lib/Debug/umfd.lib
DESTINATION ${CMAKE_INSTALL_LIBDIR})
Comment on lines +846 to +849
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And so do these. Also unable to install only these because there's no COMPONENT to name.

endif()

install(FILES ${PROJECT_SOURCE_DIR}/LICENSE.TXT
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/doc/${PROJECT_NAME}/")
install(
Expand Down
16 changes: 15 additions & 1 deletion test/test_installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def __init__(
proxy: bool,
pools: List[str],
umf_version: Version,
umfd_lib: bool,
):
self.workspace_dir = workspace_dir
self.build_dir = build_dir
Expand All @@ -50,6 +51,7 @@ def __init__(
self.proxy = proxy
self.pools = pools
self.umf_version = umf_version
self.umfd_lib = umfd_lib
self.match_list = self._create_match_list()

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

bin = []
if platform.system() == "Windows" and (self.shared_library or self.proxy):
if platform.system() == "Windows" and (
self.shared_library or self.proxy or self.umfd_lib
):
bin.append("bin")
if self.shared_library:
bin.append("bin/umf.dll")
if self.umfd_lib:
bin.append("bin/umfd.dll")
if self.proxy:
bin.append("bin/umf_proxy.dll")

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

if platform.system() == "Linux":
lib.append(
Expand Down Expand Up @@ -283,6 +291,11 @@ def parse_arguments(self) -> argparse.Namespace:
action="store",
help="Current version of the UMF, e.g. 1.0.0",
)
self.parser.add_argument(
"--umfd-lib",
action="store_true",
help="Add this argument if the UMF was built with the umfd library",
)
return self.parser.parse_args()

def run(self) -> None:
Expand All @@ -306,6 +319,7 @@ def run(self) -> None:
self.args.proxy,
pools,
umf_version,
self.args.umfd_lib,
)

print("Installation test - BEGIN", flush=True)
Expand Down
Loading