Skip to content

Commit 6f6c9f6

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]> (cherry picked from commit fd1f783)
1 parent 2bb7b09 commit 6f6c9f6

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
@@ -582,33 +582,18 @@ Here's an example de <tt>CMakeLists.txt</tt> which shows variables
582582
obtained from <tt>pkg-config</tt> and how to use them:
583583

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

607595
add_executable(hwloc-hello hwloc-hello.c)
608-
target_include_directories(hwloc-hello PRIVATE ${HWLOC_INCLUDE_DIRS})
609-
target_compile_options(hwloc-hello PRIVATE ${HWLOC_CFLAGS})
610-
target_link_libraries(hwloc-hello PRIVATE ${HWLOC_LINK_LIBRARIES})
611-
target_link_options(hwloc-hello PRIVATE ${HWLOC_LDFLAGS})
596+
target_link_libraries(hwloc-hello PRIVATE PkgConfig::HWLOC)
612597
\endverbatim
613598

614599
The project may be built with:

0 commit comments

Comments
 (0)