@@ -14,6 +14,11 @@ set(UMF_CMAKE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
1414list (APPEND CMAKE_MODULE_PATH "${UMF_CMAKE_SOURCE_DIR} /cmake" )
1515include (${UMF_CMAKE_SOURCE_DIR} /cmake/helpers.cmake)
1616
17+ include (CTest)
18+ include (CMakePackageConfigHelpers)
19+ include (GNUInstallDirs)
20+ find_package (PkgConfig)
21+
1722# CMAKE_PROJECT_VERSION[_MAJOR|_MINOR|_PATCH] variables are set via 'project'
1823# command. They cannot contain any "pre-release" part, though. We use custom
1924# "UMF_SRC_VERSION" to store more accurate (source) version - this var should be
@@ -37,6 +42,8 @@ option(UMF_BUILD_BENCHMARKS "Build UMF benchmarks" OFF)
3742option (UMF_BUILD_BENCHMARKS_MT "Build UMF multithreaded benchmarks" OFF )
3843option (UMF_BUILD_EXAMPLES "Build UMF examples" ON )
3944option (UMF_BUILD_GPU_EXAMPLES "Build UMF GPU examples" OFF )
45+ option (UMF_LINK_HWLOC_STATICALLY
46+ "Link UMF with HWLOC library statically (Windows+Release only)" OFF )
4047option (UMF_DEVELOPER_MODE "Enable developer checks, treats warnings as errors"
4148 OFF )
4249option (UMF_FORMAT_CODE_STYLE
@@ -83,6 +90,47 @@ else()
8390 message (FATAL_ERROR "Unknown OS type" )
8491endif ()
8592
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 WIN32 )
104+ message (FATAL_ERROR "hwloc can be static linked only on Windows" )
105+ endif ()
106+ include (FetchContent)
107+ FetchContent_Declare(
108+ hwloc_targ
109+ GIT_REPOSITORY "https://github.com/open-mpi/hwloc.git"
110+ GIT_TAG hwloc-2.10.0
111+ FIND_PACKAGE_ARGS)
112+
113+ FetchContent_GetProperties(hwloc_targ)
114+ if (NOT hwloc_targ_POPULATED)
115+ FetchContent_MakeAvailable(hwloc_targ)
116+ endif ()
117+
118+ set (HWLOC_ENABLE_TESTING OFF )
119+ set (HWLOC_SKIP_LSTOPO ON )
120+ set (HWLOC_SKIP_TOOLS ON )
121+ set (hwloc_cmake ${hwloc_targ_SOURCE_DIR} /contrib/windows-cmake)
122+
123+ add_subdirectory (${hwloc_cmake} ${hwloc_targ_SOURCE_DIR} )
124+
125+ set (LIBHWLOC_INCLUDE_DIRS ${hwloc_targ_SOURCE_DIR} /include )
126+ set (LIBHWLOC_LIBRARY_DIRS ${hwloc_targ_SOURCE_DIR} /Release)
127+ set (LIBHWLOC_LIBRARIES ${LIBHWLOC_LIBRARY_DIRS} /hwloc.lib)
128+
129+ message (STATUS " LIBHWLOC_LIBRARIES = ${LIBHWLOC_LIBRARIES} " )
130+ message (STATUS " LIBHWLOC_INCLUDE_DIRS = ${LIBHWLOC_INCLUDE_DIRS} " )
131+ message (STATUS " LIBHWLOC_LIBRARY_DIRS = ${LIBHWLOC_LIBRARY_DIRS} " )
132+ endif ()
133+
86134# This build type check is not possible on Windows when CMAKE_BUILD_TYPE is not
87135# set, because in this case the build type is determined after a CMake
88136# configuration is done (at the build time)
@@ -130,11 +178,6 @@ foreach(option_name ${OPTIONS_REQUIRING_CXX})
130178 endif ()
131179endforeach ()
132180
133- include (CTest)
134- include (CMakePackageConfigHelpers)
135- include (GNUInstallDirs)
136- find_package (PkgConfig)
137-
138181set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} /lib)
139182set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} /lib)
140183set (CMAKE_UMF_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} /bin)
@@ -179,7 +222,8 @@ if(WINDOWS)
179222 add_compile_definitions (_CRT_SECURE_NO_WARNINGS)
180223 # set PATH to DLLs on Windows
181224 set (DLL_PATH_LIST
182- "PATH=path_list_append:${PROJECT_BINARY_DIR} /bin/$<CONFIG>" )
225+ "${DLL_PATH_LIST} ;PATH=path_list_append:${PROJECT_BINARY_DIR} /bin/$<CONFIG>"
226+ )
183227 # add path to the proxy lib DLL
184228 set (DLL_PATH_LIST
185229 "${DLL_PATH_LIST} ;PATH=path_list_append:${PROJECT_BINARY_DIR} /src/proxy_lib"
@@ -190,14 +234,6 @@ if(WINDOWS)
190234 )
191235endif ()
192236
193- pkg_check_modules(LIBHWLOC hwloc>=2.3.0)
194- if (NOT LIBHWLOC_FOUND)
195- find_package (LIBHWLOC 2.3.0 REQUIRED hwloc)
196- endif ()
197- # add PATH to DLL on Windows
198- set (DLL_PATH_LIST
199- "${DLL_PATH_LIST} ;PATH=path_list_append:${LIBHWLOC_LIBRARY_DIRS} /../bin" )
200-
201237pkg_check_modules(TBB tbb)
202238if (NOT TBB_FOUND)
203239 find_package (TBB OPTIONAL_COMPONENTS tbb)
0 commit comments