forked from hakarlss/Voxelizer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
120 lines (93 loc) · 4.23 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
cmake_minimum_required( VERSION 2.8 )
set(CMAKE_CUDA_COMPILER_WORKS 1) # to ignore mismatched system gcc
project( Voxelizer CXX CUDA)
# Prints more information about the compilation process.
set( CMAKE_VERBOSE_MAKEFILE ON )
# Set the C++ standard to 11 and disable Boost auto-link for the system libarary
# Both seem to be needed to link against the Anaconda Boost library
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBOOST_SYSTEM_NO_LIB -std=gnu++11 -fPIC")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -DBOOST_SYSTEM_NO_LIB -Xcompiler -std=gnu++11 -Xcompiler -fPIC")
if(NOT "$ENV{CONDA_PREFIX}" STREQUAL "")
# have nvcc use the default c++ compiler, if defined
set(CMAKE_CUDA_FLAGS " -ccbin $ENV{CXX} ${CMAKE_CUDA_FLAGS}")
endif()
# Collect all relevant files to be sent to the compilers.
# Also includes these files into the project for easy access.
# If new files are added, the project files need to be regenerated with cmake.
file( GLOB SOURCE_FILES . src/*.cpp src/*.cu )
file( GLOB HEADER_FILES . include/*.h )
# Limits the configuration types available. Doesn't seem to work, though...
set( CMAKE_CONFIGURATION_TYPES Release Debug )
if ( UNIX )
#option( CMAKE_BUILD_SHARED_LIBS "Choose to build either shared or static libraries." OFF )
set( CMAKE_BUILD_TYPE Release CACHE STRING "Build type (Debug/Release) for single-configuration build systems." )
endif ()
# Boost options.
set( Boost_USE_STATIC_LIBS ON )
set( Boost_USE_MULTITHREADED ON )
set( Boost_USE_STATIC_RUNTIME OFF )
# Require Boost >= 1.53 with system and thread components.
find_package( Boost 1.53 REQUIRED COMPONENTS system thread date_time )
# If boost cannot be found, make a cache variable that allows the user to
# specify the Boost root directory where the libraries and includes are found.
if ( Boost_FOUND )
include_directories( ${Boost_INCLUDE_DIRS} )
else ()
set( BOOST_ROOT "" CACHE PATH "Path to Boost root directory." )
endif ()
# CUDA 5.0 doesn't support gcc 4.7 and above.
if ( UNIX AND (CUDA_VERSION VERSION_LESS "5.5") )
if ( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
if ( NOT (CMAKE_COMPILER_VERSION VERSION_LESS "4.7") )
message( FATAL_ERROR "For CUDA 5.5, gcc/g++ needs to be < 4.7" )
endif()
endif()
endif ()
# CUDA 5.5 doesn't support gcc 4.8 and above.
if( UNIX AND (CUDA_VERSION VERSION_EQUAL "5.5") )
if ( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
if ( NOT (CMAKE_COMPILER_VERSION VERSION_LESS "4.8") )
message( FATAL_ERROR "For CUDA 5.5, gcc/g++ needs to be < 4.8" )
endif()
endif()
endif()
option( GENERATE_DOXYGEN_DOCS "Enables or disables the generation of documentation with Doxygen." OFF )
option( GENERATE_TESTS "Adds the compilation of a test program as a target." OFF )
# Configuration-dependent settings.
set( CMAKE_DEBUG_POSTFIX "_d" )
# Set CUDA architecture
cmake_policy(SET CMP0104 OLD)
if(CUDA_GENCODE)
set(CUDA_NVCC_FLAGS_RELEASE "${CMAKE_CUDA_FLAGS} -gencode ${CUDA_GENCODE}")
set(CUDA_NVCC_FLAGS_DEBUG "${CMAKE_CUDA_FLAGS} -gencode ${CUDA_GENCODE}")
else()
set( CUDA_NVCC_FLAGS_RELEASE ${CUDA_NVCC_FLAGS_RELEASE};
-gencode arch=compute_80,code=sm_60
-gencode arch=compute_70,code=sm_60
-gencode arch=compute_61,code=sm_61
-gencode arch=compute_60,code=sm_60
-gencode arch=compute_52,code=sm_52
)
set( CUDA_NVCC_FLAGS_DEBUG ${CUDA_NVCC_FLAGS_DEBUG};
-gencode arch=compute_80,code=sm_60
-gencode arch=compute_70,code=sm_60
-gencode arch=compute_61,code=sm_61
-gencode arch=compute_60,code=sm_60
-gencode arch=compute_52,code=sm_52
)
endif()
# Unix-specific compiler flags.
if ( UNIX )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w -m64 -std=gnu++11 -fPIC" )
endif ()
#message( STATUS "R Flags: ${CMAKE_CXX_FLAGS_RELEASE}" )
# Include files from the subdirectories and process the CMakeLists.txt in those
# directories.
include_directories( include )
add_subdirectory( src )
if ( GENERATE_DOXYGEN_DOCS )
add_subdirectory( doc )
endif ()
if ( GENERATE_TESTS )
add_subdirectory( tests )
endif ()