[Openmp-commits] [openmp] 9ffa945 - [Libomptarget] Remove global include directory from libomptarget

Joseph Huber via Openmp-commits openmp-commits at lists.llvm.org
Fri May 13 11:39:25 PDT 2022


Author: Joseph Huber
Date: 2022-05-13T14:38:47-04:00
New Revision: 9ffa945c401ccd248e1e35fbbccb1860b253b290

URL: https://github.com/llvm/llvm-project/commit/9ffa945c401ccd248e1e35fbbccb1860b253b290
DIFF: https://github.com/llvm/llvm-project/commit/9ffa945c401ccd248e1e35fbbccb1860b253b290.diff

LOG: [Libomptarget] Remove global include directory from libomptarget

We used to globally include the libomptarget include directory for all
projects. This caused some conflicts with the other files named
"Debug.h". This patch changes the cmake to include these files via the
target include instead.

Reviewed By: tianshilei1992

Differential Revision: https://reviews.llvm.org/D125563

Added: 
    

Modified: 
    openmp/libomptarget/CMakeLists.txt
    openmp/libomptarget/plugins/CMakeLists.txt
    openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
    openmp/libomptarget/plugins/common/elf_common/CMakeLists.txt
    openmp/libomptarget/plugins/cuda/CMakeLists.txt
    openmp/libomptarget/plugins/ve/CMakeLists.txt
    openmp/libomptarget/src/CMakeLists.txt
    openmp/libomptarget/tools/deviceinfo/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/CMakeLists.txt b/openmp/libomptarget/CMakeLists.txt
index cd63ce2726d2..ca301c42bbb1 100644
--- a/openmp/libomptarget/CMakeLists.txt
+++ b/openmp/libomptarget/CMakeLists.txt
@@ -70,7 +70,6 @@ if(LIBOMPTARGET_ENABLE_DEBUG)
 endif()
 
 set(LIBOMPTARGET_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
-include_directories(${LIBOMPTARGET_INCLUDE_DIR})
 
 # Build target agnostic offloading library.
 set(LIBOMPTARGET_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)

diff  --git a/openmp/libomptarget/plugins/CMakeLists.txt b/openmp/libomptarget/plugins/CMakeLists.txt
index f48dc3b49b1d..e80799ee2b3a 100644
--- a/openmp/libomptarget/plugins/CMakeLists.txt
+++ b/openmp/libomptarget/plugins/CMakeLists.txt
@@ -24,9 +24,6 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "${tmachine}$")
 
       libomptarget_say("Building ${tmachine_name} offloading plugin.")
 
-      include_directories(${LIBOMPTARGET_DEP_LIBFFI_INCLUDE_DIR})
-      include_directories(${LIBOMPTARGET_DEP_LIBELF_INCLUDE_DIR})
-
       # Define macro to be used as prefix of the runtime messages for this target.
       add_definitions("-DTARGET_NAME=${tmachine_name}")
 
@@ -40,6 +37,11 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "${tmachine}$")
       install(TARGETS "omptarget.rtl.${tmachine_libname}"
         LIBRARY DESTINATION "${OPENMP_INSTALL_LIBDIR}")
 
