Skip to content

Commit

Permalink
doxy: update build with CMake
Browse files Browse the repository at this point in the history
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 <Brice.Goglin@inria.fr>
(cherry picked from commit fd1f783)
  • Loading branch information
bgoglin committed Jan 7, 2025
1 parent a7fa133 commit f2b8c28
Showing 1 changed file with 8 additions and 23 deletions.
31 changes: 8 additions & 23 deletions doc/hwloc.doxy
Original file line number Diff line number Diff line change
Expand Up @@ -581,33 +581,18 @@ Here's an example de <tt>CMakeLists.txt</tt> which shows variables
obtained from <tt>pkg-config</tt> and how to use them:

\verbatim
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.6)
project(TEST_HWLOC C)

include(FindPkgConfig)
if(PKG_CONFIG_EXECUTABLE)
unset(HWLOC_FOUND CACHE)
pkg_search_module(HWLOC hwloc)
if(HWLOC_FOUND)
message(STATUS "HWLOC_LIBRARIES=${HWLOC_LIBRARIES}")
message(STATUS "HWLOC_LINK_LIBRARIES=${HWLOC_LINK_LIBRARIES}")
message(STATUS "HWLOC_LIBRARY_DIRS=${HWLOC_LIBRARY_DIRS}")
message(STATUS "HWLOC_LDFLAGS=${HWLOC_LDFLAGS}")
message(STATUS "HWLOC_LDFLAGS_OTHERS=${HWLOC_LDFLAGS_OTHERS}")
message(STATUS "HWLOC_INCLUDE_DIRS=${HWLOC_INCLUDE_DIRS}")
message(STATUS "HWLOC_CFLAGS=${HWLOC_CFLAGS}")
message(STATUS "HWLOC_CFLAGS_OTHER=${HWLOC_CFLAGS_OTHER}")
else()
message(FATAL_ERROR "HWLOC not found with pkg-config, add the path to hwloc.pc in PKG_CONFIG_PATH.")
endif()
else()
message(FATAL_ERROR "PKG_CONFIG_EXECUTABLE: not found.")
endif()
if(PKG_CONFIG_FOUND)
pkg_search_module(HWLOC REQUIRED IMPORTED_TARGET hwloc)
else(PKG_CONFIG_FOUND)
message(FATAL_ERROR "FindHWLOC needs pkg-config program and PKG_CONFIG_PATH must contain the path to hwloc.pc file.")
endif(PKG_CONFIG_FOUND)

add_executable(hwloc-hello hwloc-hello.c)
target_include_directories(hwloc-hello PRIVATE ${HWLOC_INCLUDE_DIRS})
target_compile_options(hwloc-hello PRIVATE ${HWLOC_CFLAGS})
target_link_libraries(hwloc-hello PRIVATE ${HWLOC_LINK_LIBRARIES})
target_link_options(hwloc-hello PRIVATE ${HWLOC_LDFLAGS})
target_link_libraries(hwloc-hello PRIVATE PkgConfig::HWLOC)
\endverbatim

The project may be built with:
Expand Down

0 comments on commit f2b8c28

Please sign in to comment.