Skip to content

Commit

Permalink
windows-cmake: search for LibXml2
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Hirsch <michael@scivision.dev>
  • Loading branch information
scivision committed Nov 7, 2021
1 parent 76d94d0 commit 9a8ab88
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
17 changes: 17 additions & 0 deletions contrib/windows-cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,19 @@ HWLOC_HAVE_MSVC_CPUIDEX
# - strtoull() had some issues in the past (see 9559bd08b79ef63dce45df87fb7f875b73ecb512)
# set(HAVE_DECL_STRTOULL 1)

# --- optional external libraries
find_package(LibXml2)
set(HWLOC_HAVE_LIBXML2)
if(LibXml2_FOUND)
set(HWLOC_HAVE_LIBXML2 1)
endif()

find_package(OpenCL)
set(HWLOC_HAVE_OPENCL)
if(OpenCL_FOUND)
set(HWLOC_HAVE_OPENCL 1)
endif()

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/private_config.h.in include/private/autogen/config.h)

# Library
Expand Down Expand Up @@ -94,8 +107,12 @@ add_library(hwloc
${TOPDIR}/hwloc/topology-xml-nolibxml.c
${TOPDIR}/hwloc/topology-windows.c
${TOPDIR}/hwloc/topology-x86.c
$<$<BOOL:${HWLOC_HAVE_LIBXML2}>:${TOPDIR}/hwloc/topology-xml-libxml.c>
$<$<BOOL:${HWLOC_HAVE_OPENCL}>:${TOPDIR}/hwloc/topology-opencl.c>
)

target_link_libraries(hwloc PRIVATE $<$<BOOL:${HWLOC_HAVE_LIBXML2}>:LibXml2::LibXml2>)

if(BUILD_SHARED_LIBS)
target_compile_definitions(hwloc PRIVATE $<$<BOOL:${MSVC}>:_USRDLL>)
endif()
Expand Down
4 changes: 2 additions & 2 deletions contrib/windows-cmake/private_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@
/* #undef HWLOC_HAVE_LIBTERMCAP */

/* Define to 1 if you have the `libxml2' library. */
/* #undef HWLOC_HAVE_LIBXML2 */
#cmakedefine HWLOC_HAVE_LIBXML2 @HWLOC_HAVE_LIBXML2@

/* Define to 1 if building the Linux PCI component */
/* #undef HWLOC_HAVE_LINUXPCI */
Expand All @@ -500,7 +500,7 @@
/* #undef HWLOC_HAVE_OLD_SCHED_SETAFFINITY */

/* Define to 1 if you have the `OpenCL' library. */
/* #undef HWLOC_HAVE_OPENCL */
#cmakedefine HWLOC_HAVE_OPENCL @HWLOC_HAVE_OPENCL@

/* Define to 1 if the hwloc library should support dynamically-loaded plugins
*/
Expand Down
10 changes: 10 additions & 0 deletions tests/hwloc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,13 @@ LABELS exe
TIMEOUT 10
)


# --- optional tests

if(HWLOC_HAVE_OPENCL)
add_executable(test_opencl opencl.c)
target_link_libraries(test_opencl PRIVATE hwloc::hwloc)

add_test(NAME OpenCL COMMAND test_opencl)
set_tests_properties(OpenCL PROPERTIES TIMEOUT 10)
endif()

0 comments on commit 9a8ab88

Please sign in to comment.