[Openmp-commits] [PATCH] D123888: [Clang][OpenMP] libompd: get libomp hwloc includedir by target_link_libraries

Bernhard Kaindl via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Fri Apr 15 20:10:15 PDT 2022


bernhardkaindl updated this revision to Diff 423208.
bernhardkaindl added a comment.

Thanks, added:

  --- a/openmp/runtime/cmake/config-ix.cmake
  +++ b/openmp/runtime/cmake/config-ix.cmake
  @@ -333,6 +333,7 @@ endif()
   # Check if HWLOC support is available
   if(${LIBOMP_USE_HWLOC})
     set(CMAKE_REQUIRED_INCLUDES ${LIBOMP_HWLOC_INSTALL_DIR}/include)
  +  find_path(LIBOMP_HWLOC_INCLUDE_DIR NAMES hwloc.h HINTS ${LIBOMP_HWLOC_INSTALL_DIR} PATH_SUFFIXES include)
     check_include_file(hwloc.h LIBOMP_HAVE_HWLOC_H)
     set(CMAKE_REQUIRED_INCLUDES)
     find_library(LIBOMP_HWLOC_LIBRARY

And use the created LIBOMP_HWLOC_INCLUDE_DIR here:

  --- a/openmp/runtime/src/CMakeLists.txt
  +++ b/openmp/runtime/src/CMakeLists.txt
  ...
  @@ -157,6 +154,13 @@ else()
     # libomp must be a C++ library such that it can link libLLVMSupport
     set(LIBOMP_LINKER_LANGUAGE CXX)
   endif()
  +if(${LIBOMP_USE_HWLOC})
  +  target_include_directories(omp
  +                             PUBLIC
  +          "$<BUILD_INTERFACE:${LIBOMP_HWLOC_INCLUDE_DIR}>"
  +          "$<INSTALL_INTERFACE:${LIBOMP_HWLOC_INCLUDE_DIR}>"
  +  )
  +endif()
  
   if(OPENMP_MSVC_NAME_SCHEME)
     if(uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")

Exactly as suggested. Thanks @ye-luo for the exact blueprint what to do!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123888/new/

https://reviews.llvm.org/D123888

Files:
  openmp/libompd/src/CMakeLists.txt
  openmp/runtime/cmake/config-ix.cmake
  openmp/runtime/src/CMakeLists.txt


Index: openmp/runtime/src/CMakeLists.txt
===================================================================
--- openmp/runtime/src/CMakeLists.txt
+++ openmp/runtime/src/CMakeLists.txt
@@ -46,9 +46,6 @@
   ${LIBOMP_INC_DIR}
   ${LIBOMP_SRC_DIR}/thirdparty/ittnotify
 )
-if(${LIBOMP_USE_HWLOC})
-  include_directories(${LIBOMP_HWLOC_INSTALL_DIR}/include)
-endif()
 
 # Building with time profiling support requires LLVM directory includes.
 if(LIBOMP_PROFILING_SUPPORT)
@@ -157,6 +154,13 @@
   # libomp must be a C++ library such that it can link libLLVMSupport
   set(LIBOMP_LINKER_LANGUAGE CXX)
 endif()
+if(${LIBOMP_USE_HWLOC})
+  target_include_directories(omp
+                             PUBLIC
+			     "$<BUILD_INTERFACE:${LIBOMP_HWLOC_INCLUDE_DIR}>"
+			     "$<INSTALL_INTERFACE:${LIBOMP_HWLOC_INCLUDE_DIR}>"
+  )
+endif()
 
 if(OPENMP_MSVC_NAME_SCHEME)
   if(uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
Index: openmp/runtime/cmake/config-ix.cmake
===================================================================
--- openmp/runtime/cmake/config-ix.cmake
+++ openmp/runtime/cmake/config-ix.cmake
@@ -333,6 +333,7 @@
 # Check if HWLOC support is available
 if(${LIBOMP_USE_HWLOC})
   set(CMAKE_REQUIRED_INCLUDES ${LIBOMP_HWLOC_INSTALL_DIR}/include)
+  find_path(LIBOMP_HWLOC_INCLUDE_DIR NAMES hwloc.h HINTS ${LIBOMP_HWLOC_INSTALL_DIR} PATH_SUFFIXES include)
   check_include_file(hwloc.h LIBOMP_HAVE_HWLOC_H)
   set(CMAKE_REQUIRED_INCLUDES)
   find_library(LIBOMP_HWLOC_LIBRARY
Index: openmp/libompd/src/CMakeLists.txt
===================================================================
--- openmp/libompd/src/CMakeLists.txt
+++ openmp/libompd/src/CMakeLists.txt
@@ -13,7 +13,7 @@
 
 add_library (ompd SHARED TargetValue.cpp omp-debug.cpp omp-state.cpp omp-icv.cpp)
 
-add_dependencies(ompd omp) # ensure generated import library is created first
+target_link_libraries(ompd omp) # ensure generated import library is created first
 
 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123888.423208.patch
Type: text/x-patch
Size: 2002 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20220416/98724960/attachment.bin>


More information about the Openmp-commits mailing list