Skip to content

Various CMake updates #1043

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 4 commits into from
Jan 24, 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
35 changes: 24 additions & 11 deletions .cmake-format
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,31 @@ with section("parse"):
"pargs": 0,
"flags": [],
'kwargs': {
'NAME': '*',
'SRCS': '*',
'LIBS': '*' ,
'NAME': '*',
'SRCS': '*',
'LIBS': '*' ,
'LIBDIRS': '*'}},
'add_umf_executable': {
"pargs": 0,
"flags": [],
'kwargs': {
'NAME': '*',
'SRCS': '*',
'NAME': '*',
'SRCS': '*',
'LIBS': '*'}},
'add_umf_test': {
"pargs": 0,
"flags": [],
'kwargs': {
'NAME': '*',
'SRCS': '*',
'NAME': '*',
'SRCS': '*',
'LIBS': '*'}},
'add_umf_library': {
"pargs": 0,
"flags": [],
'kwargs': {
'NAME': '*',
'TYPE': '*',
'SRCS': '*',
'NAME': '*',
'TYPE': '*',
'SRCS': '*',
'LIBS': '*',
'LINUX_MAP_FILE': '*',
'WINDOWS_DEF_FILE': '*'}},
Expand All @@ -43,7 +43,20 @@ with section("parse"):
'kwargs': {
'LABELS': '*',
'PASS_REGULAR_EXPRESSION': '*'}},
}
'build_umf_test': {
"pargs": 0,
"flags": [],
'kwargs': {
'NAME': '*',
'SRCS': '*',
'LIBS': '*' }},
'add_umf_ipc_test': {
"pargs": 0,
"flags": [],
'kwargs': {
'TEST': '*',
'SRC_DIR': '*'}},
}

# Override configurations per-command where available
override_spec = {}
Expand Down
32 changes: 25 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ list(APPEND CMAKE_MODULE_PATH "${UMF_CMAKE_SOURCE_DIR}/cmake")
# Use full path of the helpers module (to omit potential conflicts with others)
include(${UMF_CMAKE_SOURCE_DIR}/cmake/helpers.cmake)

# --------------------------------------------------------------------------- #
# Set UMF version variables, define project, and add basic modules
# --------------------------------------------------------------------------- #

# We use semver aligned version, set via git tags. We parse git output to
# establish the version of UMF to be used in CMake, Win dll's, and within the
# code (e.g. in logger). We have 3-component releases (e.g. 1.5.1) plus release
Expand All @@ -22,6 +26,12 @@ project(
umf
VERSION ${UMF_CMAKE_VERSION}
LANGUAGES C)
if(UMF_CMAKE_VERSION VERSION_EQUAL "0.0.0")
message(
WARNING
"UMF version is set to 0.0.0, which most likely is not expected! "
"Please checkout the git tags to get a proper version.")
endif()

if(PROJECT_VERSION_PATCH GREATER 0)
# set extra variable for Windows dll metadata
Expand All @@ -33,6 +43,10 @@ include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
find_package(PkgConfig)

# --------------------------------------------------------------------------- #
# Set UMF build options (and CACHE variables)
# --------------------------------------------------------------------------- #

# Define a list to store the names of all options
set(UMF_OPTIONS_LIST "")
list(APPEND UMF_OPTIONS_LIST CMAKE_BUILD_TYPE)
Expand All @@ -43,7 +57,6 @@ macro(umf_option)
option(${ARGV})
endmacro()

