Make samples support cmake

Only cmake can support static lib of hip rt.
Thus samples will support static lib of hip
rt when this is done.

Change-Id: I70e8d06e85084369a035b42c5d1d56287c874ac9
This commit is contained in:
Tao Sang
2020-09-01 12:54:32 -04:00
committed by Tao Sang
parent 5bf2a70382
commit 8f72a6993f
23 changed files with 490 additions and 12 deletions
+21
View File
@@ -0,0 +1,21 @@
#Follow "README.md" to generate square.cpp if it's missing
project(square)
cmake_minimum_required(VERSION 3.10)
# Search for rocm in common locations
list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm)
# Find hip
find_package(hip)
# Set compiler and linker
set(CMAKE_CXX_COMPILER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
# Create the excutable
add_executable(square square.cpp)
# Link with HIP
target_link_libraries(square hip::host)
+2 -5
View File
@@ -11,7 +11,7 @@ else
SOURCES=square.cpp
endif
all: square.out square.out.static
all: square.out
# Step
square.cpp: square.cu
@@ -20,8 +20,5 @@ square.cpp: square.cu
square.out: $(SOURCES)
$(HIPCC) $(CXXFLAGS) $(SOURCES) -o $@
square.out.static: $(SOURCES)
$(HIPCC) -use-staticlib $(CXXFLAGS) $(SOURCES) -o $@
clean:
rm -f *.o *.out *.out.static square.cpp
rm -f *.o *.out square.cpp