forked from ROCm/HIPCC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
135 lines (114 loc) · 4.35 KB
/
CMakeLists.txt
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
cmake_minimum_required(VERSION 3.13.4)
project(hipcc VERSION "1.0.0" LANGUAGES C CXX)
set(hipcc_NAME "${PROJECT_NAME}")
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
find_package(ROCM QUIET)
if(ROCM_FOUND)
include(ROCMSetupVersion)
rocm_setup_version(VERSION "${hipcc_VERSION}")
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(ADDITIONAL_SHARED_LIBRARIES_TO_LINK
libstdc++fs.so)
set(HIPCC_BIN
hipcc.bin)
set(HIPCC_SOURCES
src/hipBin.cpp)
set(HIPCONFIG_BIN
hipconfig.bin)
set(HIPCONFIG_SOURCES
src/hipBin.cpp)
add_executable(${HIPCC_BIN} ${HIPCC_SOURCES})
if(NOT WIN32)
# C++17 does not require std lib linking.
target_link_libraries(${HIPCC_BIN} ${ADDITIONAL_SHARED_LIBRARIES_TO_LINK})
endif()
add_executable(${HIPCONFIG_BIN} ${HIPCONFIG_SOURCES})
if(NOT WIN32)
# C++17 does not require std lib linking.
target_link_libraries(${HIPCONFIG_BIN} ${ADDITIONAL_SHARED_LIBRARIES_TO_LINK})
endif()
# Copy scripts and batch files to build directory.
file(COPY ${PROJECT_SOURCE_DIR}/bin/ DESTINATION ${PROJECT_BINARY_DIR})
set(CPACK_GENERATOR "DEB;RPM;ZIP" CACHE STRING "Default packaging generators")
set(CPACK_PACKAGE_CONTACT "ROCm Compiler Support <[email protected]>")
set(CPACK_PACKAGE_DESCRIPTION "HIP Compiler Driver")
set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
set(CPACK_PACKAGE_VENDOR "Advanced Micro Devices, Inc.")
set(CPACK_PACKAGE_VERSION_MAJOR "${hipcc_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${hipcc_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${hipcc_VERSION_PATCH}")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt")
# Debian-specific packaging variables.
set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "perl (>= 5.0), hip-dev, rocm-core, rocm-llvm")
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/ROCm-Developer-Tools/HIPCC")
if(DEFINED ENV{CPACK_DEBIAN_PACKAGE_RELEASE})
set(CPACK_DEBIAN_PACKAGE_RELEASE $ENV{CPACK_DEBIAN_PACKAGE_RELEASE})
else()
set(CPACK_DEBIAN_PACKAGE_RELEASE "local")
endif()
# RPM-specific packaging variables.
set(CPACK_RPM_FILE_NAME "RPM-DEFAULT")
set(CPACK_RPM_PACKAGE_LICENSE "MIT")
set(CPACK_RPM_PACKAGE_REQUIRES "perl >= 5.0, hip-devel, rocm-core, rocm-llvm")
set(CPACK_RPM_PACKAGE_AUTOREQPROV 0)
if(DEFINED ENV{CPACK_RPM_PACKAGE_RELEASE})
set(CPACK_RPM_PACKAGE_RELEASE $ENV{CPACK_RPM_PACKAGE_RELEASE})
else()
set(CPACK_RPM_PACKAGE_RELEASE "local")
endif()
if(CPACK_RPM_PACKAGE_RELEASE)
set(CPACK_RPM_PACKAGE_RELEASE_DIST ON)
endif()
# ROCM versioning.
set(ROCM_VERSION_FOR_PACKAGE "")
if(DEFINED ENV{ROCM_LIBPATCH_VERSION})
set(ROCM_VERSION_FOR_PACKAGE $ENV{ROCM_LIBPATCH_VERSION})
elseif(DEFINED ENV{ROCM_VERSION})
string(REGEX REPLACE "." "" ROCM_VERSION_FOR_PACKAGE $ENV{ROCM_VERSION})
else()
set(ROCM_VERSION_FOR_PACKAGE "99999")
endif()
set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}.${ROCM_VERSION_FOR_PACKAGE}")
# Exclude Windows specific BAT scripts from install/packaging for Linux.
if (NOT WIN32)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin
DESTINATION .
USE_SOURCE_PERMISSIONS
DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
FILES_MATCHING
PATTERN "*"
PATTERN "*.bat" EXCLUDE)
else ()
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin
DESTINATION .
USE_SOURCE_PERMISSIONS
DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
endif()
install(FILES
"LICENSE.txt"
"README.md"
COMPONENT ${hipcc_NAME}
DESTINATION ${CMAKE_INSTALL_DOCDIR})
install(TARGETS ${HIPCC_BIN}
COMPONENT ${hipcc_NAME}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(TARGETS ${HIPCONFIG_BIN}
COMPONENT ${hipcc_NAME}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
# TODO: WIN32 check need to be removed if backward
# compatibility is required for WIN32.
option(HIPCC_BACKWARD_COMPATIBILITY "Enable HIPCC backward compatibility" ON)
if(NOT WIN32)
if(HIPCC_BACKWARD_COMPATIBILITY)
include(hipcc-backward-compat.cmake)
endif()
endif()
if(NOT ROCM_DEP_ROCMCORE)
string(REGEX REPLACE ",? ?rocm-core" "" CPACK_DEBIAN_PACKAGE_DEPENDS ${CPACK_DEBIAN_PACKAGE_DEPENDS})
string(REGEX REPLACE ",? ?rocm-core" "" CPACK_RPM_PACKAGE_REQUIRES ${CPACK_RPM_PACKAGE_REQUIRES})
endif()
include(CPack)