-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathCMakeLists.txt
146 lines (110 loc) · 3.79 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
cmake_minimum_required(VERSION 2.8.11)
project(optical-flow-filter)
#################################################
# BUILDING ON WINDOWS
#
# For X64
#
# mkdir build64 & cd build64
# cmake -G "Visual Studio 12 2013 Win64" ..
# cmake --build . --config Release
#
#
# For x86
#
# mkdir build & cd build
# cmake -G "Visual Studio 12 2013"
# cmake --build . --config Release
#################################################
#################################################
# MACROS
#################################################
macro (add_sources)
file (RELATIVE_PATH _relPath "${CMAKE_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}")
foreach (_src ${ARGN})
if (_relPath)
list (APPEND SRCS "${_relPath}/${_src}")
else()
list (APPEND SRCS "${_src}")
endif()
endforeach()
if (_relPath)
# propagate SRCS to parent directory
set (SRCS ${SRCS} PARENT_SCOPE)
endif()
endmacro()
macro (add_gpu_sources)
file (RELATIVE_PATH _relPath "${CMAKE_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}")
foreach (_src ${ARGN})
# message(STATUS "source: " ${_src})
if (_relPath)
list (APPEND GPU_SRCS "${_relPath}/${_src}")
else()
list (APPEND GPU_SRCS "${_src}")
endif()
endforeach()
if (_relPath)
# propagate SRCS to parent directory
set (GPU_SRCS ${GPU_SRCS} PARENT_SCOPE)
endif()
# message(STATUS "gpu sources: " ${GPU_SRCS})
endmacro()
#################################################
# LIBRARY SETTINGS
#################################################
set (LIBRARY_OUTPUT_PATH "lib")
#################################################
# INCLUDE SETTINGS
#################################################
include_directories("${PROJECT_SOURCE_DIR}/include")
#################################################
# COMPILER SETTINGS
#################################################
if(WIN32)
message(STATUS "Configuring for Windows system")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT -DFLOWFILTERLIBRARY_EXPORTS")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd -DFLOWFILTERLIBRARY_EXPORTS")
set(CMAKE_CXX_FLAGS "-DFLOWFILTERLIBRARY_EXPORTS")
elseif(UNIX)
message(STATUS "Configuring for Unix system")
set (CMAKE_CXX_COMPILER "g++")
set (CMAKE_CXX_FLAGS "-std=c++11 -flto -O3 -Wall")
endif(WIN32)
#################################################
# SOURCE FILES SETTINGS
#################################################
# process the CMakeLists.txt file at src/ folder
# it should add all the source files in the folder
add_subdirectory(src)
#################################################
# CUDA SETTINGS
#################################################
find_package(CUDA REQUIRED)
if (CUDA_FOUND)
message(STATUS "found CUDA")
message(STATUS "GPU sources: ${GPU_SRCS}")
message(STATUS "HEADER FILES: ${HEADER_LIST}")
if(WIN32)
message(STATUS "Configuring CUDA for Windows")
# THIS IS NECESSARY FOR WINDOWS BUILD
set(CUDA_NVCC_FLAGS "-DFLOWFILTERLIBRARY_EXPORTS")
# flowfilter_gpu library with CUDA implementation
cuda_add_library(flowfilter_gpu SHARED ${GPU_SRCS})
elseif(UNIX)
message(STATUS "Configuring CUDA for Unix")
set(CUDA_NVCC_FLAGS "-std=c++11 -O3")
set(CUDA_PROPAGATE_HOST_FLAGS OFF)
cuda_add_library(flowfilter_gpu SHARED ${GPU_SRCS})
# install
install(
TARGETS flowfilter_gpu
LIBRARY DESTINATION lib
COMPONENT library
)
# install header files
install(
DIRECTORY include/flowfilter
DESTINATION include
)
endif(WIN32)
endif(CUDA_FOUND)