forked from NVIDIA/CUDALibrarySamples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
87 lines (74 loc) · 2.71 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
#
# Copyright (c) 2020 - 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
cmake_minimum_required(VERSION 3.18 FATAL_ERROR)
# ---[ Project specIFication.
set(PROJECT_NAME nvTIFFDecodeEncode)
project(${PROJECT_NAME} LANGUAGES CUDA CXX)
include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/common_example.cmake)
# Find nvTIFF lirary
if(NOT DEFINED NVTIFF_PATH)
message(FATAL_ERROR "NVTIFF_PATH not set")
endif()
message(STATUS "Looking for nvTIFF in ${NVTIFF_PATH}")
find_file(NVTIFF_INCLUDE_FILE
NAMES nvTiff.h
PATHS "${NVTIFF_PATH}/include"
NO_DEFAULT_PATH
)
if (NOT NVTIFF_INCLUDE_FILE)
message(FATAL_ERROR "Could not find nvTIFF in path specified by NVTIFF_PATH=${NVTIFF_PATH}")
endif()
set(NVTIFF_ROOT_DIR ${NVTIFF_PATH})
set(NVTIFF_INCLUDE_DIR "${NVTIFF_PATH}/include")
find_library(CUDA_nvtiff_LIBRARY
NAMES nvtiff
HINTS ${NVTIFF_ROOT_DIR}
PATH_SUFFIXES lib64 lib
)
if (WIN32)
find_file(CUDA_nvtiff_0_dll_LIBRARY
NAMES nvtiff_0.dll
PATHS ${NVTIFF_ROOT_DIR}
PATH_SUFFIXES lib64 lib
NO_DEFAULT_PATH
)
endif()
if (CUDA_nvtiff_LIBRARY)
get_filename_component(NVTIFF_LIBRARY_DIR ${CUDA_nvtiff_LIBRARY} DIRECTORY ABSOLUTE)
get_filename_component(NVTIFF_LIBRARY_NAME ${CUDA_nvtiff_LIBRARY} NAME)
message(STATUS "Found CUDA::nvtiff")
add_library(CUDA::nvtiff SHARED IMPORTED)
target_include_directories(CUDA::nvtiff SYSTEM INTERFACE "${NVTIFF_INCLUDE_DIR}")
target_link_directories(CUDA::nvtiff INTERFACE "${NVTIFF_LIBRARY_DIR}")
set_target_properties(CUDA::nvtiff
PROPERTIES
IMPORTED_LOCATION "${CUDA_nvtiff_LIBRARY}"
INTERFACE_LINK_LIBRARIES "${NVTIFF_LIBRARY_NAME}"
)
if (CUDA_nvtiff_0_dll_LIBRARY)
set_target_properties(CUDA::nvtiff
PROPERTIES
IMPORTED_LOCATION ${CUDA_nvtiff_0_dll_LIBRARY}
IMPORTED_IMPLIB "${CUDA_nvtiff_LIBRARY}"
INTERFACE_LINK_LIBRARIES "${NVTIFF_LIBRARY_NAME}"
)
endif()
endif()
# c++14 is requiered for stdc++fs
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CUDA_STANDARD 14)
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
set(CMAKE_CUDA_EXTENSIONS OFF)
if (UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
endif()
add_nvtiff_example(nvtiff-examples ${PROJECT_NAME} "nvtiff_example.cu;nvTiff_utils.cpp")