Skip to content

Commit 31ffe52

Browse files
committed
Impl #78: Replace deprecated FindCUDA
1 parent 4e3a68a commit 31ffe52

File tree

7 files changed

+44
-62
lines changed

7 files changed

+44
-62
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"ms-vscode.cpptools-extension-pack",
1919
"ms-python.python",
2020
"ms-toolsai.jupyter",
21-
"tamasfe.even-better-toml",
21+
"tamasfe.even-better-toml"
2222
]
2323
}
2424
},

CMakeLists.txt

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
1+
include(CheckLanguage)
2+
13
cmake_minimum_required(VERSION 3.18)
2-
project(Pink VERSION 2.5 LANGUAGES CUDA CXX)
4+
project(Pink VERSION 2.5)
5+
enable_language(CXX)
6+
7+
check_language(CUDA)
8+
if(CMAKE_CUDA_COMPILER)
9+
message(STATUS "CUDA support")
10+
enable_language(CUDA)
11+
else()
12+
message(STATUS "No CUDA support")
13+
endif()
314

415
message(STATUS "${PROJECT_NAME} version ${PROJECT_VERSION}")
516

@@ -119,25 +130,21 @@ if("${isSystemDir}" STREQUAL "-1")
119130
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
120131
endif()
121132

122-
option(USE_CUDA "Use CUDA" ON)
123-
if (USE_CUDA)
124-
find_package(CUDA)
125-
if(CUDA_FOUND)
126-
set(PINK_USE_CUDA true)
127-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPINK_USE_CUDA")
128-
129-
if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
130-
set(CMAKE_CUDA_ARCHITECTURES 75)
131-
endif()
132-
133-
# Set flags for CUDA compiler
134-
list(APPEND CUDA_NVCC_FLAGS "
135-
-std=c++17
136-
--expt-extended-lambda
137-
--expt-relaxed-constexpr
138-
--default-stream per-thread
139-
")
133+
if(CMAKE_CUDA_COMPILER)
134+
set(PINK_USE_CUDA true)
135+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPINK_USE_CUDA")
136+
137+
if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
138+
set(CMAKE_CUDA_ARCHITECTURES 75)
140139
endif()
140+
141+
# Set flags for CUDA compiler
142+
list(APPEND CUDA_NVCC_FLAGS "
143+
-std=c++17
144+
--expt-extended-lambda
145+
--expt-relaxed-constexpr
146+
--default-stream per-thread
147+
")
141148
endif()
142149

143150
set(PYBIND11_PYTHON_VERSION 3)

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ endif()
44

55
add_subdirectory(UtilitiesLib)
66

7-
if(CUDA_FOUND)
7+
if(CMAKE_CUDA_COMPILER)
88
add_subdirectory(CudaLib)
99
endif()
1010

src/CudaLib/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ include_directories(SYSTEM
66
${CUDA_INCLUDE_DIRS}
77
)
88

9-
cuda_add_library(
9+
add_library(
1010
CudaLib
1111
SHARED
1212
CudaLib.cu

src/pink/CMakeLists.txt

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,40 +12,19 @@ include_directories(SYSTEM
1212
${PYTHON_INCLUDE_DIRS}
1313
)
1414

15-
if(PINK_USE_CUDA)
16-
include_directories(
17-
${CUDA_INCLUDE_DIRS}
18-
)
19-
20-
cuda_add_library(
21-
PythonBindingLib
22-
SHARED
23-
DynamicData.cpp
24-
DynamicMapper.cpp
25-
DynamicSOM.cpp
26-
DynamicTrainer.cpp
27-
)
28-
29-
target_link_libraries(
30-
PythonBindingLib
31-
CudaLib
32-
UtilitiesLib
33-
)
34-
else()
35-
add_library(
36-
PythonBindingLib
37-
SHARED
38-
DynamicData.cpp
39-
DynamicMapper.cpp
40-
DynamicSOM.cpp
41-
DynamicTrainer.cpp
42-
)
43-
44-
target_link_libraries(
45-
PythonBindingLib PRIVATE
46-
UtilitiesLib
47-
)
48-
endif()
15+
add_library(
16+
PythonBindingLib
17+
SHARED
18+
DynamicData.cpp
19+
DynamicMapper.cpp
20+
DynamicSOM.cpp
21+
DynamicTrainer.cpp
22+
)
23+
24+
target_link_libraries(
25+
PythonBindingLib PRIVATE
26+
UtilitiesLib
27+
)
4928

5029
pybind11_add_module(
5130
_pink MODULE

test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ add_subdirectory(ImageProcessingTest)
22
add_subdirectory(SelfOrganizingMapTest)
33
add_subdirectory(UtilitiesTest)
44

5-
if(CUDA_FOUND)
5+
if(CMAKE_CUDA_COMPILER)
66
add_subdirectory(CudaTest)
77
endif()
88

test/CudaTest/CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@ include_directories(
22
${PROJECT_SOURCE_DIR}/src
33
)
44

5-
include_directories(SYSTEM
6-
${CUDA_INCLUDE_DIRS}
7-
)
8-
9-
cuda_add_executable(
5+
add_executable(
106
CudaTest
117
circular_ed.cu
128
compare_trainer_3d_cpu.cu

0 commit comments

Comments
 (0)