-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
100 lines (81 loc) · 2.95 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
cmake_minimum_required (VERSION 2.6)
project (odlcuda)
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/odl_cpp_utils/CMakeLists.txt")
message(FATAL_ERROR "odl_cpp_utils not initialized. Run 'git submodule update --init'." )
endif()
#Set binary dir
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
# add cmake find modules
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
# Use folders in MSVC
set_property(GLOBAL PROPERTY USE_FOLDERS true)
# Create clang compile for YouCompleteMe
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Add cuda
option(CUDA_ENABLED "Enable CUDA" TRUE)
if(CUDA_ENABLED)
find_package(CUDA QUIET REQUIRED)
set(ODL_CUDA_COMPUTE "52" CACHE STRING "Cuda compute capability to compile for")
# Pass options to NVCC
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};-gencode arch=compute_${ODL_CUDA_COMPUTE},code=sm_${ODL_CUDA_COMPUTE})
# Enable fast math
option(ODL_CUDA_USE_FAST_MATH "Enable fast math in cuda (can decrease precision)" TRUE)
if(ODL_CUDA_USE_FAST_MATH)
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};-use_fast_math)
endif()
# Enable fast math
option(ODL_CUDA_COMPILE_ALL_TYPES "Enable compilation of all types in cuda, disable for quicker builds" TRUE)
if(ODL_CUDA_COMPILE_ALL_TYPES)
add_definitions(-DODL_CUDA_COMPILE_ALL_TYPES)
endif()
endif()
# Add openMP
option(OPENMP_ENABLED "Enable OpenMP" TRUE)
if(OPENMP_ENABLED)
find_package(OpenMP QUIET REQUIRED)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
# Enable c++11
if (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4251 /bigobj")
if (MSVC_VERSION STREQUAL "1700")
add_definitions(-DODL_MSVC_2012)
endif()
else()
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
if (CUDA_ENABLED)
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}; -std=c++11)
SET(CUDA_PROPAGATE_HOST_FLAGS OFF)
endif()
endif()
# Python bindings
set(Boost_USE_SHARED_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
find_package(Boost COMPONENTS
python
REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
# Find python
find_package(PythonLibs REQUIRED)
find_package(PythonInterp REQUIRED)
include_directories(${PYTHON_INCLUDE_DIRS})
# Find numpy
find_package(Numpy REQUIRED)
include_directories(${PYTHON_NUMPY_INCLUDE_DIR})
link_directories(${PYTHON_LIBRARIES})
# Add sub directories as needed
add_subdirectory (odlcuda)
add_subdirectory (odl_cpp_utils)