-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
64 lines (53 loc) · 2.17 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
cmake_minimum_required(VERSION 3.24)
project(cuslines LANGUAGES CUDA CXX VERSION 1.0)
# Build settings
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -Wall -Werror=reorder")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()
if (CMAKE_BUILD_TYPE STREQUAL "Debug" )
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG}")
else()
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE}")
endif()
# CUDA
find_package(CUDAToolkit REQUIRED)
# Set default CUDA compute capabilities if unset
if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
include(FindCUDA/select_compute_arch.cmake)
cuda_select_nvcc_arch_flags(CUDA_ARCH_FLAGS Auto)
set(CMAKE_CUDA_ARCHITECTURES ${CUDA_ARCH_FLAGS})
endif()
message(STATUS "Using CUDA architectures: ${CMAKE_CUDA_ARCHITECTURES}")
# OpenMP
find_package(OpenMP)
if(OPENMP_FOUND)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
# Set OMP runtime based on compiler
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(OMP_RUNTIME "INTEL")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(OMP_RUNTIME "GNU")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
set(OMP_RUNTIME "INTEL")
endif()
message(STATUS "OpenMP runtime used: ${OMP_RUNTIME}")
endif()
# Build library and pybind11 module
add_subdirectory(external/pybind11)
add_library(cuslines_kernels)
target_sources(cuslines_kernels
PRIVATE
${CMAKE_SOURCE_DIR}/cuslines/generate_streamlines_cuda.cu)
set_target_properties(cuslines_kernels PROPERTIES OUTPUT_NAME cuslines_kernels
POSITION_INDEPENDENT_CODE TRUE)
pybind11_add_module(cuslines ${CMAKE_SOURCE_DIR}/cuslines/cuslines.cpp)
target_include_directories(cuslines PUBLIC "${CMAKE_SOURCE_DIR}/cuslines" "${CUDAToolkit_INCLUDE_DIRS}")
target_link_libraries(cuslines PRIVATE cuslines_kernels CUDA::cudart_static)
# Install
install(TARGETS cuslines cuslines_kernels LIBRARY DESTINATION .)