forked from isl-org/Open3D
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
90 lines (81 loc) · 4.49 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
function(open3d_show_and_abort_on_warning trgt)
set(DISABLE_MSVC_WARNINGS
/Wv:18 # ignore warnings introduced in Visual Studio 2015 and later.
/wd4201 # non-standard extension nameless struct (filament includes)
/wd4310 # cast truncates const value (filament)
/wd4505 # unreferenced local function has been removed (dirent)
/wd4127 # conditional expression is const (Eigen)
/wd4146 # unary minus operator applied to unsigned type, result still unsigned (UnaryEWCPU)
/wd4189 # local variable is initialized but not referenced (PoissonRecon)
/wd4324 # structure was padded due to alignment specifier (qhull)
/wd4706 # assignment within conditional expression (fileIO, ...)
/wd4100 # unreferenced parameter (many places in Open3D code)
/wd4702 # unreachable code (many places in Open3D code)
/wd4244 # implicit data type conversion (many places in Open3D code)
/wd4245 # signed/unsigned mismatch (visualization, PoissonRecon, ...)
/wd4267 # conversion from size_t to smaller type (FixedRadiusSearchCUDA, tests)
/wd4305 # conversion to smaller type in initialization or constructor argument (examples, tests)
)
set(DISABLE_GNU_CLANG_INTEL_WARNINGS
-Wno-unused-parameter # (many places in Open3D code)
)
if (BUILD_CUDA_MODULE)
# General NVCC flags
set(DISABLE_NVCC_WARNINGS
2809 # ignoring return value from routine declared with "nodiscard" attribute (cub)
)
string(REPLACE ";" "," DISABLE_NVCC_WARNINGS "${DISABLE_NVCC_WARNINGS}")
set(CUDA_FLAGS "--Werror cross-execution-space-call,deprecated-declarations")
if (CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL "10.2")
string(APPEND CUDA_FLAGS " --Werror all-warnings")
endif()
if (CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL "11.0")
string(APPEND CUDA_FLAGS " --Werror ext-lambda-captures-this")
endif()
string(APPEND CUDA_FLAGS " --expt-relaxed-constexpr")
if (CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL "11.2")
string(APPEND CUDA_FLAGS " --diag-suppress ${DISABLE_NVCC_WARNINGS}")
else()
string(APPEND CUDA_FLAGS " -Xcudafe --diag_suppress=[${DISABLE_NVCC_WARNINGS}]")
endif()
# Host compiler flags
if (MSVC)
set(CUDA_DISABLE_MSVC_WARNINGS ${DISABLE_MSVC_WARNINGS})
if (CMAKE_CUDA_COMPILER_VERSION VERSION_LESS "11.2")
list(APPEND CUDA_DISABLE_MSVC_WARNINGS $<$<CONFIG:Debug>:/wd4700>) # uninitialized local variable used (thrust)
endif()
if (CMAKE_CUDA_COMPILER_VERSION VERSION_LESS "11.1")
list(APPEND CUDA_DISABLE_MSVC_WARNINGS /wd4515) # namespace uses itself (thrust)
endif()
string(REPLACE ";" "," CUDA_DISABLE_MSVC_WARNINGS "${CUDA_DISABLE_MSVC_WARNINGS}")
string(APPEND CUDA_FLAGS " -Xcompiler /W4,/WX,${CUDA_DISABLE_MSVC_WARNINGS}")
else()
# reorder breaks builds on Windows, so only enable for other platforms
string(APPEND CUDA_FLAGS " --Werror reorder")
set(CUDA_DISABLE_GNU_CLANG_INTEL_WARNINGS ${DISABLE_GNU_CLANG_INTEL_WARNINGS})
string(REPLACE ";" "," CUDA_DISABLE_GNU_CLANG_INTEL_WARNINGS "${CUDA_DISABLE_GNU_CLANG_INTEL_WARNINGS}")
string(APPEND CUDA_FLAGS " -Xcompiler -Wall,-Wextra,-Werror,${CUDA_DISABLE_GNU_CLANG_INTEL_WARNINGS}")
endif()
else()
set(CUDA_FLAGS "")
endif()
target_compile_options(${trgt} PRIVATE
$<$<COMPILE_LANG_AND_ID:C,MSVC>:/W4 /WX ${DISABLE_MSVC_WARNINGS}>
$<$<COMPILE_LANG_AND_ID:C,GNU,Clang,AppleClang,Intel>:-Wall -Wextra -Werror ${DISABLE_GNU_CLANG_INTEL_WARNINGS}>
$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/W4 /WX ${DISABLE_MSVC_WARNINGS}>
$<$<COMPILE_LANG_AND_ID:CXX,GNU,Clang,AppleClang,Intel>:-Wall -Wextra -Werror ${DISABLE_GNU_CLANG_INTEL_WARNINGS}>
$<$<COMPILE_LANGUAGE:CUDA>:SHELL:${CUDA_FLAGS}>
)
endfunction()
add_subdirectory(open3d)
add_subdirectory(tools)
add_subdirectory(apps)
if (BUILD_UNIT_TESTS)
add_subdirectory(tests)
endif()
if (BUILD_BENCHMARKS)
add_subdirectory(benchmarks)
endif()
if (BUILD_PYTHON_MODULE)
add_subdirectory(pybind)
endif()