forked from pkestene/pybind11-cuda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
78 lines (62 loc) · 2.74 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
# use cmake version >= 3.12 so that to benefit from
# the new FindPython3 module
# cmake >= 3.18 for modern CUDA support
cmake_minimum_required(VERSION 3.18)
message("Using CMake version ${CMAKE_VERSION}")
if(${CMAKE_VERSION} VERSION_LESS "3.18.0")
message("Using cmake policy CMP0104 OLD")
cmake_policy(SET CMP0104 OLD)
else()
message("Using cmake policy CMP0104 NEW")
cmake_policy(SET CMP0104 NEW)
endif()
project(pybind11-cuda-test LANGUAGES CXX CUDA)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF)
# custom cmake macros location
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cuda")
# Prevent from build in source tree
include(preventBuildInSource)
# Init build type: Release, Debug, ...
include(initBuildType)
# useful for debugging cmake
include(print_target_properties)
# always export compile commands database
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
#-------------------------------------------------------------------#
# Cuda and Python configuration
#-------------------------------------------------------------------#
if(NOT DEFINED CMAKE_CUDA_STANDARD)
set(CMAKE_CUDA_STANDARD 17)
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
endif()
# make sure to find python from conda, if a conda virtual env is activated
set(Python3_FIND_VIRTUALENV "STANDARD")
# Don't use FindPython here, pybind11 takes care of things much better
# we also need extra stuff to make sure compile flags are correctly
# passed to nvcc / host compiler
include(protect_nvcc_flags)
include(protect_pthread_flag)
#-------------------------------------------------------------------#
# build some Cuda library
#-------------------------------------------------------------------#
add_subdirectory(src)
#-------------------------------------------------------------------#
# Configuration summary
#-------------------------------------------------------------------#
message("//===================================================")
message(" ${PROJECT_NAME} build configuration:")
message("//===================================================")
message(" CUDA compiler ID : ${CMAKE_CUDA_COMPILER_ID}")
message(" CUDA compiler Version : ${CMAKE_CUDA_COMPILER_VERSION}")
message(" C++ Compiler : ${CMAKE_CXX_COMPILER_ID} "
"${CMAKE_CXX_COMPILER_VERSION} "
"${CMAKE_CXX_COMPILER_WRAPPER}")
message(" ${CMAKE_CXX_COMPILER}")
message(" C++ Compiler flags : ${CMAKE_CXX_FLAGS}")
message(" CUDA Compiler : ${CMAKE_CUDA_COMPILER}")
message(" CUDA Compiler exec : ${CUDA_NVCC_EXECUTABLE}")
message(" CUDA Compile flags : ${CMAKE_CUDA_FLAGS}")
message(" CUDA toolkit inc : ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}")
message(" CUDA arch targets : ${CMAKE_CUDA_ARCHITECTURES}")