CMakeLists.txt 2.89 KB
Newer Older
Ondrej Mosnáček's avatar
Ondrej Mosnáček committed
1 2 3 4 5 6 7 8 9
cmake_minimum_required(VERSION 2.6)

project(argon2-gpu CXX)
set(BINARY_INSTALL_DIR /usr/local/bin)
set(LIBRARY_INSTALL_DIR /usr/local/lib)
set(INCLUDE_INSTALL_DIR /usr/local/include)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

Ondrej Mosnáček's avatar
Ondrej Mosnáček committed
10
set(CUDA_PROPAGATE_HOST_FLAGS OFF)
11
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};
Ondrej Mosnáček's avatar
Ondrej Mosnáček committed
12
    -std=c++11;-O3;--ptxas-options=-v;-arch sm_30;-lineinfo
13 14
)

Ondrej Mosnáček's avatar
Ondrej Mosnáček committed
15 16
find_package(CUDA REQUIRED)

Ondrej Mosnáček's avatar
Ondrej Mosnáček committed
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
add_library(argon2-gpu-common SHARED
    lib/argon2-gpu-common/argon2params.cpp
    lib/argon2-gpu-common/blake2b.cpp
)
target_include_directories(argon2-gpu-common INTERFACE
    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
    $<INSTALL_INTERFACE:include>
)
target_include_directories(argon2-gpu-common PRIVATE
    include/argon2-gpu-common
    lib/argon2-gpu-common
)

cuda_add_library(argon2-cuda SHARED
    lib/argon2-cuda/device.cpp
    lib/argon2-cuda/globalcontext.cpp
    lib/argon2-cuda/programcontext.cpp
    lib/argon2-cuda/processingunit.cpp
    lib/argon2-cuda/kernels.cu
)
target_include_directories(argon2-cuda INTERFACE
    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
    $<INSTALL_INTERFACE:include>
)
target_include_directories(argon2-cuda PRIVATE
    include/argon2-cuda
    lib/argon2-cuda
)
target_link_libraries(argon2-cuda argon2-gpu-common)

add_library(argon2-opencl SHARED
    lib/argon2-opencl/device.cpp
    lib/argon2-opencl/globalcontext.cpp
    lib/argon2-opencl/kernelloader.cpp
    lib/argon2-opencl/programcontext.cpp
    lib/argon2-opencl/processingunit.cpp
)
target_include_directories(argon2-opencl INTERFACE
    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
    $<INSTALL_INTERFACE:include>
)
target_include_directories(argon2-opencl PRIVATE
    include/argon2-opencl
    lib/argon2-opencl
)
target_link_libraries(argon2-opencl
    argon2-gpu-common -lOpenCL
)

add_executable(argon2-gpu-test src/argon2-gpu-test/main.cpp)
target_include_directories(argon2-gpu-test PRIVATE src/argon2-gpu-test)
target_link_libraries(argon2-gpu-test
    argon2-cuda argon2-opencl -lOpenCL
)

add_executable(argon2-gpu-bench
    src/argon2-gpu-bench/cudaexecutive.cpp
    src/argon2-gpu-bench/openclexecutive.cpp
    src/argon2-gpu-bench/benchmark.cpp
    src/argon2-gpu-bench/main.cpp
)
target_include_directories(argon2-gpu-bench PRIVATE src/argon2-gpu-bench)
target_link_libraries(argon2-gpu-bench
    argon2-cuda argon2-opencl -lOpenCL
)

add_test(test argon2-gpu-test)

install(TARGETS argon2-opencl DESTINATION ${LIBRARY_INSTALL_DIR})
install(FILES
    include/argon2-opencl/cl.hpp
    include/argon2-opencl/opencl.h
    include/argon2-opencl/argon2-common.h
    include/argon2-opencl/argon2params.h
    include/argon2-opencl/device.h
    include/argon2-opencl/globalcontext.h
    include/argon2-opencl/programcontext.h
    include/argon2-opencl/processingunit.h
    DESTINATION ${INCLUDE_INSTALL_DIR}
)
install(TARGETS argon2-gpu-bench argon2-gpu-test DESTINATION ${BINARY_INSTALL_DIR})