-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
130 lines (108 loc) · 4.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
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
# ======================================================================== #
# Copyright 2023-2024 Ingo Wald #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
# you may not use this file except in compliance with the License. #
# You may obtain a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
# ======================================================================== #
cmake_minimum_required(VERSION 3.12)
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.18)
cmake_policy(SET CMP0104 NEW)
endif()
if (WIN32)
# MPI is off by default on windows. whoever wants to use mpi under windows
# probably better know what he's doing, anyway
option(BARNEY_MPI "Enable MPI Support" OFF)
else()
option(BARNEY_MPI "Enable MPI Support" ON)
endif()
if (NOT (${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR}))
set(BARNEY_IS_SUBPROJECT ON)
else()
set(BARNEY_IS_SUBPROJECT OFF)
endif()
set(CMAKE_BUILD_TYPE_INIT "Release")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
#set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug;Release")
#if ((NOT WIN32) AND (NOT CMAKE_BUILD_TYPE) AND (NOT CMAKE_CONFIGURATION_TYPES))
# message(STATUS "Setting build type to 'Release' as none was specified.")
# set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
#if (CMAKE_BUILD_TYPE)
# set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Release" "Debug"
# "MinSizeRel" "RelWithDebInfo")
#endif()
# iw - do NOT use an 'option' - they can't do strings
set(BARNEY_CUDA_ARCHITECTURES "auto" CACHE STRING
"Which CUDA architecture to build for")
if (BARNEY_CUDA_ARCHITECTURES STREQUAL "auto")
if (NOT (DEFINED CMAKE_CUDA_ARCHITECTURES))
# 'all-major', since cmake-3.23
set(BARNEY_CUDA_ARCHITECTURES all-major)
else()
if("${CMAKE_CUDA_ARCHITECTURES}" STREQUAL "52")
# some cmake setups set cuda-archs to '52' if nothing else is
# set - this is almost certainly a default value that one does
# _not_ want to use.
set(BARNEY_CUDA_ARCHITECTURES all-major)
else()
set(BARNEY_CUDA_ARCHITECTURES ${CMAKE_CUDA_ARCHITECTURES})
endif()
endif()
message("#barney: cuda-archs set to auto, selected ${BARNEY_CUDA_ARCHITECTURES}")
else()
message("#barney: explicit cuda archs ${BARNEY_CUDA_ARCHITECTURES} requested by user")
endif()
# project command is required to come after cmake_minimum_required command.
project(Barney VERSION 0.7.0 LANGUAGES C CXX CUDA)
if (CMAKE_BUILD_TYPE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Release" "Debug"
"MinSizeRel" "RelWithDebInfo")
endif()
if (NOT BARNEY_IS_SUBPROJECT)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if (NOT (COMMAND CUDA_SOURCE))
macro(CUDA_SOURCE fileName)
set_source_files_properties(${fileName}
PROPERTIES LANGUAGE CUDA
)
set_source_files_properties(${fileName}
PROPERTIES
CUDA_RESOLVE_DEVICE_SYMBOLS ON
CUDA_ARCHITECTURES ${BARNEY_CUDA_ARCHITECTURES}
)
endmacro()
endif()
# ------------------------------------------------------------------
# subprojects we depend on
# ------------------------------------------------------------------
if (NOT (TARGET owl::owl))
set(OWL_CUDA_STATIC ON)
add_subdirectory(submodules/owl EXCLUDE_FROM_ALL)
endif()
# TODO: add option to find if installed
option(BARNEY_CUBQL_HOST "Use CUBQL host builder" off)
if (NOT (TARGET cuBQL_cuda_float3))
add_subdirectory(submodules/cuBQL EXCLUDE_FROM_ALL)
endif()
# ------------------------------------------------------------------
# barney itself
# ------------------------------------------------------------------
add_subdirectory(barney)
# ------------------------------------------------------------------
# ANARI device
# ------------------------------------------------------------------
add_subdirectory(anari)