@@ -7,7 +7,8 @@ cmake_minimum_required(VERSION 3.14.0 FATAL_ERROR)
7
7
set (UMF_CMAKE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
8
8
9
9
list (APPEND CMAKE_MODULE_PATH "${UMF_CMAKE_SOURCE_DIR} /cmake" )
10
- include (helpers)
10
+ # Use full path of the helpers module (to omit potential conflicts with others)
11
+ include (${UMF_CMAKE_SOURCE_DIR} /cmake/helpers.cmake)
11
12
12
13
# We use semver aligned version, set via git tags. We parse git output to
13
14
# establih the version of UMF to be used in CMake, Win dll's, and within the
@@ -47,8 +48,10 @@ option(UMF_BUILD_EXAMPLES "Build UMF examples" ON)
47
48
option (UMF_BUILD_FUZZTESTS "Build UMF fuzz tests" OFF )
48
49
option (UMF_BUILD_GPU_EXAMPLES "Build UMF GPU examples" OFF )
49
50
option (UMF_DEVELOPER_MODE "Enable additional developer checks" OFF )
50
- option (UMF_LINK_HWLOC_STATICALLY
51
- "Link UMF with HWLOC library statically (Windows+Release only)" OFF )
51
+ option (
52
+ UMF_LINK_HWLOC_STATICALLY
53
+ "Link UMF with HWLOC library statically (supported for Linux, MacOS and Release build on Windows)"
54
+ OFF )
52
55
option (UMF_FORMAT_CODE_STYLE
53
56
"Add clang, cmake, and black -format-check and -format-apply targets"
54
57
OFF )
@@ -60,6 +63,10 @@ option(USE_TSAN "Enable ThreadSanitizer checks" OFF)
60
63
option (USE_MSAN "Enable MemorySanitizer checks" OFF )
61
64
option (USE_VALGRIND "Enable Valgrind instrumentation" OFF )
62
65
option (USE_GCOV "Enable gcov support" OFF )
66
+ option (
67
+ UMF_DISABLE_HWLOC
68
+ "Disable features that requires hwloc (OS provider, memory targets, topolgy discovery)"
69
+ OFF )
63
70
64
71
# set UMF_PROXY_LIB_BASED_ON_POOL to one of: SCALABLE or JEMALLOC
65
72
set (KNOWN_PROXY_LIB_POOLS SCALABLE JEMALLOC)
@@ -93,27 +100,42 @@ else()
93
100
message (FATAL_ERROR "Unknown OS type" )
94
101
endif ()
95
102
103
+ if (NOT DEFINED UMF_HWLOC_REPO)
104
+ set (UMF_HWLOC_REPO "https://github.com/open-mpi/hwloc.git" )
105
+ endif ()
106
+
107
+ if (NOT DEFINED UMF_HWLOC_TAG)
108
+ set (UMF_HWLOC_TAG hwloc-2.10.0)
109
+ endif ()
110
+
96
111
if (NOT UMF_LINK_HWLOC_STATICALLY)
97
- pkg_check_modules(LIBHWLOC hwloc>=2.3.0)
98
- if (NOT LIBHWLOC_FOUND)
99
- find_package (LIBHWLOC 2.3.0 REQUIRED hwloc)
112
+ if (NOT UMF_DISABLE_HWLOC)
113
+ pkg_check_modules(LIBHWLOC hwloc>=2.3.0)
114
+ if (NOT LIBHWLOC_FOUND)
115
+ find_package (LIBHWLOC 2.3.0 REQUIRED hwloc)
116
+ endif ()
117
+
118
+ # add PATH to DLL on Windows
119
+ set (DLL_PATH_LIST
120
+ "${DLL_PATH_LIST} ;PATH=path_list_append:${LIBHWLOC_LIBRARY_DIRS} /../bin"
121
+ )
100
122
endif ()
101
123
# add PATH to DLL on Windows
102
124
set (DLL_PATH_LIST
103
125
"${DLL_PATH_LIST} ;PATH=path_list_append:${LIBHWLOC_LIBRARY_DIRS} /../bin"
104
126
)
105
- else ()
106
- if (NOT WINDOWS)
107
- message (FATAL_ERROR "hwloc can be statically linked only on Windows" )
108
- endif ()
127
+ elseif (WINDOWS AND NOT UMF_DISABLE_HWLOC)
109
128
include (FetchContent)
110
129
set (HWLOC_ENABLE_TESTING OFF )
111
130
set (HWLOC_SKIP_LSTOPO ON )
112
131
set (HWLOC_SKIP_TOOLS ON )
132
+
133
+ message (STATUS "Will fetch hwloc from ${UMF_HWLOC_REPO} " )
134
+
113
135
FetchContent_Declare(
114
136
hwloc_targ
115
- GIT_REPOSITORY "https://github.com/open-mpi/hwloc.git"
116
- GIT_TAG hwloc-2.10.0
137
+ GIT_REPOSITORY ${UMF_HWLOC_REPO}
138
+ GIT_TAG ${UMF_HWLOC_TAG}
117
139
SOURCE_SUBDIR contrib/windows-cmake/ FIND_PACKAGE_ARGS)
118
140
119
141
FetchContent_GetProperties(hwloc_targ)
@@ -126,6 +148,57 @@ else()
126
148
set (LIBHWLOC_LIBRARY_DIRS
127
149
${hwloc_targ_BINARY_DIR} /Release;${hwloc_targ_BINARY_DIR} /Debug)
128
150
151
+ message (STATUS " LIBHWLOC_LIBRARIES = ${LIBHWLOC_LIBRARIES} " )
152
+ message (STATUS " LIBHWLOC_INCLUDE_DIRS = ${LIBHWLOC_INCLUDE_DIRS} " )
153
+ message (STATUS " LIBHWLOC_LIBRARY_DIRS = ${LIBHWLOC_LIBRARY_DIRS} " )
154
+ elseif (NOT UMF_DISABLE_HWLOC)
155
+ include (FetchContent)
156
+ message (STATUS "Will fetch hwloc from ${UMF_HWLOC_REPO} " )
157
+
158
+ FetchContent_Declare(
159
+ hwloc_targ
160
+ GIT_REPOSITORY ${UMF_HWLOC_REPO}
161
+ GIT_TAG ${UMF_HWLOC_TAG} )
162
+
163
+ FetchContent_GetProperties(hwloc_targ)
164
+ if (NOT hwloc_targ_POPULATED)
165
+ FetchContent_MakeAvailable(hwloc_targ)
166
+ endif ()
167
+
168
+ add_custom_command (
169
+ COMMAND ./autogen.sh
170
+ WORKING_DIRECTORY ${hwloc_targ_SOURCE_DIR}
171
+ OUTPUT ${hwloc_targ_SOURCE_DIR} /configure)
172
+ add_custom_command (
173
+ COMMAND
174
+ ./configure --prefix =${hwloc_targ_BINARY_DIR} --enable-static =yes
175
+ --enable-shared=no --disable-libxml2 --disable-levelzero
176
+ CFLAGS=-fPIC CXXFLAGS=-fPIC
177
+ WORKING_DIRECTORY ${hwloc_targ_SOURCE_DIR}
178
+ OUTPUT ${hwloc_targ_SOURCE_DIR} /Makefile
179
+ DEPENDS ${hwloc_targ_SOURCE_DIR} /configure)
180
+ add_custom_command (
181
+ COMMAND make
182
+ WORKING_DIRECTORY ${hwloc_targ_SOURCE_DIR}
183
+ OUTPUT ${hwloc_targ_SOURCE_DIR} /lib/libhwloc.la
184
+ DEPENDS ${hwloc_targ_SOURCE_DIR} /Makefile)
185
+ add_custom_command (
186
+ COMMAND make install
187
+ WORKING_DIRECTORY ${hwloc_targ_SOURCE_DIR}
188
+ OUTPUT ${hwloc_targ_BINARY_DIR} /lib/libhwloc.a
189
+ DEPENDS ${hwloc_targ_SOURCE_DIR} /lib/libhwloc.la)
190
+
191
+ add_custom_target (hwloc_prod
192
+ DEPENDS ${hwloc_targ_BINARY_DIR} /lib/libhwloc.a)
193
+ add_library (hwloc INTERFACE )
194
+ target_link_libraries (hwloc
195
+ INTERFACE ${hwloc_targ_BINARY_DIR} /lib/libhwloc.a)
196
+ add_dependencies (hwloc hwloc_prod)
197
+
198
+ set (LIBHWLOC_LIBRARY_DIRS ${hwloc_targ_BINARY_DIR} /lib)
199
+ set (LIBHWLOC_INCLUDE_DIRS ${hwloc_targ_BINARY_DIR} /include )
200
+ set (LIBHWLOC_LIBRARIES ${hwloc_targ_BINARY_DIR} /lib/libhwloc.a)
201
+
129
202
message (STATUS " LIBHWLOC_LIBRARIES = ${LIBHWLOC_LIBRARIES} " )
130
203
message (STATUS " LIBHWLOC_INCLUDE_DIRS = ${LIBHWLOC_INCLUDE_DIRS} " )
131
204
message (STATUS " LIBHWLOC_LIBRARY_DIRS = ${LIBHWLOC_LIBRARY_DIRS} " )
@@ -317,6 +390,18 @@ else()
317
390
)
318
391
endif ()
319
392
393
+ set (UMF_OPTIONAL_SYMBOLS_LINUX "" )
394
+ set (UMF_OPTIONAL_SYMBOLS_WINDOWS "" )
395
+
396
+ # Conditional configuration for Level Zero provider
397
+ if (UMF_BUILD_LEVEL_ZERO_PROVIDER)
398
+ add_optional_symbol(umfLevelZeroMemoryProviderOps)
399
+ endif ()
400
+
401
+ if (NOT UMF_DISABLE_HWLOC)
402
+ add_optional_symbol(umfOsMemoryProviderOps)
403
+ endif ()
404
+
320
405
add_subdirectory (src)
321
406
322
407
if (UMF_BUILD_TESTS)
@@ -328,20 +413,13 @@ if(UMF_BUILD_BENCHMARKS)
328
413
endif ()
329
414
330
415
if (UMF_BUILD_EXAMPLES)
331
- add_subdirectory (examples)
332
- endif ()
333
-
334
- # Conditional configuration for Level Zero provider
335
- if (UMF_BUILD_LEVEL_ZERO_PROVIDER)
336
- set (OPTIONAL_SYMBOLS "umfLevelZeroMemoryProviderOps" )
337
- else ()
338
- set (OPTIONAL_SYMBOLS "" )
416
+ if (NOT UMF_DISABLE_HWLOC)
417
+ add_subdirectory (examples)
418
+ else ()
419
+ message (WARNING "Examples cannot be build - hwloc disabled" )
420
+ endif ()
339
421
endif ()
340
422
341
- # Configure the DEF file based on whether Level Zero provider is built
342
- configure_file ("${CMAKE_CURRENT_SOURCE_DIR} /src/libumf.def.in"
343
- "${CMAKE_CURRENT_BINARY_DIR} /src/libumf.def" @ONLY)
344
-
345
423
if (UMF_FORMAT_CODE_STYLE)
346
424
find_program (CLANG_FORMAT NAMES clang-format-15 clang-format-15.0
347
425
clang-format)
@@ -522,8 +600,10 @@ endif()
522
600
# Configure make install/uninstall and packages
523
601
# --------------------------------------------------------------------------- #
524
602
install (FILES ${CMAKE_SOURCE_DIR} /LICENSE.TXT
525
- ${CMAKE_SOURCE_DIR} /third-party-programs.txt
526
603
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR} /doc/${PROJECT_NAME} /" )
604
+ install (
605
+ FILES ${CMAKE_SOURCE_DIR} /licensing/third-party-programs.txt
606
+ DESTINATION "${CMAKE_INSTALL_DATAROOTDIR} /doc/${PROJECT_NAME} /licensing/" )
527
607
528
608
install (DIRECTORY examples DESTINATION "${CMAKE_INSTALL_DOCDIR} " )
529
609
0 commit comments