@@ -14,6 +14,11 @@ set(UMF_CMAKE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
14
14
list (APPEND CMAKE_MODULE_PATH "${UMF_CMAKE_SOURCE_DIR} /cmake" )
15
15
include (${UMF_CMAKE_SOURCE_DIR} /cmake/helpers.cmake )
16
16
17
+ include (CTest )
18
+ include (CMakePackageConfigHelpers )
19
+ include (GNUInstallDirs )
20
+ find_package (PkgConfig )
21
+
17
22
# CMAKE_PROJECT_VERSION[_MAJOR|_MINOR|_PATCH] variables are set via 'project'
18
23
# command. They cannot contain any "pre-release" part, though. We use custom
19
24
# "UMF_SRC_VERSION" to store more accurate (source) version - this var should be
@@ -39,6 +44,8 @@ option(UMF_BUILD_EXAMPLES "Build UMF examples" ON)
39
44
option (UMF_BUILD_FUZZTESTS "Build UMF fuzz tests" OFF )
40
45
option (UMF_BUILD_GPU_EXAMPLES "Build UMF GPU examples" OFF )
41
46
option (UMF_DEVELOPER_MODE "Enable additional developer checks" OFF )
47
+ option (UMF_LINK_HWLOC_STATICALLY
48
+ "Link UMF with HWLOC library statically (Windows+Release only)" OFF )
42
49
option (UMF_FORMAT_CODE_STYLE
43
50
"Add clang, cmake, and black -format-check and -format-apply targets"
44
51
OFF )
@@ -83,6 +90,44 @@ else()
83
90
message (FATAL_ERROR "Unknown OS type" )
84
91
endif ()
85
92
93
+ if (NOT UMF_LINK_HWLOC_STATICALLY )
94
+ pkg_check_modules (LIBHWLOC hwloc>=2.3.0 )
95
+ if (NOT LIBHWLOC_FOUND )
96
+ find_package (LIBHWLOC 2.3.0 REQUIRED hwloc )
97
+ endif ()
98
+ # add PATH to DLL on Windows
99
+ set (DLL_PATH_LIST
100
+ "${DLL_PATH_LIST} ;PATH=path_list_append:${LIBHWLOC_LIBRARY_DIRS} /../bin"
101
+ )
102
+ else ()
103
+ if (NOT WINDOWS )
104
+ message (FATAL_ERROR "hwloc can be statically linked only on Windows" )
105
+ endif ()
106
+ include (FetchContent )
107
+ set (HWLOC_ENABLE_TESTING OFF )
108
+ set (HWLOC_SKIP_LSTOPO ON )
109
+ set (HWLOC_SKIP_TOOLS ON )
110
+ FetchContent_Declare (
111
+ hwloc_targ
112
+ GIT_REPOSITORY "https://github.com/open-mpi/hwloc.git"
113
+ GIT_TAG hwloc-2.10.0
114
+ SOURCE_SUBDIR contrib/windows-cmake/ FIND_PACKAGE_ARGS )
115
+
116
+ FetchContent_GetProperties (hwloc_targ )
117
+ if (NOT hwloc_targ_POPULATED )
118
+ FetchContent_MakeAvailable (hwloc_targ )
119
+ endif ()
120
+
121
+ set (LIBHWLOC_INCLUDE_DIRS
122
+ ${hwloc_targ_SOURCE_DIR} /include;${hwloc_targ_BINARY_DIR}/include )
123
+ set (LIBHWLOC_LIBRARY_DIRS
124
+ ${hwloc_targ_BINARY_DIR} /Release;${hwloc_targ_BINARY_DIR}/Debug )
125
+
126
+ message (STATUS " LIBHWLOC_LIBRARIES = ${LIBHWLOC_LIBRARIES} " )
127
+ message (STATUS " LIBHWLOC_INCLUDE_DIRS = ${LIBHWLOC_INCLUDE_DIRS} " )
128
+ message (STATUS " LIBHWLOC_LIBRARY_DIRS = ${LIBHWLOC_LIBRARY_DIRS} " )
129
+ endif ()
130
+
86
131
# This build type check is not possible on Windows when CMAKE_BUILD_TYPE is not
87
132
# set, because in this case the build type is determined after a CMake
88
133
# configuration is done (at the build time)
@@ -130,11 +175,6 @@ foreach(option_name ${OPTIONS_REQUIRING_CXX})
130
175
endif ()
131
176
endforeach ()
132
177
133
- include (CTest )
134
- include (CMakePackageConfigHelpers )
135
- include (GNUInstallDirs )
136
- find_package (PkgConfig )
137
-
138
178
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} /lib )
139
179
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} /lib )
140
180
set (CMAKE_UMF_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} /bin )
@@ -186,7 +226,8 @@ if(WINDOWS)
186
226
add_compile_definitions (_CRT_SECURE_NO_WARNINGS )
187
227
# set PATH to DLLs on Windows
188
228
set (DLL_PATH_LIST
189
- "PATH=path_list_append:${PROJECT_BINARY_DIR} /bin/$<CONFIG>" )
229
+ "${DLL_PATH_LIST} ;PATH=path_list_append:${PROJECT_BINARY_DIR} /bin/$<CONFIG>"
230
+ )
190
231
# add path to the proxy lib DLL
191
232
set (DLL_PATH_LIST
192
233
"${DLL_PATH_LIST} ;PATH=path_list_append:${PROJECT_BINARY_DIR} /src/proxy_lib"
@@ -197,14 +238,6 @@ if(WINDOWS)
197
238
)
198
239
endif ()
199
240
200
- pkg_check_modules (LIBHWLOC hwloc>=2.3.0 )
201
- if (NOT LIBHWLOC_FOUND )
202
- find_package (LIBHWLOC 2.3.0 REQUIRED hwloc )
203
- endif ()
204
- # add PATH to DLL on Windows
205
- set (DLL_PATH_LIST
206
- "${DLL_PATH_LIST} ;PATH=path_list_append:${LIBHWLOC_LIBRARY_DIRS} /../bin" )
207
-
208
241
pkg_check_modules (TBB tbb )
209
242
if (NOT TBB_FOUND )
210
243
find_package (TBB OPTIONAL_COMPONENTS tbb )
@@ -240,10 +273,17 @@ if(WINDOWS)
240
273
# In MSVC builds, there is no way to determine the actual build type during
241
274
# the CMake configuration step. Therefore, this message is printed in all
242
275
# MSVC builds.
243
- message (
244
- STATUS
245
- "The proxy library will be built, however it is supported only in the Release build on Windows"
246
- )
276
+ if (UMF_LINK_HWLOC_STATICALLY )
277
+ message (
278
+ STATUS
279
+ "The proxy library will be disabled - static linkage with hwloc is not supported yet"
280
+ )
281
+ else ()
282
+ message (
283
+ STATUS
284
+ "The proxy library will be built, however it is supported only in the Release build on Windows"
285
+ )
286
+ endif ()
247
287
endif ()
248
288
if (UMF_PROXY_LIB_BASED_ON_POOL STREQUAL SCALABLE )
249
289
if (UMF_POOL_SCALABLE_ENABLED )
0 commit comments