Skip to content

Commit 91ccd82

Browse files
committed
[Clang][OpenMP] libompd: get libomp hwloc includedir by target_link_libraries
When hwloc is used and is installed outside of the default paths, the omp CMake target needs to provide the needed include path thru the CMake target by adding it with target_include_directories to it, so libompd gets it as well when it defines it's cmake target using target_link_libraries. As suggested in D122667 Reviewed By: ye-luo Differential Revision: https://reviews.llvm.org/D123888
1 parent 4b4437c commit 91ccd82

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

openmp/libompd/src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ cmake_minimum_required(VERSION 3.13.4)
1313

1414
add_library (ompd SHARED TargetValue.cpp omp-debug.cpp omp-state.cpp omp-icv.cpp)
1515

16-
add_dependencies(ompd omp) # ensure generated import library is created first
16+
target_link_libraries(ompd omp) # ensure generated import library is created first
1717

1818
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
1919

openmp/runtime/cmake/config-ix.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,8 @@ endif()
332332

333333
# Check if HWLOC support is available
334334
if(${LIBOMP_USE_HWLOC})
335-
set(CMAKE_REQUIRED_INCLUDES ${LIBOMP_HWLOC_INSTALL_DIR}/include)
335+
find_path(LIBOMP_HWLOC_INCLUDE_DIR NAMES hwloc.h HINTS ${LIBOMP_HWLOC_INSTALL_DIR} PATH_SUFFIXES include)
336+
set(CMAKE_REQUIRED_INCLUDES ${LIBOMP_HWLOC_INCLUDE_DIR})
336337
check_include_file(hwloc.h LIBOMP_HAVE_HWLOC_H)
337338
set(CMAKE_REQUIRED_INCLUDES)
338339
find_library(LIBOMP_HWLOC_LIBRARY

openmp/runtime/src/CMakeLists.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ include_directories(
4646
${LIBOMP_INC_DIR}
4747
${LIBOMP_SRC_DIR}/thirdparty/ittnotify
4848
)
49-
if(${LIBOMP_USE_HWLOC})
50-
include_directories(${LIBOMP_HWLOC_INSTALL_DIR}/include)
51-
endif()
5249

5350
# Building with time profiling support requires LLVM directory includes.
5451
if(LIBOMP_PROFILING_SUPPORT)
@@ -157,6 +154,13 @@ else()
157154
# libomp must be a C++ library such that it can link libLLVMSupport
158155
set(LIBOMP_LINKER_LANGUAGE CXX)
159156
endif()
157+
if(${LIBOMP_USE_HWLOC})
158+
target_include_directories(omp
159+
PUBLIC
160+
"$<BUILD_INTERFACE:${LIBOMP_HWLOC_INCLUDE_DIR}>"
161+
"$<INSTALL_INTERFACE:${LIBOMP_HWLOC_INCLUDE_DIR}>"
162+
)
163+
endif()
160164

161165
if(OPENMP_MSVC_NAME_SCHEME)
162166
if(uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")

0 commit comments

Comments
 (0)