forked from NVIDIA/CUDALibrarySamples
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
151 lines (121 loc) · 5.36 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#
# Copyright 2020-2024 NVIDIA Corporation And Affiliates. 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.
#
# ---[ Check cmake version.
CMAKE_MINIMUM_REQUIRED(VERSION 3.10.0 FATAL_ERROR)
INCLUDE(GNUInstallDirs)
# ---[ Project specIFication.
SET(PROJECT_NAME findContour)
PROJECT(${PROJECT_NAME} LANGUAGES CUDA CXX)
find_package(CUDAToolkit REQUIRED)
#export NPP_PLUS_PATH=/usr/lib/x86_64-linux-gnu/libnpp_plus/12
#export NPP_PLUS_INCLUDE_DIR=/usr/include/libnpp_plus/12
#cmake .. -DNPP_PLUS_PATH=/usr/lib/x86_64-linux-gnu
add_definitions(-DNPP_PLUS_ON)
find_library(NPP_PLUS_IF_LIBRARY
NAMES npp_plus_if
PATHS ${NPP_PLUS_PATH}/12)
if(NOT NPP_PLUS_IF_LIBRARY)
message(FATAL_ERROR, " NPP_PLUS_IF_LIBRARY library not found. Make sure the library is installed. If using the tar.xz/zip packages set -DNPP_PLUS_PATH")
else()
message(INFO, " NPP_PLUS_IF_LIBRARY library found here: ${NPP_PLUS_IF_LIBRARY}")
endif()
find_library(NPP_PLUS_C_LIBRARY
NAMES npp_plus_c
PATHS ${NPP_PLUS_PATH}/12)
if(NOT NPP_PLUS_C_LIBRARY)
message(FATAL_ERROR, " NPP_PLUS_IF_LIBRARY library not found. Make sure the library is installed. If using the tar.xz/zip packages set -DNPP_PLUS_PATH")
else()
message(INFO, " NPP_PLUS_C_LIBRARY library found here: ${NPP_PLUS_C_LIBRARY}")
endif()
find_library(NPP_PLUS_ISU_LIBRARY
NAMES npp_plus_isu
PATHS ${NPP_PLUS_PATH}/12)
if(NOT NPP_PLUS_ISU_LIBRARY)
message(FATAL_ERROR, " NPP_PLUS_IF_LIBRARY library not found. Make sure the library is installed. If using the tar.xz/zip packages set -DNPP_PLUS_PATH")
else()
message(INFO, " NPP_PLUS_ISU_LIBRARY library found here: ${NPP_PLUS_ISU_LIBRARY}")
endif()
find_path(NPP_HEADER_PATH
NAMES npp.h
PATHS /usr/include/libnpp_plus/12
)
if (NPP_HEADER_PATH)
message(STATUS "Found npp.h in: ${NPP_HEADER_PATH}")
else()
message(FATAL_ERROR "Could not find npp.h")
endif()
find_path(NPP_PLUS_HEADER_PATH
NAMES nppPlus.h
PATHS /usr/local/include /usr/include /usr/include/nppPlus
)
if (NPP_PLUS_HEADER_PATH)
message(STATUS "Found nppPlus.h in: ${NPP_PLUS_HEADER_PATH}")
else()
message(FATAL_ERROR "Could not find nppPlus.h")
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CUDA_STANDARD 17)
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
set(CMAKE_CUDA_EXTENSIONS OFF)
include_directories(
${NPP_HEADER_PATH}
${NPP_PLUS_HEADER_PATH}
SYSTEM ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
link_directories(${CMAKE_CUDA_INCLUDE_DIRS})
if (UNIX)
find_library(CUDART_LIBRARY cudart ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
find_library(NPP_PLUS_IF_LIBRARY npp_plus_if ${NPP_PLUS_LIB})
find_library(NPP_PLUS_C_LIBRARY npp_plus_c ${NPP_PLUS_LIB})
find_library(NPP_PLUS_ISU_LIBRARY npp_plus_isu ${NPP_PLUS_LIB})
find_library(CULIBOS culibos ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
endif (UNIX)
if (MSVC OR WIN32 OR MSYS)
MESSAGE( STATUS "CMAKE_CUDA_COMPILER: " ${CMAKE_CUDA_COMPILER} )
set(CUDA_LIBRARY_PATH "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.6/lib/x64")
set(CUDART_LIBRARY ${CUDA_LIBRARY_PATH}/cudart.lib)
set(NPP_PLUS_IF_LIBRARY ${NPP_PLUS_LIB}/npp_plus_if.lib)
set(NPP_PLUS_C_LIBRARY ${NPP_PLUS_LIB}/npp_plus_c.lib)
set(NPP_PLUS_ISU_LIBRARY ${NPP_PLUS_LIB}/npp_plus_isu.lib)
set(CULIBOS ${CUDA_LIBRARY_PATH}/culibos.lib)
endif()
PROJECT(${PROJECT_NAME} C CXX CUDA)
# ---[ Use the default installation path if not set.
IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
SET(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR} CACHE PATH "" FORCE)
ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
# ---[ Build type
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Develop)
ENDIF(NOT CMAKE_BUILD_TYPE)
SET(EXAMPLES_DESCRIPTOR_SOURCES "findContourNPPPlus.cpp")
ADD_EXECUTABLE(${PROJECT_NAME} ${EXAMPLES_DESCRIPTOR_SOURCES})
SET_SOURCE_FILES_PROPERTIES(${EXAMPLES_DESCRIPTOR_SOURCES} PROPERTIES LANGUAGE CUDA)
TARGET_COMPILE_FEATURES(${PROJECT_NAME} PUBLIC cxx_std_11)
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES CUDA_SEPERABLE_COMPILATION ON)
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} PRIVATE ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} PRIVATE ${NPP_HEADER_PATH})
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} PRIVATE ${NPP_PLUS_HEADER_PATH})
if (UNIX)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} PUBLIC ${CUDART_LIBRARY} ${NPP_PLUS_IF_LIBRARY} ${NPP_PLUS_C_LIBRARY} ${NPP_PLUS_ISU_LIBRARY} ${CULIBOS})
endif (UNIX)
if(MSVC OR WIN32 OR MSYS)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} PUBLIC ${CUDART_LIBRARY} ${NPP_PLUS_IF_LIBRARY} ${NPP_PLUS_C_LIBRARY} ${NPP_PLUS_ISU_LIBRARY} ${CULIBOS})
endif(MSVC OR WIN32 OR MSYS)
if(APPLE)
# We need to add the path to the driver (libcuda.dylib) as an rpath,
# so that the static cuda runtime can find it at runtime.
set_property(TARGET ${PROJECT_NAME}
PROPERTY
BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
endif(APPLE)
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)