# Build Options
umf_option(UMF_BUILD_SHARED_LIBRARY "Build UMF as shared library" OFF)
umf_option(UMF_BUILD_LEVEL_ZERO_PROVIDER "Build Level Zero memory provider" ON)
umf_option(UMF_BUILD_CUDA_PROVIDER "Build CUDA memory provider" ON)
Expand All @@ -56,9 +69,8 @@ umf_option(UMF_BUILD_GPU_TESTS "Build UMF GPU tests" OFF)
umf_option(UMF_BUILD_BENCHMARKS "Build UMF benchmarks" OFF)
umf_option(UMF_BUILD_BENCHMARKS_MT "Build UMF multithreaded benchmarks" OFF)
umf_option(UMF_BUILD_EXAMPLES "Build UMF examples" ON)
umf_option(UMF_BUILD_FUZZTESTS "Build UMF fuzz tests" OFF)
umf_option(UMF_BUILD_GPU_EXAMPLES "Build UMF GPU examples" OFF)
umf_option(UMF_DEVELOPER_MODE "Enable additional developer checks" OFF)
umf_option(UMF_BUILD_FUZZTESTS "Build UMF fuzz tests" OFF)
umf_option(
UMF_DISABLE_HWLOC
"Disable hwloc and UMF features requiring it (OS provider, memtargets, topology discovery)"
Expand All @@ -67,9 +79,6 @@ umf_option(
UMF_LINK_HWLOC_STATICALLY
"Link UMF with HWLOC library statically (proxy library will be disabled on Windows+Debug build)"
OFF)
umf_option(
UMF_FORMAT_CODE_STYLE
"Add clang, cmake, and black -format-check and -format-apply targets" OFF)
set(UMF_HWLOC_NAME
"hwloc"
CACHE STRING "Custom name for hwloc library w/o extension")
Expand All @@ -81,6 +90,10 @@ set(UMF_INSTALL_RPATH
"Set the runtime search path to the directory with dependencies (e.g. hwloc)"
)

umf_option(UMF_DEVELOPER_MODE "Enable additional developer checks" OFF)
umf_option(
UMF_FORMAT_CODE_STYLE
"Add clang, cmake, and black -format-check and -format-apply targets" OFF)
# Only a part of skips is treated as a failure now. TODO: extend to all tests
umf_option(UMF_TESTS_FAIL_ON_SKIP "Treat skips in tests as fail" OFF)
umf_option(UMF_USE_ASAN "Enable AddressSanitizer checks" OFF)
Expand All @@ -100,6 +113,11 @@ set_property(CACHE UMF_PROXY_LIB_BASED_ON_POOL
PROPERTY STRINGS ${KNOWN_PROXY_LIB_POOLS})
list(APPEND UMF_OPTIONS_LIST UMF_PROXY_LIB_BASED_ON_POOL)

# --------------------------------------------------------------------------- #
# Setup required variables, definitions; fetch dependencies; include
# sub_directories based on build options; set flags; etc.
# --------------------------------------------------------------------------- #

if(UMF_BUILD_TESTS
AND DEFINED ENV{CI}
AND NOT UMF_TESTS_FAIL_ON_SKIP)
Expand Down Expand Up @@ -711,7 +729,7 @@ if(UMF_FORMAT_CODE_STYLE)
add_custom_target(
cmake-format-apply
COMMAND ${CMAKE_FORMAT} --in-place ${format_cmake_list}
COMMENT "Format Cmake files using cmake-format")
COMMENT "Format CMake files using cmake-format")
endif()

if(BLACK)
Expand Down
4 changes: 2 additions & 2 deletions benchmark/ubench.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (C) 2023-2024 Intel Corporation
* Copyright (C) 2023-2025 Intel Corporation
*
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Expand Down Expand Up @@ -452,7 +452,7 @@ static int create_level_zero_params(ze_context_handle_t *context,

int ret = utils_ze_init_level_zero();
if (ret != 0) {
fprintf(stderr, "Failed to init Level 0!\n");
fprintf(stderr, "Failed to init Level Zero!\n");
return ret;
}

Expand Down
4 changes: 2 additions & 2 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2024 Intel Corporation
# Copyright (C) 2024-2025 Intel Corporation
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

Expand Down Expand Up @@ -154,7 +154,7 @@ if(UMF_BUILD_GPU_EXAMPLES
else()
message(
STATUS
"IPC Level 0 example requires UMF_BUILD_GPU_EXAMPLES, UMF_BUILD_LEVEL_ZERO_PROVIDER and UMF_BUILD_LIBUMF_POOL_DISJOINT to be turned ON - skipping"
"IPC Level Zero example requires UMF_BUILD_GPU_EXAMPLES, UMF_BUILD_LEVEL_ZERO_PROVIDER and UMF_BUILD_LIBUMF_POOL_DISJOINT to be turned ON - skipping"
)
endif()

Expand Down
4 changes: 2 additions & 2 deletions examples/ipc_level_zero/ipc_level_zero.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (C) 2024 Intel Corporation
* Copyright (C) 2024-2025 Intel Corporation
*
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Expand Down Expand Up @@ -104,7 +104,7 @@ int main(void) {
const size_t BUFFER_PATTERN = 0x42;
int ret = init_level_zero();
if (ret != 0) {
fprintf(stderr, "ERROR: Failed to init Level 0!\n");
fprintf(stderr, "ERROR: Failed to init Level Zero!\n");
return ret;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (C) 2024 Intel Corporation
* Copyright (C) 2024-2025 Intel Corporation
*
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Expand All @@ -27,7 +27,7 @@ int main(void) {
// Initialize Level Zero
int ret = init_level_zero();
if (ret != 0) {
fprintf(stderr, "Failed to init Level 0!\n");
fprintf(stderr, "Failed to init Level Zero!\n");
return ret;
}

Expand Down
Loading
Loading