Skip to content

Commit fd1f783

Browse files
committed
doxy: update build with CMake
Simplify the code using CMake 3.6+ features (PkgConfig::HWLOC). Thanks to Florent Pruvost and the example at https://gitlab.inria.fr/solverstack/distrib/-/tree/master/cmake/test/hwloc Refs #565 Signed-off-by: Brice Goglin <[email protected]>
1 parent 4b2a139 commit fd1f783

File tree

1 file changed

+8
-23
lines changed

1 file changed

+8
-23
lines changed

doc/hwloc.doxy

+8-23
Original file line numberDiff line numberDiff line change
@@ -581,33 +581,18 @@ Here's an example de <tt>CMakeLists.txt</tt> which shows variables
581581
obtained from <tt>pkg-config</tt> and how to use them:
582582

583583
\verbatim
584-
cmake_minimum_required(VERSION 3.5)
584+
cmake_minimum_required(VERSION 3.6)
585585
project(TEST_HWLOC C)
586+
586587
include(FindPkgConfig)
587-
if(PKG_CONFIG_EXECUTABLE)
588-
unset(HWLOC_FOUND CACHE)
589-
pkg_search_module(HWLOC hwloc)
590-
if(HWLOC_FOUND)
591-
message(STATUS "HWLOC_LIBRARIES=${HWLOC_LIBRARIES}")
592-
message(STATUS "HWLOC_LINK_LIBRARIES=${HWLOC_LINK_LIBRARIES}")
593-
message(STATUS "HWLOC_LIBRARY_DIRS=${HWLOC_LIBRARY_DIRS}")
594-
message(STATUS "HWLOC_LDFLAGS=${HWLOC_LDFLAGS}")
595-
message(STATUS "HWLOC_LDFLAGS_OTHERS=${HWLOC_LDFLAGS_OTHERS}")
596-
message(STATUS "HWLOC_INCLUDE_DIRS=${HWLOC_INCLUDE_DIRS}")
597-
message(STATUS "HWLOC_CFLAGS=${HWLOC_CFLAGS}")
598-
message(STATUS "HWLOC_CFLAGS_OTHER=${HWLOC_CFLAGS_OTHER}")
599-
else()
600-
message(FATAL_ERROR "HWLOC not found with pkg-config, add the path to hwloc.pc in PKG_CONFIG_PATH.")
601-
endif()
602-
else()
603-
message(FATAL_ERROR "PKG_CONFIG_EXECUTABLE: not found.")
604-
endif()
588+
if(PKG_CONFIG_FOUND)
589+
pkg_search_module(HWLOC REQUIRED IMPORTED_TARGET hwloc)
590+
else(PKG_CONFIG_FOUND)
591+
message(FATAL_ERROR "FindHWLOC needs pkg-config program and PKG_CONFIG_PATH must contain the path to hwloc.pc file.")
592+
endif(PKG_CONFIG_FOUND)
605593

606594
add_executable(hwloc-hello hwloc-hello.c)
607-
target_include_directories(hwloc-hello PRIVATE ${HWLOC_INCLUDE_DIRS})
608-
target_compile_options(hwloc-hello PRIVATE ${HWLOC_CFLAGS})
609-
target_link_libraries(hwloc-hello PRIVATE ${HWLOC_LINK_LIBRARIES})
610-
target_link_options(hwloc-hello PRIVATE ${HWLOC_LDFLAGS})
595+
target_link_libraries(hwloc-hello PRIVATE PkgConfig::HWLOC)
611596
\endverbatim
612597

613598
The project may be built with:

0 commit comments

Comments
 (0)