+      target_include_directories( "omptarget.rtl.${tmachine_libname}" PRIVATE
+        ${LIBOMPTARGET_INCLUDE_DIR}
+        ${LIBOMPTARGET_DEP_LIBFFI_INCLUDE_DIR}
+        ${LIBOMPTARGET_DEP_LIBELF_INCLUDE_DIR})
+
       target_link_libraries(
         "omptarget.rtl.${tmachine_libname}"
         elf_common

diff  --git a/openmp/libomptarget/plugins/amdgpu/CMakeLists.txt b/openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
index b2fc43acf1b7..4088f2d2a4ba 100644
--- a/openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
+++ b/openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
@@ -43,10 +43,6 @@ if(CMAKE_BUILD_TYPE MATCHES Debug)
   add_definitions(-DDEBUG)
 endif()
 
-include_directories(
-  ${CMAKE_CURRENT_SOURCE_DIR}/impl
-)
-
 set(LIBOMPTARGET_DLOPEN_LIBHSA OFF)
 option(LIBOMPTARGET_FORCE_DLOPEN_LIBHSA "Build with dlopened libhsa" ${LIBOMPTARGET_DLOPEN_LIBHSA})
 
@@ -87,6 +83,13 @@ else()
   set(LDFLAGS_UNDEFINED "-Wl,-z,defs")
 endif()
 
+target_include_directories(
+  omptarget.rtl.amdgpu
+  PRIVATE
+  ${LIBOMPTARGET_INCLUDE_DIR}
+  ${CMAKE_CURRENT_SOURCE_DIR}/impl
+)
+
 target_link_libraries(
   omptarget.rtl.amdgpu
   PRIVATE

diff  --git a/openmp/libomptarget/plugins/common/elf_common/CMakeLists.txt b/openmp/libomptarget/plugins/common/elf_common/CMakeLists.txt
index c30edd3864f4..9ea292620f42 100644
--- a/openmp/libomptarget/plugins/common/elf_common/CMakeLists.txt
+++ b/openmp/libomptarget/plugins/common/elf_common/CMakeLists.txt
@@ -27,3 +27,4 @@ target_link_libraries(elf_common INTERFACE ${OPENMP_PTHREAD_LIB})
 
 # Expose elf_common.h directory to the users of this library.
 target_include_directories(elf_common INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
+target_include_directories(elf_common PRIVATE ${LIBOMPTARGET_INCLUDE_DIR})

diff  --git a/openmp/libomptarget/plugins/cuda/CMakeLists.txt b/openmp/libomptarget/plugins/cuda/CMakeLists.txt
index b335efc1f1b0..20b0aff16ae5 100644
--- a/openmp/libomptarget/plugins/cuda/CMakeLists.txt
+++ b/openmp/libomptarget/plugins/cuda/CMakeLists.txt
@@ -29,10 +29,6 @@ libomptarget_say("Building CUDA offloading plugin.")
 # Define the suffix for the runtime messaging dumps.
 add_definitions(-DTARGET_NAME=CUDA)
 
-include_directories(
-  ${LIBOMPTARGET_DEP_LIBELF_INCLUDE_DIRS}
-)
-
 set(LIBOMPTARGET_DLOPEN_LIBCUDA OFF)
 option(LIBOMPTARGET_FORCE_DLOPEN_LIBCUDA "Build with dlopened libcuda" ${LIBOMPTARGET_DLOPEN_LIBCUDA})
 
@@ -57,6 +53,11 @@ add_dependencies(omptarget.rtl.cuda omptarget.devicertl.nvptx)
 # Install plugin under the lib destination folder.
 install(TARGETS omptarget.rtl.cuda LIBRARY DESTINATION "${OPENMP_INSTALL_LIBDIR}")
 
+target_include_directories(omptarget.rtl.cuda PRIVATE
+  ${LIBOMPTARGET_INCLUDE_DIR}
+  ${LIBOMPTARGET_DEP_LIBELF_INCLUDE_DIRS}
+)
+
 target_link_libraries(omptarget.rtl.cuda
   elf_common
   MemoryManager

diff  --git a/openmp/libomptarget/plugins/ve/CMakeLists.txt b/openmp/libomptarget/plugins/ve/CMakeLists.txt
index 16ce0891ca23..1b10af039d98 100644
--- a/openmp/libomptarget/plugins/ve/CMakeLists.txt
+++ b/openmp/libomptarget/plugins/ve/CMakeLists.txt
@@ -17,10 +17,6 @@ if(${LIBOMPTARGET_DEP_VEO_FOUND})
   set(tmachine_triple "ve-unknown-linux-unknown")
   set(elf_machine_id 251)
 
-  include_directories(${LIBOMPTARGET_DEP_LIBELF_INCLUDE_DIR})
-  include_directories(${LIBOMPTARGET_DEP_VEO_INCLUDE_DIR})
-
-
   # Define macro to be used as prefix of the runtime messages for this target.
   add_definitions("-DTARGET_NAME=${tmachine_name}")
 
@@ -34,6 +30,11 @@ if(${LIBOMPTARGET_DEP_VEO_FOUND})
   install(TARGETS "omptarget.rtl.${tmachine_libname}"
     LIBRARY DESTINATION lib${OPENMP_LIBDIR_SUFFIX})
 
+  target_include_directories("omptarget.rtl.${tmachine_libname}" PRIVATE
+    ${LIBOMPTARGET_INCLUDE_DIR}
+    ${LIBOMPTARGET_DEP_LIBELF_INCLUDE_DIR}
+    ${LIBOMPTARGET_DEP_VEO_INCLUDE_DIR})
+
   target_link_libraries(
     "omptarget.rtl.${tmachine_libname}"
     elf_common

diff  --git a/openmp/libomptarget/src/CMakeLists.txt b/openmp/libomptarget/src/CMakeLists.txt
index db5b212c7ae7..3c338b810047 100644
--- a/openmp/libomptarget/src/CMakeLists.txt
+++ b/openmp/libomptarget/src/CMakeLists.txt
@@ -34,6 +34,8 @@ if (OPENMP_ENABLE_LIBOMPTARGET_PROFILING)
   target_compile_definitions(omptarget PUBLIC OMPTARGET_PROFILE_ENABLED)
   target_link_libraries(omptarget PRIVATE LLVMSupport)
 endif()
+target_include_directories(omptarget PRIVATE
+  ${LIBOMPTARGET_INCLUDE_DIR})
 target_link_libraries(omptarget PRIVATE
   ${CMAKE_DL_LIBS}
   "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/exports")

diff  --git a/openmp/libomptarget/tools/deviceinfo/CMakeLists.txt b/openmp/libomptarget/tools/deviceinfo/CMakeLists.txt
index 8f7e95aebd34..290fc8346923 100644
--- a/openmp/libomptarget/tools/deviceinfo/CMakeLists.txt
+++ b/openmp/libomptarget/tools/deviceinfo/CMakeLists.txt
@@ -16,6 +16,9 @@ add_llvm_tool(llvm-omp-device-info llvm-omp-device-info.cpp)
 
 llvm_update_compile_flags(llvm-omp-device-info)
 
+target_include_directories(llvm-omp-device-info PRIVATE
+  ${LIBOMPTARGET_INCLUDE_DIR}
+)
 target_link_libraries(llvm-omp-device-info PRIVATE
   omp
   omptarget


        


More information about the Openmp-commits mailing list