File: CMakeLists.txt

package info (click to toggle)
pytorch-cuda 2.6.0%2Bdfsg-7
  • links: PTS, VCS
  • area: contrib
  • in suites: forky, sid, trixie
  • size: 161,620 kB
  • sloc: python: 1,278,832; cpp: 900,322; ansic: 82,710; asm: 7,754; java: 3,363; sh: 2,811; javascript: 2,443; makefile: 597; ruby: 195; xml: 84; objc: 68
file content (69 lines) | stat: -rw-r--r-- 2,449 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Build file for the C10 HIP.  This directory doesn't actually contain
# any files; these files are copied over by the HIPIFY script in tools/amd_build
#
# At the moment, this cmake is NOT standalone

include(../../cmake/public/utils.cmake)

if(BUILD_LIBTORCHLESS)
  find_library(C10_HIP_LIB c10_hip PATHS $ENV{LIBTORCH_LIB_PATH} NO_DEFAULT_PATH)
endif()

# ---[ Configure macro file.
set(C10_HIP_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}) # used in cmake_macros.h.in
configure_file(
    ${CMAKE_CURRENT_LIST_DIR}/impl/hip_cmake_macros.h.in
    ${CMAKE_BINARY_DIR}/c10/hip/impl/hip_cmake_macros.h)

# NB: All previous cu files are renamed into cc files.  This isn't tested at the
# moment.
file(GLOB C10_HIP_SRCS
        *.cpp
        *.cc
        impl/*.cpp
        impl/*.cc
        )

# Mark the cc files as HIP files, so we call the compiler.  (They have to be
# suffixed with cc, because the hcc compiler won't accept them otherwise.)
file(GLOB __c10_hip_srcs_cpp *.cc impl/*.cc)
set_source_files_properties(${__c10_hip_srcs_cpp} PROPERTIES HIP_SOURCE_PROPERTY_FORMAT 1)

file(GLOB_RECURSE C10_HIP_HEADERS *.h)

if(NOT BUILD_LIBTORCHLESS)
  hip_add_library(c10_hip ${C10_HIP_SRCS} ${C10_HIP_HEADERS})

  # Propagate HIP_CXX_FLAGS that were set from Dependencies.cmake
  target_compile_options(c10_hip PRIVATE ${HIP_CXX_FLAGS})

  # caffe2_hip adds a bunch of dependencies like rocsparse, but c10/hip is supposed to be
  # minimal.  I'm not sure if we need hip_hcc or not; for now leave it out

  # If building shared library, set dllimport/dllexport proper.
  target_compile_options(c10_hip PRIVATE "-DC10_HIP_BUILD_MAIN_LIB")
  # Enable hidden visibility if compiler supports it.
  if(${COMPILER_SUPPORTS_HIDDEN_VISIBILITY})
    target_compile_options(c10_hip PRIVATE "-fvisibility=hidden")
  endif()

  # ---[ Dependency of c10_hip
  target_link_libraries(c10_hip PUBLIC ${C10_LIB} hip::amdhip64)

  target_include_directories(
      c10_hip PUBLIC
      $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../..>
      $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}>
      $<INSTALL_INTERFACE:include>)
  install(TARGETS c10_hip EXPORT Caffe2Targets DESTINATION lib)
  set(C10_HIP_LIB c10_hip)
endif()

add_subdirectory(test)

# ---[ Installation
install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
        DESTINATION include
        FILES_MATCHING PATTERN "*.h")
install(FILES ${CMAKE_BINARY_DIR}/c10/hip/impl/hip_cmake_macros.h
  DESTINATION include/c10/hip/impl)